Skip to content

test(diff): fold the trailing-blank-line spec into the final-line-break spec - #571

Merged
ThomasK33 merged 4 commits into
mainfrom
fix/fold-trailing-newlines-spec
Nov 12, 2026
Merged

ThomasK33 merged 4 commits into
mainfrom
fix/fold-trailing-newlines-spec

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Why

Two integration specs ran the same test for the accepted text of a diff. diff_accept_trailing_newlines_spec.lua (88 lines, from #535) opens a diff, accepts it unedited, and compares the answer with the proposal. diff_accept_missing_final_newline_spec.lua (from #542) does the same over a larger table of layouts, old files and proposals. Both had the same setup and the same four assertions. Twelve of the 28 cases of the trailing spec were also rows of the other one. A second copy of the loop means two places to fix when the accept path changes.

What changed

Only two files change, both under tests/integration/. No file under lua/ or plugin/ changes.

  1. diff_accept_missing_final_newline_spec.lua gets two rows. These were the only cases that the trailing spec ran and the table did not:
    • the proposal "a\n\nb\n\n" ("a blank line inside and one after the last line"), and
    • the old file "a\n" ("a file that is a line shorter").
  2. diff_accept_trailing_newlines_spec.lua is deleted.
  3. The header comment of the table now states which proposals the unified layout lost a line break for. Only a proposal that ends in "\n\n" lost one ("a\n\n" came back as "a\n"). A proposal that ends in a single "\n", such as "a\n" or "\n", kept it.

The merged spec has 136 tests: 3 layouts × 4 old files × 11 proposals, plus the 4 edit tests that were already there. Before, the two specs had 94 + 28 = 122 tests.

Nothing is lost

  1. All 28 cases of the deleted spec are in the merged spec. All 90 matrix cases of the table before this PR are still in it.
  2. The four assertions of the deleted spec are in the table's own helpers: openDiff waits for the user (call._deferred), exactly one answer, the answer is FILE_SAVED, and the accepted text equals the proposal.
  3. Nothing else in the tree names the deleted file (git grep for its name, its describe title and trailing_newlines_spec: 0 hits at the head and on origin/main).

Verification: the merged spec still catches the bug of #535

I reverted #535 (the reverse patch of 884f7e22 on lua/claudecode/diff_inline.lua) and ran each spec alone on a copy of the head.

Spec head #535 reverted
old trailing spec 28 ok 20 ok, 8 failed
old table spec 94 ok 85 ok, 9 failed
merged spec (this PR) 136 ok 120 ok, 16 failed

(The first two rows ran the two specs of the base of this PR, 37ee1e35, on Neovim 0.12.3 and 0.8.0, with the same counts on both. The merged spec's row ran on Neovim 0.12.3, 0.11.5, 0.10.4, 0.9.5 and 0.8.0, with the same counts on all five.)

  1. The 16 failures are the unified layout × 4 old files × the four proposals that end in "\n\n": "a\n\n", "a\n\n\n", "\n\n" and "a\n\nb\n\n". Proposals that end in a single "\n" pass with fix(diff): keep every trailing blank line in an accepted unified diff #535 reverted, as they did before fix(diff): keep every trailing blank line in an accepted unified diff #535.
  2. Every case that failed in either old spec with fix(diff): keep every trailing blank line in an accepted unified diff #535 reverted also fails in the merged spec (the 14 failures of the two old specs, 3 of them shared, are all among the 16).
  3. Two of the 16 are new: "a\n\nb\n\n" against "old" (a file without a final line break) and against a file that does not exist. They come from the new proposal row.

Gates

The head is 1f736d0d95154574376390c92f55bbcf3ad308a3. It merges origin/main at 5c7a4db9. The full gates ran at 76b50be9, the merge before it. The commit after it brings only terminal.lua, scripts/, docs and the new tests/integration/terminal_cwd_spec.lua from main, and nothing in the two specs of this PR. At the head I ran format-check, check.sh --hash-only of all four skills, and the merged spec on Neovim 0.12.3 and 0.8.0 (136 ok each).

  1. mise run all (BUSTED_SEED=97531) exits 0: 1832 successes, 0 failures, 0 errors, 29 pending. luacheck: 0 warnings, 0 errors in 189 files.
  2. mise run format-check exits 0 at both heads (432 files, 0 changed at the last one).
  3. scripts/run_integration_tests_individually.sh exits 0 on Neovim 0.12.3 (Total Success 614, Failed 0, Errors 0) and on Neovim 0.8.0 (Total Success 596, Failed 0, Errors 0).
  4. check.sh --hash-only of verify-diff-lifecycle, verify-mention-queue, verify-selection-tracking and verify-terminal-lifecycle exits 0, at both heads. The full check.sh of verify-diff-lifecycle exits 0 (main 93477 distinct states, live-DisconnectedCallsAnswered 5557). The PR changes no covered file.

One comment line of the table spec is 123 columns wide. It comes from #542 and I left it as it was.


Generated with xum • Model: anthropic:claude-sonnet-5-5 • Thinking: xhigh

…ak spec

diff_accept_trailing_newlines_spec.lua (#535) copied the setup of
diff_accept_missing_final_newline_spec.lua, and 12 of its 28 cases repeated cases
of that spec. Only two rows were new: the proposal "a\n\nb\n\n" and the old file
"a\n". Both rows move into the tables of the final-line-break spec, which runs
them in all three layouts, and the duplicate file goes. Every assertion stays:
one answer, FILE_SAVED, and the accepted text equal to the proposal.

With the fix of #535 reverted, the old trailing spec failed 8 of 28 cases and the
final-line-break spec failed 9 of 94. The merged spec passes 136 of 136 at head,
and with the fix reverted it fails the 16 blank-line cases of the unified layout,
among them every case that either old spec failed.
Only a proposal that ends in "\n\n" lost one. A proposal that ends in a single
"\n" did not, so "ends in blank lines" was too wide.
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T18:10:49.933817Z 1f736d0 Manual request
🔒 Security Review ✅ Completed 2026-11-12T18:11:23.447087Z 1f736d0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 1f736d0d95

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1f736d0d95

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit c529ebe Nov 12, 2026
7 checks passed
@ThomasK33
ThomasK33 deleted the fix/fold-trailing-newlines-spec branch November 12, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant