fix: highlight keywords when keyword is actual identifier (#9019)

This PR fixes a bug where semantic highlighting would only highlight
keywords that started with an alphanumeric character. Now, it uses
`Lean.isIdFirst`.
This commit is contained in:
Marc Huisinga 2025-06-27 10:23:10 +02:00 committed by GitHub
parent 1a6eae16ec
commit 1edb7632b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,8 +110,8 @@ partial def collectSyntaxBasedSemanticTokens : (stx : Syntax) → Array LeanSema
stx.getArgs.map collectSyntaxBasedSemanticTokens |>.flatten
let Syntax.atom _ val := stx
| return tokens
let isRegularKeyword := val.length > 0 && val.front.isAlpha
let isHashKeyword := val.length > 1 && val.front == '#' && (val.get ⟨1⟩).isAlpha
let isRegularKeyword := val.length > 0 && isIdFirst val.front
let isHashKeyword := val.length > 1 && val.front == '#' && isIdFirst (val.get ⟨1⟩)
if ! isRegularKeyword && ! isHashKeyword then
return tokens
return tokens.push ⟨stx, keywordSemanticTokenMap.findD val .keyword⟩