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

gf misbehaves on paths surrounded by quotes #5533

Closed
theteachr opened this issue Jan 14, 2023 · 2 comments
Closed

gf misbehaves on paths surrounded by quotes #5533

theteachr opened this issue Jan 14, 2023 · 2 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@theteachr
Copy link
Contributor

Summary

When the cursor is on (not selected, on a single char) a path surrounded quotes followed by a comma, pressing gf opens a buffer pointing to a weird path.

Example scene

application_config_map = {
    "kitty": "kitty/.config/kitty/kitty.conf",
    # .................^.....
    "helix": "helix/.config/helix/config.toml",
    "nvim": "nvim/.config/nvim/init.lua",
}

With cursor at the ^ marker (no selection), pressing gf opens a buffer with kitty/.config/kitty/kitty.conf", as the path.

Reproduction Steps

  • In an open buffer, type a path name: .config/helix
  • Surround the path with quotes: '.config/helix'
  • Add a comma at the end: '.config/helix',
  • Place the cursor anywhere on the path name (not on the quote, no selection)
  • Press gf
  • The opened buffer will have a path name like .config/helix,

Helix log

No response

Platform

macOS

Terminal Emulator

kitty 0.26.5

Helix Version

helix 22.12 (e2a1a97)

@theteachr theteachr added the C-bug Category: This is a bug label Jan 14, 2023
@the-mikedavis the-mikedavis added the A-helix-term Area: Helix term improvements label Jan 14, 2023
@ghost
Copy link

ghost commented Jan 14, 2023

I looked at the code and found out this lines:

// Trims some surrounding chars so that the actual file is opened.
let surrounding_chars: &[_] = &['\'', '"', '(', ')'];
paths.clear();
paths.push(
current_word
.fragment(text_slice)
.trim_matches(surrounding_chars)
.to_string(),
);

The problem is not with quotes, but with the comma. I added a comma as another separator and it works.

let surrounding_chars: &[_] = &['\'', '"', '(', ')', ','];

However, I think it's more like hotfix and not desire solution. What do you say (question to maintainers)? Would this be an acceptable solution or should it only remove the comma if it is at the end of the selection?

@pascalkuthe
Copy link
Member

Closed by #9065

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants