@codemirror/language 6.12.3 → 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 CHANGED
@@ -1,3 +1,9 @@
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
+
1
7
  ## 6.12.3 (2026-03-25)
2
8
 
3
9
  ### Bug fixes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @codemirror/language [![NPM version](https://img.shields.io/npm/v/@codemirror/language.svg)](https://www.npmjs.org/package/@codemirror/language)
2
2
 
3
- [ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#language) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/) | [**CHANGELOG**](https://github.com/codemirror/language/blob/main/CHANGELOG.md) ]
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://github.com/codemirror/language/tree/main/LICENSE).
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
- let { preparePlaceholder } = tr.state.facet(foldConfig);
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://github.com/marijnh/style-mod#documentation)-style
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
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://github.com/marijnh/style-mod#documentation)-style
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://github.com/marijnh/style-mod#documentation).
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://github.com/marijnh/style-mod#documentation)-style
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://github.com/marijnh/style-mod#documentation).
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
- let { preparePlaceholder } = tr.state.facet(foldConfig);
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://github.com/marijnh/style-mod#documentation)-style
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/language",
3
- "version": "6.12.3",
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://github.com/codemirror/language.git"
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