Repository navigation
Conversation
Set OSC1717=V1 for delta and, when its output starts with the handshake, attach each row's line records to the diff line and strip them from the text. Older delta ignores the variable and renders as before.
Delta writes the handshake in front of its first row, not on a row of its own.
Remember the diff line at the top of the view (or the selected one) and, once the re-rendered diff is shown, scroll back to the row with the same OSC 1717 record. Keeping the row index drifted, since unified and side-by-side lay out a different number of rows. Without records the index is kept as before.
Resizing first let the viewport clamp its top row to the old row count, so a taller pane near the bottom moved up. Also skip the anchor when no content row is visible.
Remember the top row's offset from the first row of its anchor record, so a preamble, delta's decoration rows and wrapped rows stay where they were instead of snapping to the record.
Re-renders show the same patch, so the exact record is always there.
When the new layout wraps the anchor line over fewer rows, the offset spilled onto the next diff line. Rows above the anchor keep their offset.
A scroll or jump made before the re-render arrives is no longer undone by the anchor taken at the s press or resize.
ScrollUp/Down/Top/Bottom dropped the pending anchor even at the edge of the diff, where they don't move. They now share Update's check.
Scrolling right after s or a resize kept the row index on the new layout, so a relative move landed on another line. The viewer now keeps the lines on screen and re-anchors to the line the move lands on; g and G still go to the top and bottom. currentRecord gives the record of the current row from those lines.
Git quotes non-ASCII names with octal escapes and delta copies them into the record, so a.txt with an umlaut came through as \303\244.txt.
EditorTarget maps the selected or top visible row's OSC 1717 record to a file and new-file line, using the same row choice as the scroll anchor.
o takes the file and line from the row's OSC 1717 record and builds the editor arguments from ui.editorLineArg (default "+{line} {file}"). Without a line it runs $EDITOR <file> as before. $EDITOR may now carry its own arguments, like "code -w".
EditorTarget reads the record from the lines on screen (currentRecord) instead of the node's diff, which is empty until the new render arrives.
A quoted editor path with spaces works again, and arguments like "code -w" still do. Windows has no sh, so there $EDITOR is still split on spaces.
A side-by-side row pairs a deleted line with an added one, and every d record in a block keeps the block's start as its new line. o now takes the row's new-file record, so it opens the line shown on the right instead of the block start.
Without a repo root the file name from the diff went to $EDITOR as is, so a name like "+!cmd" ran a vim command and "--version" was read as an option.
Windows has no sh, and splitting $EDITOR on spaces broke paths like C:\Program Files\..., which worked before. Run it as one program, as before.
This comment has been minimized.
This comment has been minimized.
pablospe
marked this pull request as draft
November 26, 2026 12:37
Contributor
Author
|
Marked as draft because it depends on #168. |
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.
Summary
Closes #173
Today
oopens the file selected in the tree, always at the top. In a long diff you then have to find the line again by hand, and in the directory view, where several files are shown,oopens the directory.With the OSC 1717 records from #168, diffnav knows which file and line each row shows, so
onow opens the editor right there:oin the directory view opens the file under the line. Without a record it falls back to the tree's current node, as today. Outside a git repo the path is made absolute, so a file name like+cmdor--optisn't read as an editor argument.ui.editorLineArg, is a template with{line}and{file}, used only when the line is known. The default,+{line} {file}, works for vim, nvim, nano, emacs and others. VS Code users set-g {file}:{line}, and helix/zed/subl users set{file}:{line}. The template is split into words before the placeholders are filled in, so a path with spaces stays one argument. There's no detection by editor name.$EDITORnow runs throughsh -c '$EDITOR "$@"', so it can carry arguments (e.g.code -w) or a quoted path with spaces. Windows has nosh, so there$EDITORis the editor's path, as before.oruns$EDITOR <file>exactly as before.Documented in the README: the example config, the options table and the
okey.Stacked PRs
This PR is stacked on #168 (keep the scroll position), and its diff includes #168's commits until that one merges. To see only this PR's changes (the last 12 commits): pablospe/diffnav@osc1717...editor-line
How Did You Test this Change?
d+arows (including a block's later rows, wheredkeeps the block start), a lonedrow, another file, no record, selection mode, and a directory node during a pending re-render.shcommand is run for real with a quoted editor path that has a space, plus-w, and no$EDITOR. On Windows$EDITORstays one program path. Outside a repo the path is absolute.go test ./...,go vet ./...andgolangci-lint run/golangci-lint fmt(v2.12.2) pass.EDITORset to a script that logs its arguments, in a repo whose path has a space, with delta 0.20.1:oon context, added, deleted and hunk-header rows, in unified and side-by-side, and in selection mode.editorLineArg: "-g {file}:{line}"withEDITOR="... -w".oopens the tree node as on main.ä.txt) opens the right file at the right line, withEDITOR="'/path/my ed/ed' -w".Images/Videos
With selection on (
v), using the defaultui.editorLineArgandEDITOR=vim:oon an added line in unified opens vim at line 35. Afters,oon a context line opens it at line 33.oon the file header opens just the file.AI disclosure
Claude Code was used to write the code and tests. I reviewed the changes and tested them manually.