fix(diff): align inline highlight offsets with tab-expanded text#1709
fix(diff): align inline highlight offsets with tab-expanded text#1709ahyangyi wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
913f2d2 to
fd21ddb
Compare
e1f8bcd to
ac70c64
Compare
ac70c64 to
e42bc89
Compare
e42bc89 to
e3d6a02
Compare
e3d6a02 to
d191840
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…anges Diff on raw code so whitespace-only changes (e.g. tab to spaces) are detected, then map raw offsets to rendered offsets using expandtabs column semantics with a defensive fallback if lengths mismatch. - Add _build_offset_map using expandtabs column tracking with bounded monotonic fallback when rendered length diverges - Reuse highlighted Text objects for skipped (low-similarity) pairs to avoid redundant highlighting - Preserve trailing whitespace in highlighted output (strip only the newline Pygments appends, not meaningful trailing spaces) - Use public Text.spans instead of private Text._spans in tests - Add tests for tab-indented diffs, tab-to-space changes, mixed tab+space edits, precise per-character offsets, and trailing whitespace preservation
0e73271 to
9f92b78
Compare
| - Shell: Add `/undo` and `/fork` commands for session forking — `/undo` lets you pick a previous turn and fork a new session with the selected message pre-filled for re-editing; `/fork` duplicates the entire session history into a new session; the original session is always preserved | ||
| - CLI: Add `-r` as a short alias for `--session` and print a resume hint (`kimi -r <session-id>`) whenever a session exits — covers normal exit, Ctrl-C, `/undo`, `/fork`, and `/sessions` switch so users can always find their way back | ||
| - Core: Fix `custom_headers` not being passed to non-Kimi providers — OpenAI, Anthropic, Google GenAI, and Vertex AI providers now correctly forward custom headers configured in `providers.*.custom_headers` | ||
| - Shell: Fix inline diff highlights misaligned on lines containing tabs — raw-code diff offsets are now mapped to rendered positions via expandtabs column tracking so highlight spans land correctly after tab expansion |
There was a problem hiding this comment.
🟡 Changelog entry for tab diff fix placed under already-released 1.30.0 instead of 1.31.0 or Unreleased
The new changelog entry "Shell: Fix inline diff highlights misaligned on lines containing tabs" is added at the end of the ## 1.30.0 (2026-04-02) section in all three changelog files. However, the git log shows this commit (9f92b786) was made after the 1.31.0 version bump (49d13668 chore: bump kimi-cli 1.31.0), so it cannot be part of the already-released 1.30.0. The entry should be under ## 1.31.0 (2026-04-10) or ## Unreleased. This misplacement is consistently wrong across CHANGELOG.md, docs/en/release-notes/changelog.md, and docs/zh/release-notes/changelog.md.
Prompt for agents
The new changelog entry on line 57 of CHANGELOG.md is placed under the '## 1.30.0 (2026-04-02)' section header (line 40), but this fix is being committed after the 1.31.0 version bump. Move this entry from the 1.30.0 section to the 1.31.0 section (under '## 1.31.0 (2026-04-10)' at line 14) in all three changelog files: CHANGELOG.md, docs/en/release-notes/changelog.md, and docs/zh/release-notes/changelog.md. In each file, delete the entry from its current position in the 1.30.0 section and add it as the last bullet under the 1.31.0 section header.
Was this helpful? React with 👍 or 👎 to provide feedback.
Related Issue
N/A
Description
When modifying a file with tabs (
\t), the inline diff highlights appear at wrong positions.This is caused by the current order of operations:
This PR swaps 1) and 2) to avoid the problem.
(I did ran
make gen-docsbut it decided to produce lots of 1.28-1.29 updates, which is probably irrelevant here so I reverted those change)Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.