Broken regex causing incorrect highlighting
davidhcefx opened this issue · 5 comments
When trying out this project, I found several issues:
- Since I added
include /path/to/nano-highlight/*.nanorc
to my nanorc, the highlighting of.nanorc
had been changed. However, even I removednanorc.nanorc
, it is still happening. To my surprise,rcfiles-new.nanorc
was the culprit:
nano-highlight/rcfiles-new.nanorc
Lines 9 to 11 in 672aad9
Notice the broken regex rc$
, which match not only .bashrc
but also nanorc
. Furthermore, .gtk
would be matched instead of .gtkrc
. The same issue might also exist in other rc files.
bash.nanorc
is colliding its definition of\.sh$
withsh.nanorc
. It does not work as a fallback method, but instead a complete overwrite. More worst, the order of which one overwrite which is ambiguous, so it's definitely not a good idea.
Hmm, I had not noticed this. I'm not sure exactly what I want to do about this, but it needs to be fixed. If you have any suggestions let me know. It is probably going to be a while before I have a chance to take a look & fix this myself.
A couple of possibilities:
syntax "rcfiles" "^(\.?(ba|c|z)sh|input|xinit|eix|\.?wminet|gtk)rc$"
syntax "rcfiles" "^\.?[^.]+rc$"
Thanks for your prompt reply! For the possible fixes, I would prefer the first one, but shouldn't we constraint to .inputrc$
instead of inputrc$
? eg.
syntax "rcfiles" "\.?((ba|c|z)sh|input|xinit|eix|wminet|gtk)rc$"
By the way, don't place a starting anchor to the regex, because it is in fact matching the full path! I've edited my above comment.
Fixed by PR#52