feat(ui): add toggleable line numbers in diff gutterLine numbers#21
feat(ui): add toggleable line numbers in diff gutterLine numbers#21umputun merged 12 commits intoumputun:masterfrom
Conversation
umputun
left a comment
There was a problem hiding this comment.
the line numbers feature itself looks good, two-column old/new is the right approach (we had single-column before and removed it because it was confusing in diff mode).
the branch needs a rebase on master though - it's based on a commit before --all-files/--exclude was merged, so the diff shows those files as "removed." once rebased the diff should be clean.
couple things to fix:
- linter:
var old, new stringindiffview.go:30-newshadows the Go builtin, rename to smth likeoldCol/newCol - linter: untagged switch in
diffview.go:31- useswitch dl.ChangeType { case ... }instead ofswitch { case dl.ChangeType == ... } lineNumGuttercomment says "raw ANSI" but usesm.styles.LineNumber.Render()(lipgloss). works fine in practice since the gutter is concatenated before content, but the comment is misleading - pls fix
There was a problem hiding this comment.
Pull request overview
Adds an optional old/new side-by-side line-number gutter to the diff view, toggleable at runtime with the L key, and updates rendering across normal/wrapped/collapsed modes plus documentation and tests.
Changes:
- Introduce
Model.lineNumbers+Model.lineNumWidth, compute width per file, and addLkey handling + status bar indicator. - Prepend a two-column old/new line-number gutter to diff rendering (normal, wrapped, collapsed, delete placeholders), including width adjustments for wrapping and horizontal scroll.
- Add unit/integration-style tests for toggling, width computation, gutter formatting, and rendered output; update help/README/plugin usage docs.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
ui/model.go |
Adds model state + key handling for toggling and width recomputation on file load. |
ui/model_test.go |
Adds tests covering toggle behavior, width computation, help/status indicators, and an end-to-end render check. |
ui/diffview.go |
Implements gutter formatting and integrates it into normal/wrapped diff rendering and scroll/wrap width math. |
ui/diffview_test.go |
New tests for gutter formatting and rendering with/without line numbers (incl. wrap). |
ui/collapsed.go |
Integrates the gutter into collapsed-mode rendering paths and adjusts wrap/scroll calculations. |
ui/collapsed_test.go |
Adds a collapsed-mode render test with line numbers enabled. |
ui/annotate.go |
Adjusts delete-placeholder wrap-height accounting to include the extra gutter width. |
README.md |
Documents the new L keybinding and feature in the key table/features list. |
CLAUDE.md |
Updates internal notes/docs to include the new line-number mode and keybinding. |
.claude-plugin/skills/revdiff/references/usage.md |
Updates plugin usage docs with the L toggle keybinding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix horizontal scroll cut width not accounting for line number gutter width in renderDiffLine, renderCollapsedAddLine, renderDeletePlaceholder - Fix cursorViewportY delete-placeholder wrap width ignoring line numbers - Update CLAUDE.md with # status icon, L key dispatch, line number data flow - Update README.md and plugin usage.md with L keybinding
Rename var old/new to oldCol/newCol to avoid shadowing Go builtin. Use tagged switch on dl.ChangeType instead of untagged switch. Fix comment: gutter uses lipgloss style, not raw ANSI.
Align with toggleWrapMode/toggleCollapsedMode by checking m.focus == paneDiff before toggling, so pressing L while the tree pane is focused is a no-op.
|
Rebased on latest master — diff is clean now. Fixes:
|
umputun
left a comment
There was a problem hiding this comment.
lgtm, all review points addressed. thx
The line numbers toggle (L key) from umputun#21 was runtime-only. This adds a CLI flag, env var, and config file option so users can enable line numbers by default.
The line numbers toggle (L key) from #21 was runtime-only. This adds a CLI flag, env var, and config file option so users can enable line numbers by default.

Summary
Adds side-by-side old/new line number columns to the diff gutter, toggled at runtime with
Lkey.Closes #20
What's changed
Lkey toggles line number display on/offOOO NNNformat)w), and collapsed (v)#status bar icon indicates when line numbers are active?) documents theLkeybindingImplementation
lineNumbersbool andlineNumWidthint fields on the ModellineNumGutter(dl)helper formats the gutter using muted ANSI (raw sequences, no lipgloss reset)renderDiffLine,renderWrappedDiffLine,renderCollapsedAddLine,renderDeletePlaceholderhandleFileLoadedandtoggleLineNumbersTest plan
Credits
powered by