Sorting breaks syntax sometimes
Gnarus-G opened this issue ยท 7 comments
Describe the bug
When I run the sort command, some classNames get place outside of the quotes.
To Reproduce
I prepared a repo you can clone: https://github.com/Gnarus-G/tailwind-tools-bug-repo
Steps to reproduce the behavior:
- Open
src/app/page.tsx
- Run the
:TailwindSort
command - See error
Expected behavior
Doesn't create any syntax errors.
Environment (please complete the following information):
- Operating system: Linux rig 6.8.1-zen1-1-zen # 1 ZEN SMP PREEMPT_DYNAMIC Sat, 16 Mar 2024 17:15:23 +0000 x86_64 GNU/Linux
- Neovim version: NVIM v0.10.0-dev-2657+g9765efb40f
Build type: RelWithDebInfo
LuaJIT 2.1.1702233742 - Nvim-treesitter commit: Latest commit of master
- tailwind-language-server version:
0.0.16
Oh, I missed something with javascript expressions range, the backticks were also included in the range.
I think I just realized how tricky handling the full javascript expression is, maybe I should limit the class range to the string inside the expression {"..."}
It should work now, thanks for the report!
No. Thank you for the plugin.
I'm actually struggling with a very similar issue. it breaks when the pattern is something like:
className={ <backtick> h-6 ${openIndex === index ? "block" : "hidden"} w-6 leading-6 </backtick>}
using :TailwindSort
will then produce something like:
className={ <backtick> h-6 ${openIndex === index ? "block" : "hidden"} w-6 </backtick> leading-6 }
EDIT in case its unclear: I replaced ` in the example with since using it would break the formatting.
Thanks for pointing out the issue, it was a regression but it should be fixed now.
I just tested it and it works perfectly! Thanks for the fast fix ๐๐ผ