дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
ParseContext.changes() in @codemirror/language handed the parent context's skipped array to the child whenever there was nothing to remap, so a speculative state.update() (paste reindent, Shift+Enter, Move Line, Complete Statement) let StreamLanguage's skipUntilInView push a range past the live document's end into the live state's array. Applying the real transaction then threw RangeError in ChangeSet.mapPos and broke the editor for .properties and other StreamLanguage files longer than the viewport. The patch gives every child context its own skipped array. Closes #7989 Co-authored-by: wildcatDownstairs <[email protected]>
61 рядки
2.8 KiB
Diff
61 рядки
2.8 KiB
Diff
diff --git a/dist/index.cjs b/dist/index.cjs
|
|
index db9d5491d5d5ffba46c85d822f0bc75d15ecebc4..8d3637e4dd4d12053e08e6b27ee70b52f6d48093 100644
|
|
--- a/dist/index.cjs
|
|
+++ b/dist/index.cjs
|
|
@@ -422,12 +422,15 @@ class ParseContext {
|
|
treeLen = 0;
|
|
viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
|
|
+ skipped = [];
|
|
if (this.skipped.length) {
|
|
- skipped = [];
|
|
for (let r of this.skipped) {
|
|
let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
|
|
if (from < to)
|
|
skipped.push({ from, to });
|
|
}
|
|
}
|
|
+ }
|
|
+ else {
|
|
+ skipped = skipped.slice();
|
|
}
|
|
return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
|
|
@@ -1891,7 +1894,7 @@ const bracketMatcher = view.ViewPlugin.fromClass(class {
|
|
this.decorations = bracketDeco(view.state);
|
|
}
|
|
update(update) {
|
|
- if (update.docChanged || update.selectionSet || this.paused) {
|
|
+ if (update.docChanged || update.selectionSet || this.paused || syntaxTree(update.state) != syntaxTree(update.startState)) {
|
|
if (update.view.composing) {
|
|
this.decorations = this.decorations.map(update.changes);
|
|
this.paused = true;
|
|
diff --git a/dist/index.js b/dist/index.js
|
|
index 32c1054f848d845ab8b9a71ff406bb59cca2ceb3..8cf64f5cd7298ba67fe01d9c19d262651d73cd0a 100644
|
|
--- a/dist/index.js
|
|
+++ b/dist/index.js
|
|
@@ -421,12 +421,15 @@ class ParseContext {
|
|
treeLen = 0;
|
|
viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
|
|
+ skipped = [];
|
|
if (this.skipped.length) {
|
|
- skipped = [];
|
|
for (let r of this.skipped) {
|
|
let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
|
|
if (from < to)
|
|
skipped.push({ from, to });
|
|
}
|
|
}
|
|
+ }
|
|
+ else {
|
|
+ skipped = skipped.slice();
|
|
}
|
|
return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
|
|
@@ -1890,7 +1893,7 @@ const bracketMatcher = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
this.decorations = bracketDeco(view.state);
|
|
}
|
|
update(update) {
|
|
- if (update.docChanged || update.selectionSet || this.paused) {
|
|
+ if (update.docChanged || update.selectionSet || this.paused || syntaxTree(update.state) != syntaxTree(update.startState)) {
|
|
if (update.view.composing) {
|
|
this.decorations = this.decorations.map(update.changes);
|
|
this.paused = true;
|