helix icon indicating copy to clipboard operation
helix copied to clipboard

gf misbehaves on paths surrounded by quotes

Open theteachr opened this issue 1 year ago • 1 comments

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 (e2a1a975)

theteachr avatar Jan 14 '23 14:01 theteachr

I looked at the code and found out this lines:

https://github.com/helix-editor/helix/blob/b6331394a3f341ad21f8fad3e6e0b93becda9ce5/helix-term/src/commands.rs#L1051-L1059

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?

ghost avatar Jan 14 '23 19:01 ghost

Closed by #9065

pascalkuthe avatar Apr 14 '24 01:04 pascalkuthe