Repository navigation
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.
Collaborator
Author
|
CC @AntoineGS |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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