fix: remove short-circuting when offset is non-zero

Short-circuiting while offset is a non-zero value causes unexpected result when the parser intializes parsing. If it happens, the current context isn't obtained. Hence, tokens that intended to be resolved when facing the end of current line (i.e. due to current context being different with the previous one) may not be resolved.
This commit is contained in:
kotaindah55 2025-02-03 23:40:47 +02:00
parent f7376eea86
commit 04a88cb15a

View file

@ -174,7 +174,6 @@ export class ParserState {
this.curCtx = ctx;
}
resolveContext() {
if (this.offset) { return }
while (this.cursorPos() == "before") { this.nextCursor() }
this.setContext(this.getContext());
let isSkip = false,
@ -207,9 +206,11 @@ export class ParserState {
toBeResolved = true;
offset -= 1;
}
toBeResolved && this.queue.resolve(NonHighlightFormats, offset);
includesHl && this.queue.resolve([Format.HIGHLIGHT], offset);
isSkip && this.skipCursorRange();
this.curCtx && this.nextCursor();
if (!this.offset) {
if (toBeResolved) { this.queue.resolve(NonHighlightFormats, offset) }
if (includesHl) { this.queue.resolve([Format.HIGHLIGHT], offset) }
}
if (isSkip) { this.skipCursorRange() }
if (this.curCtx) { this.nextCursor() }
}
}