Can't navigate to component file without trailing characters on opening tag line
Hi!
Given the following component,
`<x-button class="btn" />`
I want to format that onto multiple lines like so, to make the markup more vertical:
```
<x-button
class="btn"
/>
```
I've found that the navigation does not work because blade-nav is not able to find the component name. If I add a single whitespace character at the end of that line, the navigation works as expected. I think the key is to edit the strategy for finding a start and end position in [gf.lua:274](https://github.com/RicardoRamirezR/blade-nav.nvim/blob/3b4114b2df22fc3b415845a19d502255696c5d79/lua/blade-nav/gf.lua#L274).
I have a pull request [here](https://github.com/RicardoRamirezR/blade-nav.nvim/issues/35). I added a fallback regex that just looks for the end of the line instead of the name-ending characters in the original:
`local start_pos, end_pos = text:find("[,%s>%)]", col) or text:find("$", col), text:find("$", col)`
This provides the last character index of the line as the `start_pos` and `end_pos` (which is fine because `start_pos` is replaced in the backwards search anyway). However, I'm very open to suggestions for this solution.
关闭于 2024-12-17 1 条评论