orbitalquark / scintillua

Scintillua enables Scintilla lexers to be written in Lua, particularly using LPeg. It can also be used as a standalone Lua library for syntax highlighting support.
https://orbitalquark.github.io/scintillua
MIT License
52 stars 22 forks source link

Bash Lexer incorrectly treats '#' as start of comment in variable pattern match #95

Closed rnpnr closed 1 year ago

rnpnr commented 1 year ago

Hi I was reviewing a patchset to update vis to use scintillua 6.2 (devel_scintillua branch here) and I noticed that the bash lexer can no longer handle pattern matching in variables. For example any text like this snippet from our configure script:

--prefix=*) PREFIX=${arg#*=} ;;
--exec-prefix=*) EXEC_PREFIX=${arg#*=} ;;
--bindir=*) BINDIR=${arg#*=} ;;
--sharedir=*) SHAREDIR=${arg#*=} ;;
--docdir=*) DOCDIR=${arg#*=} ;;
--mandir=*) MANDIR=${arg#*=} ;;

It seems like the lexer can't find the closing } because the # is being treated as the start of a comment.

I bisected the issue and it was introduced in b909d43 when the lexer was updated to the new format. Unfourtantely I am not familiar with how the lexers are implemented here so I was unable to make a patch but it seems like there used to be a lexer.range('{', '}', true, false, true) for variables that is no longer there.

orbitalquark commented 1 year ago

Thanks for the report! This should be fixed via https://github.com/orbitalquark/scintillua/commit/0a8c23d5229eaa4942facaefa5e48e017d0d4636

rnpnr commented 1 year ago

Thanks for the quick fix! I found another problem but I'll open a separate issue.