@codemirror/language 6.11.1 → 6.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +16 -13
- package/dist/index.js +16 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.11.3 (2025-08-15)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Make the stream parser user 4 times smaller chunks to reduce the amount of re-parsed code on changes.
|
|
6
|
+
|
|
7
|
+
## 6.11.2 (2025-06-27)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Make sure folded ranges open when backspacing or deleting into them.
|
|
12
|
+
|
|
1
13
|
## 6.11.1 (2025-06-02)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -1318,6 +1318,8 @@ const foldState = state.StateField.define({
|
|
|
1318
1318
|
return view.Decoration.none;
|
|
1319
1319
|
},
|
|
1320
1320
|
update(folded, tr) {
|
|
1321
|
+
if (tr.isUserEvent("delete"))
|
|
1322
|
+
tr.changes.iterChangedRanges((fromA, toA) => folded = clearTouchedFolds(folded, fromA, toA));
|
|
1321
1323
|
folded = folded.map(tr.changes);
|
|
1322
1324
|
for (let e of tr.effects) {
|
|
1323
1325
|
if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {
|
|
@@ -1332,17 +1334,8 @@ const foldState = state.StateField.define({
|
|
|
1332
1334
|
}
|
|
1333
1335
|
}
|
|
1334
1336
|
// Clear folded ranges that cover the selection head
|
|
1335
|
-
if (tr.selection)
|
|
1336
|
-
|
|
1337
|
-
folded.between(head, head, (a, b) => { if (a < head && b > head)
|
|
1338
|
-
onSelection = true; });
|
|
1339
|
-
if (onSelection)
|
|
1340
|
-
folded = folded.update({
|
|
1341
|
-
filterFrom: head,
|
|
1342
|
-
filterTo: head,
|
|
1343
|
-
filter: (a, b) => b <= head || a >= head
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1337
|
+
if (tr.selection)
|
|
1338
|
+
folded = clearTouchedFolds(folded, tr.selection.main.head);
|
|
1346
1339
|
return folded;
|
|
1347
1340
|
},
|
|
1348
1341
|
provide: f => view.EditorView.decorations.from(f),
|
|
@@ -1364,6 +1357,16 @@ const foldState = state.StateField.define({
|
|
|
1364
1357
|
return view.Decoration.set(ranges, true);
|
|
1365
1358
|
}
|
|
1366
1359
|
});
|
|
1360
|
+
function clearTouchedFolds(folded, from, to = from) {
|
|
1361
|
+
let touched = false;
|
|
1362
|
+
folded.between(from, to, (a, b) => { if (a < to && b > from)
|
|
1363
|
+
touched = true; });
|
|
1364
|
+
return !touched ? folded : folded.update({
|
|
1365
|
+
filterFrom: from,
|
|
1366
|
+
filterTo: to,
|
|
1367
|
+
filter: (a, b) => a >= to || b <= from
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1367
1370
|
/**
|
|
1368
1371
|
Get a [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) containing the folded ranges
|
|
1369
1372
|
in the given state.
|
|
@@ -2337,7 +2340,7 @@ class Parse {
|
|
|
2337
2340
|
advance() {
|
|
2338
2341
|
let context = ParseContext.get();
|
|
2339
2342
|
let parseEnd = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt);
|
|
2340
|
-
let end = Math.min(parseEnd, this.chunkStart +
|
|
2343
|
+
let end = Math.min(parseEnd, this.chunkStart + 512 /* C.ChunkSize */);
|
|
2341
2344
|
if (context)
|
|
2342
2345
|
end = Math.min(end, context.viewport.to);
|
|
2343
2346
|
while (this.parsedPos < end)
|
|
@@ -2443,7 +2446,7 @@ class Parse {
|
|
|
2443
2446
|
length: this.parsedPos - this.chunkStart,
|
|
2444
2447
|
nodeSet,
|
|
2445
2448
|
topID: 0,
|
|
2446
|
-
maxBufferLength:
|
|
2449
|
+
maxBufferLength: 512 /* C.ChunkSize */,
|
|
2447
2450
|
reused: this.chunkReused
|
|
2448
2451
|
});
|
|
2449
2452
|
tree = new common.Tree(tree.type, tree.children, tree.positions, tree.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]);
|
package/dist/index.js
CHANGED
|
@@ -1316,6 +1316,8 @@ const foldState = /*@__PURE__*/StateField.define({
|
|
|
1316
1316
|
return Decoration.none;
|
|
1317
1317
|
},
|
|
1318
1318
|
update(folded, tr) {
|
|
1319
|
+
if (tr.isUserEvent("delete"))
|
|
1320
|
+
tr.changes.iterChangedRanges((fromA, toA) => folded = clearTouchedFolds(folded, fromA, toA));
|
|
1319
1321
|
folded = folded.map(tr.changes);
|
|
1320
1322
|
for (let e of tr.effects) {
|
|
1321
1323
|
if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {
|
|
@@ -1330,17 +1332,8 @@ const foldState = /*@__PURE__*/StateField.define({
|
|
|
1330
1332
|
}
|
|
1331
1333
|
}
|
|
1332
1334
|
// Clear folded ranges that cover the selection head
|
|
1333
|
-
if (tr.selection)
|
|
1334
|
-
|
|
1335
|
-
folded.between(head, head, (a, b) => { if (a < head && b > head)
|
|
1336
|
-
onSelection = true; });
|
|
1337
|
-
if (onSelection)
|
|
1338
|
-
folded = folded.update({
|
|
1339
|
-
filterFrom: head,
|
|
1340
|
-
filterTo: head,
|
|
1341
|
-
filter: (a, b) => b <= head || a >= head
|
|
1342
|
-
});
|
|
1343
|
-
}
|
|
1335
|
+
if (tr.selection)
|
|
1336
|
+
folded = clearTouchedFolds(folded, tr.selection.main.head);
|
|
1344
1337
|
return folded;
|
|
1345
1338
|
},
|
|
1346
1339
|
provide: f => EditorView.decorations.from(f),
|
|
@@ -1362,6 +1355,16 @@ const foldState = /*@__PURE__*/StateField.define({
|
|
|
1362
1355
|
return Decoration.set(ranges, true);
|
|
1363
1356
|
}
|
|
1364
1357
|
});
|
|
1358
|
+
function clearTouchedFolds(folded, from, to = from) {
|
|
1359
|
+
let touched = false;
|
|
1360
|
+
folded.between(from, to, (a, b) => { if (a < to && b > from)
|
|
1361
|
+
touched = true; });
|
|
1362
|
+
return !touched ? folded : folded.update({
|
|
1363
|
+
filterFrom: from,
|
|
1364
|
+
filterTo: to,
|
|
1365
|
+
filter: (a, b) => a >= to || b <= from
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1365
1368
|
/**
|
|
1366
1369
|
Get a [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) containing the folded ranges
|
|
1367
1370
|
in the given state.
|
|
@@ -2335,7 +2338,7 @@ class Parse {
|
|
|
2335
2338
|
advance() {
|
|
2336
2339
|
let context = ParseContext.get();
|
|
2337
2340
|
let parseEnd = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt);
|
|
2338
|
-
let end = Math.min(parseEnd, this.chunkStart +
|
|
2341
|
+
let end = Math.min(parseEnd, this.chunkStart + 512 /* C.ChunkSize */);
|
|
2339
2342
|
if (context)
|
|
2340
2343
|
end = Math.min(end, context.viewport.to);
|
|
2341
2344
|
while (this.parsedPos < end)
|
|
@@ -2441,7 +2444,7 @@ class Parse {
|
|
|
2441
2444
|
length: this.parsedPos - this.chunkStart,
|
|
2442
2445
|
nodeSet,
|
|
2443
2446
|
topID: 0,
|
|
2444
|
-
maxBufferLength:
|
|
2447
|
+
maxBufferLength: 512 /* C.ChunkSize */,
|
|
2445
2448
|
reused: this.chunkReused
|
|
2446
2449
|
});
|
|
2447
2450
|
tree = new Tree(tree.type, tree.children, tree.positions, tree.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]);
|