diff --git a/src/editor-mode/decorator/builder/ExtendedSyntax.ts b/src/editor-mode/decorator/builder/ExtendedSyntax.ts index ff8fccd..1532b27 100644 --- a/src/editor-mode/decorator/builder/ExtendedSyntax.ts +++ b/src/editor-mode/decorator/builder/ExtendedSyntax.ts @@ -53,17 +53,17 @@ export class ExtendedSyntax implements PluginValue { this.combine(); } update(update: ViewUpdate) { - if (update.docChanged) { + if (update.docChanged || this.parser.isReparsing) { let { mainDecoRanges, outerDecoRanges, delimiterRanges } = this.builder.build(update.state); this.mainDecoSet = this.builder.updateSet(update, this.mainDecoSet, mainDecoRanges); this.outerDecoSet = this.builder.updateSet(update, this.outerDecoSet, outerDecoRanges); this.delimiterSet = this.builder.updateSet(update, this.delimiterSet, delimiterRanges); } - if (update.docChanged || update.selectionSet) { + if (update.docChanged || update.selectionSet || this.parser.isReparsing) { this.supplementalSet = this.builder.getSupplemental(update.state, this.outerDecoSet); } if (update.state.field(editorLivePreviewField)) { - if (update.docChanged || update.selectionSet || this.noOmit) { + if (update.docChanged || update.selectionSet || this.parser.isReparsing || this.noOmit) { this.omittedSet = this.omitter.omit(update.state, this.delimiterSet); } this.noOmit = false; @@ -72,6 +72,7 @@ export class ExtendedSyntax implements PluginValue { this.noOmit = true; } this.combine(); + this.parser.isReparsing = false; } combine() { this.combinedSet = RangeSet.join([ diff --git a/src/editor-mode/parser/Parser.ts b/src/editor-mode/parser/Parser.ts index cad7d76..a7474b0 100644 --- a/src/editor-mode/parser/Parser.ts +++ b/src/editor-mode/parser/Parser.ts @@ -13,6 +13,7 @@ export class Parser { private state: ParserState; private queue: TokenQueue = new TokenQueue(); private reusedTokens: TokenGroup | undefined; + isReparsing: boolean; tokens: TokenGroup = []; lastParsed = { startToken: 0, endToken: 0 }; settings: PluginSettings; @@ -77,6 +78,7 @@ export class Parser { this.lastParsed.endToken = this.tokens.length; } applyChange(doc: Text, tree: Tree, oldTree: Tree, changes: ChangeSet) { + this.isReparsing = true; let changedRange = composeChanges(changes), offset = Math.min(oldTree.length, tree.length) + 1; if (changedRange) {