-
Notifications
You must be signed in to change notification settings - Fork 14
fix(ui): handle deletion preview end_col safely #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ensure that the deletion preview's end_col does not exceed the length of the existing line, preventing potential errors when highlighting deletions in the buffer. This improves robustness when displaying deletion previews.
Ensure that edits and preview insertions beyond the buffer's end are handled gracefully. Adjusts logic to walk to the last line if the edit range exceeds buffer length, and fixes preview rendering for insertions at the buffer's end.
|
CC @AntoineGS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds defensive boundary checks to prevent errors when dealing with buffer line ranges that exceed the actual buffer size, particularly in the NES (Next Edit Suggestion) UI functionality.
- Adds handling for edge cases where edit ranges reference lines beyond the buffer's end
- Fixes potential extmark errors when deletion ranges or insertion lines exceed buffer boundaries
- Adds the
strict = falseparameter to extmark calls to allow more lenient positioning
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| lua/copilot-lsp/nes/ui.lua | Adds boundary checks for line insertions and deletions, including handling when num_old_lines == 0, clamping deletion end columns to existing line length, and adjusting insertion line positions when at buffer end |
| lua/copilot-lsp/nes/init.lua | Adds logic to handle cursor walking when the edit start line is beyond the buffer's end, redirecting to the last valid line instead |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add a new test to verify that suggestion previews are preserved even when deletions occur before the response is displayed. Includes corresponding screenshots for visual verification.
Update preview logic to correctly handle cases where insertion line is past the buffer end. Adjust line calculation to avoid out-of-bounds errors and ensure preview displays as expected. Add test case and screenshot for insertion beyond buffer end.
Simplifies the "deletions before response" test in ui_preview by removing redundant screenshot and state checks. Updates variable names for clarity and applies text edits directly. Removes obsolete screenshot file.
Xuyuanp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ensure that the deletion preview's end_col does not exceed the length of the existing line, preventing potential errors when highlighting deletions in the buffer. This improves robustness when displaying deletion previews.
Fix #52
Fix #58