fix(nes): correct inline diff artifact when appending to end of line#250
Merged
folke merged 1 commit intofolke:mainfrom Mar 16, 2026
Merged
Conversation
Owner
|
ty! |
folke
pushed a commit
that referenced
this pull request
Mar 20, 2026
🤖 I have created a release *beep* *boop* --- ## [2.2.0](v2.1.0...v2.2.0) (2026-03-20) ### Features * **agents:** add pi agent ([#247](#247)) ([7e9da9b](7e9da9b)) * **nes:** set `nes.diff.show = "cursor"` to only show nes diffs at the cursor. Closes [#266](#266) ([b1568d3](b1568d3)) * **terminal:** add files/buffers inline with spaces from picker. Closes [#133](#133) ([e743ac7](e743ac7)) * **terminal:** make re-entering terminal/normal mode more sensible ([9eb6530](9eb6530)) ### Bug Fixes * **codex:** update deprecated search option ([#166](#166)) ([88cb6dd](88cb6dd)) * **config:** remove web search option from codex command ([#257](#257)) ([f8b4f58](f8b4f58)) * **config:** update codex search option ([#167](#167)) ([c302dba](c302dba)) * **nes:** correct inline diff artifact when appending to end of line ([#250](#250)) ([f95ba54](f95ba54)) * **nes:** never process cancelled (or out of order) requests ([f8eac10](f8eac10)) * **opencode:** Use alt+p instead of ctrl+p. Fixes [#175](#175) ([a6fe80f](a6fe80f)) * **terminal:** ready check should not fail if cli window is closed. Fixes [#252](#252) ([6b69c42](6b69c42)) * **treesitter:** dont use treesitter stringbuffers ([317ada1](317ada1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
msurovcak
pushed a commit
to msurovcak/sidekick.nvim
that referenced
this pull request
Apr 14, 2026
…olke#250) ## Description When using inline diff mode (`chars` or `words`), appending characters to the end of a line produces a spurious delete-then-re-add of the last existing token before showing the actual insertion. For example, adding a comma after `hello` renders as: delete `o`, add `o`, add `,` — instead of simply showing the `,` insertion. ### Root cause `_diff` joins token arrays with `\n` via `table.concat(a, "\n")`, producing strings with no trailing newline. When a token is appended, the previously-last token changes from `token<EOF>` to `token\n`, causing `vim.diff` to treat it as a different line. This is the classic "No newline at end of file" diff artifact. ### Fix Append a trailing `\n` to non-empty diff inputs so all tokens are uniformly newline-terminated. Empty inputs (from edits targeting lines beyond the buffer) are left as `""` to preserve correct insert-vs-change semantics. The existing test "insertion after last column keeps inline change" was asserting the buggy behavior (a `change` hunk with 2 extmarks). It now correctly expects an `add` hunk with a single extmark. ## Related Issue(s) Fixes folke#251 ## Screenshots N/A (inline virtual text rendering change; no new UI elements)
msurovcak
pushed a commit
to msurovcak/sidekick.nvim
that referenced
this pull request
Apr 14, 2026
🤖 I have created a release *beep* *boop* --- ## [2.2.0](folke/sidekick.nvim@v2.1.0...v2.2.0) (2026-03-20) ### Features * **agents:** add pi agent ([folke#247](folke#247)) ([7e9da9b](folke@7e9da9b)) * **nes:** set `nes.diff.show = "cursor"` to only show nes diffs at the cursor. Closes [folke#266](folke#266) ([b1568d3](folke@b1568d3)) * **terminal:** add files/buffers inline with spaces from picker. Closes [folke#133](folke#133) ([e743ac7](folke@e743ac7)) * **terminal:** make re-entering terminal/normal mode more sensible ([9eb6530](folke@9eb6530)) ### Bug Fixes * **codex:** update deprecated search option ([folke#166](folke#166)) ([88cb6dd](folke@88cb6dd)) * **config:** remove web search option from codex command ([folke#257](folke#257)) ([f8b4f58](folke@f8b4f58)) * **config:** update codex search option ([folke#167](folke#167)) ([c302dba](folke@c302dba)) * **nes:** correct inline diff artifact when appending to end of line ([folke#250](folke#250)) ([f95ba54](folke@f95ba54)) * **nes:** never process cancelled (or out of order) requests ([f8eac10](folke@f8eac10)) * **opencode:** Use alt+p instead of ctrl+p. Fixes [folke#175](folke#175) ([a6fe80f](folke@a6fe80f)) * **terminal:** ready check should not fail if cli window is closed. Fixes [folke#252](folke#252) ([6b69c42](folke@6b69c42)) * **treesitter:** dont use treesitter stringbuffers ([317ada1](folke@317ada1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.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.
Description
When using inline diff mode (
charsorwords), appending characters to the end of a line produces a spurious delete-then-re-add of the last existing token before showing the actual insertion. For example, adding a comma afterhellorenders as: deleteo, addo, add,— instead of simply showing the,insertion.Root cause
_diffjoins token arrays with\nviatable.concat(a, "\n"), producing strings with no trailing newline. When a token is appended, the previously-last token changes fromtoken<EOF>totoken\n, causingvim.diffto treat it as a different line. This is the classic "No newline at end of file" diff artifact.Fix
Append a trailing
\nto non-empty diff inputs so all tokens are uniformly newline-terminated. Empty inputs (from edits targeting lines beyond the buffer) are left as""to preserve correct insert-vs-change semantics.The existing test "insertion after last column keeps inline change" was asserting the buggy behavior (a
changehunk with 2 extmarks). It now correctly expects anaddhunk with a single extmark.Related Issue(s)
Fixes #251
Screenshots
N/A (inline virtual text rendering change; no new UI elements)