Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Find a capitalised extension's lexer again
Scintillua's detect() matches an extension by its case, and the fallback
e1960f0 dropped had lowercased it, so MAIN.C and SETUP.PY lost their
colour. The fake lexer now answers only for the suffixes it knows, as
Scintillua does, which is what lets the check see it.
Diffstat (limited to 'custom/extensions/syntax-highlight.lua')
| -rw-r--r-- | custom/extensions/syntax-highlight.lua | 6 |
1 file changed, 4 insertions, 2 deletions
diff --git a/custom/extensions/syntax-highlight.lua b/custom/extensions/syntax-highlight.lua index 282b0cf..7414b63 100644 --- a/custom/extensions/syntax-highlight.lua +++ b/custom/extensions/syntax-highlight.lua @@ -153,9 +153,11 @@ local function load_scintillua() end -- The first line goes along to detect(), so a script with no extension is --- still known by its shebang. +-- still known by its shebang. detect() matches an extension by its case, so +-- a name in capitals such as MAIN.C is tried again in lower case. local function lexer_for(name, text) - local lang = scintillua.detect(name, string.match(text, "^[^\n]*")) + local first = string.match(text, "^[^\n]*") + local lang = scintillua.detect(name, first) or scintillua.detect(string.lower(name), first) return lang and scintillua.load(lang) end |
