@codemirror/language 6.12.2 → 6.12.4
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/README.md +2 -2
- package/dist/index.cjs +15 -7
- package/dist/index.d.cts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +15 -7
- package/package.json +2 -2
- package/.github/workflows/dispatch.yml +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.12.4 (2026-06-25)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Make adding a lot of folded ranges in one transaction linear rather than quadratic in range-set-building complexity.
|
|
6
|
+
|
|
7
|
+
## 6.12.3 (2026-03-25)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix a crash in `bracketMatching` when composing at end of document.
|
|
12
|
+
|
|
1
13
|
## 6.12.2 (2026-02-25)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @codemirror/language [](https://www.npmjs.org/package/@codemirror/language)
|
|
2
2
|
|
|
3
|
-
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#language) | [**ISSUES**](https://
|
|
3
|
+
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#language) | [**ISSUES**](https://code.haverbeke.berlin/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/) | [**CHANGELOG**](https://code.haverbeke.berlin/codemirror/language/src/branch/main/CHANGELOG.md) ]
|
|
4
4
|
|
|
5
5
|
This package implements the language support infrastructure for the
|
|
6
6
|
[CodeMirror](https://codemirror.net/) code editor.
|
|
@@ -10,7 +10,7 @@ number of [examples](https://codemirror.net/examples/) and the
|
|
|
10
10
|
[documentation](https://codemirror.net/docs/).
|
|
11
11
|
|
|
12
12
|
This code is released under an
|
|
13
|
-
[MIT license](https://
|
|
13
|
+
[MIT license](https://code.haverbeke.berlin/codemirror/language/tree/main/LICENSE).
|
|
14
14
|
|
|
15
15
|
We aim to be an inclusive, welcoming community. To make that explicit,
|
|
16
16
|
we have a [code of
|
package/dist/index.cjs
CHANGED
|
@@ -154,8 +154,7 @@ function topNodeAt(state, pos, side) {
|
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
|
|
157
|
-
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
|
|
158
|
-
parsers.
|
|
157
|
+
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser).
|
|
159
158
|
*/
|
|
160
159
|
class LRLanguage extends Language {
|
|
161
160
|
constructor(data, parser, name) {
|
|
@@ -1321,18 +1320,25 @@ const foldState = state.StateField.define({
|
|
|
1321
1320
|
if (tr.isUserEvent("delete"))
|
|
1322
1321
|
tr.changes.iterChangedRanges((fromA, toA) => folded = clearTouchedFolds(folded, fromA, toA));
|
|
1323
1322
|
folded = folded.map(tr.changes);
|
|
1323
|
+
let rangesToFold = [];
|
|
1324
1324
|
for (let e of tr.effects) {
|
|
1325
1325
|
if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {
|
|
1326
|
-
|
|
1327
|
-
let widget = !preparePlaceholder ? foldWidget :
|
|
1328
|
-
view.Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, e.value)) });
|
|
1329
|
-
folded = folded.update({ add: [widget.range(e.value.from, e.value.to)] });
|
|
1326
|
+
rangesToFold.push(e.value);
|
|
1330
1327
|
}
|
|
1331
1328
|
else if (e.is(unfoldEffect)) {
|
|
1332
1329
|
folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,
|
|
1333
1330
|
filterFrom: e.value.from, filterTo: e.value.to });
|
|
1334
1331
|
}
|
|
1335
1332
|
}
|
|
1333
|
+
if (rangesToFold.length) {
|
|
1334
|
+
let { preparePlaceholder } = tr.state.facet(foldConfig);
|
|
1335
|
+
let decorations = rangesToFold.map(value => {
|
|
1336
|
+
let widget = !preparePlaceholder ? foldWidget :
|
|
1337
|
+
view.Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, value)) });
|
|
1338
|
+
return widget.range(value.from, value.to);
|
|
1339
|
+
});
|
|
1340
|
+
folded = folded.update({ add: decorations });
|
|
1341
|
+
}
|
|
1336
1342
|
// Clear folded ranges that cover the selection head
|
|
1337
1343
|
if (tr.selection)
|
|
1338
1344
|
folded = clearTouchedFolds(folded, tr.selection.main.head);
|
|
@@ -1692,7 +1698,7 @@ class HighlightStyle {
|
|
|
1692
1698
|
or array of tags in their `tag` property, and either a single
|
|
1693
1699
|
`class` property providing a static CSS class (for highlighter
|
|
1694
1700
|
that rely on external styling), or a
|
|
1695
|
-
[`style-mod`](https://
|
|
1701
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)-style
|
|
1696
1702
|
set of CSS properties (which define the styling for those tags).
|
|
1697
1703
|
|
|
1698
1704
|
The CSS rules created for a highlighter will be emitted in the
|
|
@@ -1983,6 +1989,8 @@ function matchMarkedBrackets(_state, _pos, dir, token, handle, matching, bracket
|
|
|
1983
1989
|
return { start: firstToken, matched: false };
|
|
1984
1990
|
}
|
|
1985
1991
|
function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
|
|
1992
|
+
if (dir < 0 ? !pos : pos == state.doc.length)
|
|
1993
|
+
return null;
|
|
1986
1994
|
let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
|
|
1987
1995
|
let bracket = brackets.indexOf(startCh);
|
|
1988
1996
|
if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
|
package/dist/index.d.cts
CHANGED
|
@@ -138,8 +138,7 @@ declare class Language {
|
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
|
|
141
|
-
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
|
|
142
|
-
parsers.
|
|
141
|
+
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser).
|
|
143
142
|
*/
|
|
144
143
|
declare class LRLanguage extends Language {
|
|
145
144
|
readonly parser: LRParser;
|
|
@@ -853,7 +852,7 @@ declare class HighlightStyle implements Highlighter {
|
|
|
853
852
|
or array of tags in their `tag` property, and either a single
|
|
854
853
|
`class` property providing a static CSS class (for highlighter
|
|
855
854
|
that rely on external styling), or a
|
|
856
|
-
[`style-mod`](https://
|
|
855
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)-style
|
|
857
856
|
set of CSS properties (which define the styling for those tags).
|
|
858
857
|
|
|
859
858
|
The CSS rules created for a highlighter will be emitted in the
|
|
@@ -924,7 +923,7 @@ interface TagStyle {
|
|
|
924
923
|
/**
|
|
925
924
|
Any further properties (if `class` isn't given) will be
|
|
926
925
|
interpreted as in style objects given to
|
|
927
|
-
[style-mod](https://
|
|
926
|
+
[style-mod](https://code.haverbeke.berlin/marijn/style-mod#documentation).
|
|
928
927
|
(The type here is `any` because of TypeScript limitations.)
|
|
929
928
|
*/
|
|
930
929
|
[styleProperty: string]: any;
|
package/dist/index.d.ts
CHANGED
|
@@ -138,8 +138,7 @@ declare class Language {
|
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
|
|
141
|
-
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
|
|
142
|
-
parsers.
|
|
141
|
+
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser).
|
|
143
142
|
*/
|
|
144
143
|
declare class LRLanguage extends Language {
|
|
145
144
|
readonly parser: LRParser;
|
|
@@ -853,7 +852,7 @@ declare class HighlightStyle implements Highlighter {
|
|
|
853
852
|
or array of tags in their `tag` property, and either a single
|
|
854
853
|
`class` property providing a static CSS class (for highlighter
|
|
855
854
|
that rely on external styling), or a
|
|
856
|
-
[`style-mod`](https://
|
|
855
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)-style
|
|
857
856
|
set of CSS properties (which define the styling for those tags).
|
|
858
857
|
|
|
859
858
|
The CSS rules created for a highlighter will be emitted in the
|
|
@@ -924,7 +923,7 @@ interface TagStyle {
|
|
|
924
923
|
/**
|
|
925
924
|
Any further properties (if `class` isn't given) will be
|
|
926
925
|
interpreted as in style objects given to
|
|
927
|
-
[style-mod](https://
|
|
926
|
+
[style-mod](https://code.haverbeke.berlin/marijn/style-mod#documentation).
|
|
928
927
|
(The type here is `any` because of TypeScript limitations.)
|
|
929
928
|
*/
|
|
930
929
|
[styleProperty: string]: any;
|
package/dist/index.js
CHANGED
|
@@ -152,8 +152,7 @@ function topNodeAt(state, pos, side) {
|
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
|
|
155
|
-
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
|
|
156
|
-
parsers.
|
|
155
|
+
[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser).
|
|
157
156
|
*/
|
|
158
157
|
class LRLanguage extends Language {
|
|
159
158
|
constructor(data, parser, name) {
|
|
@@ -1319,18 +1318,25 @@ const foldState = /*@__PURE__*/StateField.define({
|
|
|
1319
1318
|
if (tr.isUserEvent("delete"))
|
|
1320
1319
|
tr.changes.iterChangedRanges((fromA, toA) => folded = clearTouchedFolds(folded, fromA, toA));
|
|
1321
1320
|
folded = folded.map(tr.changes);
|
|
1321
|
+
let rangesToFold = [];
|
|
1322
1322
|
for (let e of tr.effects) {
|
|
1323
1323
|
if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {
|
|
1324
|
-
|
|
1325
|
-
let widget = !preparePlaceholder ? foldWidget :
|
|
1326
|
-
Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, e.value)) });
|
|
1327
|
-
folded = folded.update({ add: [widget.range(e.value.from, e.value.to)] });
|
|
1324
|
+
rangesToFold.push(e.value);
|
|
1328
1325
|
}
|
|
1329
1326
|
else if (e.is(unfoldEffect)) {
|
|
1330
1327
|
folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,
|
|
1331
1328
|
filterFrom: e.value.from, filterTo: e.value.to });
|
|
1332
1329
|
}
|
|
1333
1330
|
}
|
|
1331
|
+
if (rangesToFold.length) {
|
|
1332
|
+
let { preparePlaceholder } = tr.state.facet(foldConfig);
|
|
1333
|
+
let decorations = rangesToFold.map(value => {
|
|
1334
|
+
let widget = !preparePlaceholder ? foldWidget :
|
|
1335
|
+
Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, value)) });
|
|
1336
|
+
return widget.range(value.from, value.to);
|
|
1337
|
+
});
|
|
1338
|
+
folded = folded.update({ add: decorations });
|
|
1339
|
+
}
|
|
1334
1340
|
// Clear folded ranges that cover the selection head
|
|
1335
1341
|
if (tr.selection)
|
|
1336
1342
|
folded = clearTouchedFolds(folded, tr.selection.main.head);
|
|
@@ -1690,7 +1696,7 @@ class HighlightStyle {
|
|
|
1690
1696
|
or array of tags in their `tag` property, and either a single
|
|
1691
1697
|
`class` property providing a static CSS class (for highlighter
|
|
1692
1698
|
that rely on external styling), or a
|
|
1693
|
-
[`style-mod`](https://
|
|
1699
|
+
[`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)-style
|
|
1694
1700
|
set of CSS properties (which define the styling for those tags).
|
|
1695
1701
|
|
|
1696
1702
|
The CSS rules created for a highlighter will be emitted in the
|
|
@@ -1981,6 +1987,8 @@ function matchMarkedBrackets(_state, _pos, dir, token, handle, matching, bracket
|
|
|
1981
1987
|
return { start: firstToken, matched: false };
|
|
1982
1988
|
}
|
|
1983
1989
|
function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
|
|
1990
|
+
if (dir < 0 ? !pos : pos == state.doc.length)
|
|
1991
|
+
return null;
|
|
1984
1992
|
let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
|
|
1985
1993
|
let bracket = brackets.indexOf(startCh);
|
|
1986
1994
|
if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemirror/language",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.4",
|
|
4
4
|
"description": "Language support infrastructure for the CodeMirror code editor",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "cm-runtests",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
42
|
-
"url": "git+https://
|
|
42
|
+
"url": "git+https://code.haverbeke.berlin/codemirror/language.git"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
name: Trigger CI
|
|
2
|
-
on: push
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
build:
|
|
6
|
-
name: Dispatch to main repo
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- name: Emit repository_dispatch
|
|
10
|
-
uses: mvasigh/dispatch-action@main
|
|
11
|
-
with:
|
|
12
|
-
# You should create a personal access token and store it in your repository
|
|
13
|
-
token: ${{ secrets.DISPATCH_AUTH }}
|
|
14
|
-
repo: dev
|
|
15
|
-
owner: codemirror
|
|
16
|
-
event_type: push
|