nes: fix: do not insert spurious trailing newline after suggestion#311441
Merged
nes: fix: do not insert spurious trailing newline after suggestion#311441
Conversation
… the suggestion Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts NES inline suggestion conversion for the “insert on next line” case to avoid introducing an extra trailing newline (which can render as a spurious blank line when shown/applied as ghost text).
Changes:
- Trim a single trailing newline from
newTextwhen massaging a next-line insertion into a cursor-line pure insertion. - Update existing unit tests to reflect the trimmed trailing newline behavior.
- Add a regression test covering insertion into an object literal scenario.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/extension/inlineEdits/vscode-node/isInlineSuggestion.ts | Trims a trailing linefeed when converting next-line insertions into cursor insertions for inline suggestions. |
| extensions/copilot/src/extension/inlineEdits/test/vscode-node/isInlineSuggestion.spec.ts | Updates expectations and adds a regression test for the new trimming behavior. |
Copilot's findings
Comments suppressed due to low confidence (1)
extensions/copilot/src/extension/inlineEdits/test/vscode-node/isInlineSuggestion.spec.ts:154
- Same issue as above:
replace(/\n$/, '')isn't CRLF-safe and can leave a trailing\r. Prefer stripping\r?\nso the test matches expected behavior across EOL styles.
assert.strictEqual(result!.newText, '\n' + replaceText.replace(/\n$/, ''));
- Files reviewed: 2/2 changed files
- Comments generated: 2
Co-authored-by: Copilot <copilot@github.com>
roblourens
approved these changes
Apr 20, 2026
auto-merge was automatically disabled
April 20, 2026 19:10
Pull request was closed
ulugbekna
added a commit
that referenced
this pull request
Apr 20, 2026
…311441) * nes: show how insertion at cursor leaves an unnecessary newline after the suggestion Co-authored-by: Copilot <copilot@github.com> * nes: fix: do not insert spurious trailing newline after suggestion Co-authored-by: Copilot <copilot@github.com> * account for CRLF Co-authored-by: Copilot <copilot@github.com> --------- Co-authored-by: Copilot <copilot@github.com>
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.
No description provided.