diff --git a/src/common/filetype/javascript.ts b/src/common/filetype/javascript.ts index e388ce8..2d1a118 100644 --- a/src/common/filetype/javascript.ts +++ b/src/common/filetype/javascript.ts @@ -117,6 +117,9 @@ export class JavaScriptFile extends AbstractFileType { '^', '~', '!', + '.', + ',', + ';', ]; public readonly hlOptions: HighlightingOptions = { ...defaultHighlightOptions, diff --git a/src/common/row.ts b/src/common/row.ts index 5407be8..4ff6408 100644 --- a/src/common/row.ts +++ b/src/common/row.ts @@ -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);