Skip to content

Add editfileoncursor command and bind it to gf in vim and helix - #228

Open
Seyamalam wants to merge 1 commit into
unstablebuild:mainfrom
Seyamalam:feat-edit-file-on-cursor
Open

Seyamalam wants to merge 1 commit into
unstablebuild:mainfrom
Seyamalam:feat-edit-file-on-cursor

Conversation

@Seyamalam

Copy link
Copy Markdown
Contributor

The presets bound gf to an editfileoncursor command that did not exist, so the
binding was dead; in modal modes vi's gMode swallowed the g anyway. The new command
reads the path-like token under the cursor (or the visual selection verbatim), resolves
it as absolute or ~-expanded, then relative to the current file's directory, then the
workspace root, all through the workspace file system so remote workspaces work too, and
opens the first match, landing on :line[:column] when given.

gf is bound in vi.KeyBindings and helix.KeyBindings, which complete the sequence
when the editor declines the second key. The bare gf in command.key_bindings moves
to <c-x>f, since a bare two-letter binding conflicts with typing in modeless presets;
the duplicate entry in the dead tui_cmd_bindings table is removed.

Fixes #145

Created with SWE-2 Max in T3 Code.


Authorship

  • Written by hand. I would like a human review.
  • Mostly or partially generated by an AI agent, which I reviewed and understand.

The presets bound gf to an editfileoncursor command that did not
exist, so the binding was dead and in modal modes vi's gMode
swallowed the g anyway. The command reads the path-like token under
the cursor (or the visual selection), resolves it as absolute or
~-expanded, then relative to the current file's directory, then the
workspace root through the workspace file system, and opens the first
match, landing on :line[:column] when given. gf is bound in the vi
and helix KeyBindings; the bare gf in command.key_bindings moves to
<c-x>f so modeless presets keep a reachable binding.

Fixes unstablebuild#145

Generated with Devin (https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: Seyamalam <seyamalam41@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 87.69231% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/ide/ex.go 86.11% 5 Missing ⚠️
internal/handler/locationsearch/locationsearch.go 85.71% 2 Missing ⚠️
internal/text/component.go 90.90% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

Add gf (edit file under cursor) command to core and bind it in vim and helix modes

2 participants