cbochs / grapple.nvim

Neovim plugin for tagging important files
MIT License
545 stars 20 forks source link

fix: problems with paths with spaces #156

Closed derSicking closed 5 months ago

derSicking commented 5 months ago

Earlier today, I encountered a problem when adding files with spaces in their name. Closing and reopening Neovim or even just opening the Tags Window would lose part of the file name and I could no longer open the correct file via Grapple.

Example: "this is a file.md" would become "file.md", everything up to the part after the last whitespace was dropped.

I figured this would be reasonably simple to fix and looked into it myself. My code is probably pretty bad, but it seems to work, and I included some comments and new tests.

cbochs commented 5 months ago

Hi @derSicking, thanks for creating a PR! This is indeed something I felt might come up at some point. Taking a look here, I think this might be better solved with setting the name as an extmark instead of adding it to the display string. Contrary to the comment here, [:h nvim_buf_set_extmark()](https://neovim.io/doc/user/api.html#nvim_buf_set_extmark()) does allow for setting the virtual text position to be inline. So the name could just be an inlined extmark before the path instead of an actual part of the display text.

cbochs commented 5 months ago

This should be fixed in 7b53a86ba4e0cdb6a58ff38d9d0d2e9f802e1ff9. The name is now added as an extmark instead of a string when name_pos = "start" 🙂