Tweak highlighting for keywords
All checks were successful
timw4mail/scroll/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2024-07-19 15:55:16 -04:00
parent 21d26ede6c
commit 6101132a15
2 changed files with 14 additions and 5 deletions

View File

@ -117,6 +117,9 @@ export class JavaScriptFile extends AbstractFileType {
'^',
'~',
'!',
'.',
',',
';',
];
public readonly hlOptions: HighlightingOptions = {
...defaultHighlightOptions,

View File

@ -443,11 +443,17 @@ export class Row {
}
for (const keyword of keywords) {
if (i + strlen(keyword) < this.rsize) {
const nextChar = this.rchars[i + strlen(keyword)];
if (!isSeparator(nextChar)) {
continue;
}
// Skip keywords that can't fit in the current line
if (i + strlen(keyword) >= this.rsize) {
continue;
}
// Check the character after the keyword
// if it is not a 'separator' character,
// we must be highlighting the middle of something else
const nextChar = this.rchars[i + strlen(keyword)];
if (!isSeparator(nextChar)) {
continue;
}
const maybeHighlight = this.highlightStr(i, keyword, hl_type);