Skip to content

feat(ui): respect current line when opening in $EDITOR - #713

Open
JammingBen wants to merge 2 commits into
modem-dev:mainfrom
JammingBen:feat/line-number-external-editors
Open

feat(ui): respect current line when opening in $EDITOR#713
JammingBen wants to merge 2 commits into
modem-dev:mainfrom
JammingBen:feat/line-number-external-editors

Conversation

@JammingBen

Copy link
Copy Markdown

Make opening a file in $EDITOR respect the line number of the current cursor instead of opening at the start of the selected hunk.

Also move the AppHost edit-selected-file shortcut tests into a dedicated file, since I figured they don't really belong in src/ui/AppHost.sidebar-resize.test.tsx.

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@JammingBen is attempting to deploy a commit to the Modem Team on Vercel.

A member of the Team first needs to authorize it.

@JammingBen
JammingBen force-pushed the feat/line-number-external-editors branch from 46baa3f to 51c2cb6 Compare August 11, 2026 18:26

@benvinegar benvinegar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main behavior looks good. This just needs a rebase onto main; I left two old-side mapping edge cases inline.

This comment was generated by Pi using gpt-5.6-sol

Comment thread src/ui/lib/openInEditor.ts Outdated
function deletionLineToFileLine(hunk: DiffHunk, deletionLine: number) {
let deletionCursor = hunk.deletionStart;
// A zero-count side names the line before the change, so step past it to land inside the file.
let additionCursor = hunk.additionCount === 0 ? hunk.additionStart + 1 : hunk.additionStart;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a deletion at EOF, this can request a line past the end of the resulting file. Should we clamp it to the final line?

This comment was generated by Pi using gpt-5.6-sol

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be handled gracefully by every editor that supports this feature, and all other editors don't get a line reported anyways.

I might be wrong on that, but I think we would need the true file count, which we can only reliably get with isPartial: false, or when reading the file content (e.g. via readFileSync). So given the target editors already handle it, I'd rather not change it.

But if you still want me to tackle it, I can do so.

Make opening a file in $EDITOR respect the line number of the current
cursor instead of opening at the start of the selected hunk.
@JammingBen
JammingBen force-pushed the feat/line-number-external-editors branch from 51c2cb6 to f07fa83 Compare August 12, 2026 05:48
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.

2 participants