Skip to content

Conversation

gnodet
Copy link
Member

@gnodet gnodet commented Apr 21, 2025

Add support for suggestion boxes in Nano editor

This PR enhances the Nano editor with intelligent suggestion boxes, improving the code editing experience.

Features

  • Smart Suggestion Boxes: Displays suggestion boxes that intelligently position themselves below or above the cursor based on available space
  • Documentation Support: Shows documentation alongside suggestions for better context
  • Diagnostic Tooltips: Displays diagnostic messages when hovering over code with issues
  • Improved Mouse Handling: Enhanced mouse support for interacting with suggestions and diagnostics
  • Adaptive UI: Boxes automatically resize based on content and available screen space
  • Scrollable Suggestions: Support for scrolling through large suggestion lists

Implementation Details

  • Added a new Box class to handle drawing and managing suggestion boxes
  • Implemented positioning logic that tries to display boxes below the cursor first (more natural) and falls back to displaying above when there's not enough space
  • Added support for LSP_SUGGESTION operation for code completion
  • Refactored Buffer class to be more extensible and support these new features
  • Improved auto-indentation logic for better code formatting

Fixes #1194

@gnodet gnodet mentioned this pull request Apr 24, 2025
@gnodet gnodet added this to the 3.29.1 milestone Apr 26, 2025
@gnodet gnodet force-pushed the jline-1194 branch 2 times, most recently from 0c87cb3 to 4ff0aaf Compare May 6, 2025 12:16
@gnodet gnodet marked this pull request as ready for review May 6, 2025 21:49
@gnodet gnodet force-pushed the jline-1194 branch 5 times, most recently from 8aaf7cd to e262fed Compare May 8, 2025 21:38
gnodet added 2 commits May 9, 2025 08:47
…ng compatibility

- Add support for UTF-8 mouse mode (1005) in addition to existing modes
- Modify trackMouse to send combined sequence for maximum compatibility
- Add keys() method to return possible mouse event prefixes
- Avoid duplicates in mouse event prefixes
- Improve documentation
This commit enhances the Nano editor with support for displaying suggestion boxes:

- Added support for displaying suggestion boxes below or above the cursor
- Implemented intelligent positioning logic to place boxes where there's more space
- Added support for displaying documentation alongside suggestions
- Improved mouse handling to support hovering over diagnostics
- Added support for displaying diagnostic messages in tooltips
- Refactored code to make the Buffer class more extensible
- Added LSP_SUGGESTION operation for code completion

This implementation follows best practices for UI/UX by:
1. Trying to display boxes below the cursor first (more natural)
2. Falling back to displaying above when there's not enough space below
3. Limiting box size to avoid overwhelming the screen
4. Supporting scrolling for large suggestion lists
@gnodet gnodet merged commit ed279e1 into jline:master May 9, 2025
9 checks passed
@gnodet gnodet added the feature label May 9, 2025
@gnodet gnodet deleted the jline-1194 branch May 9, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pluggable completion to Nano editor
1 participant