Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goto_file: Try multiple relative paths (including cwd) to find existing files #11859

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

inducer
Copy link

@inducer inducer commented Oct 9, 2024

I am editing files that contain paths of other files. Those paths are relative to the repository root, not the path in which the document resides. Therefore, the current implementation of gf/goto_file does the wrong thing for me, namely interpret those paths as relative to the latter. This change makes helix look for files with the given name relative to multiple locations: the directory containing the document, and the editor's current working directory. I approached this change in this way to avoid changing the behavior for folks for whom the current semantics work fine.

My rust skill is basically non-existent, so I am glad that I was able to cobble something together that seems to work for me. Feedback is very welcome though.

if cwd.exists() {
search_paths.push(cwd);
}
// FIXME: Also include project root? Or just use project root, not cwd?
Copy link
Author

Choose a reason for hiding this comment

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

I could not quickly figure out how to find the LSP root for the document, but if available, this may be a better (or at least a valid additional) choice.

@the-mikedavis the-mikedavis added the A-command Area: Commands label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-command Area: Commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants