fix: fix decorator issue when facing big text

This commit is contained in:
kotaindah55 2025-02-06 21:34:33 +02:00
parent 1de32ca303
commit 58745b2835
2 changed files with 6 additions and 3 deletions

View file

@ -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([

View file

@ -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) {