@codemirror/language 6.11.0 → 6.11.1

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.11.1 (2025-06-02)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue where indentation would sometimes miss nodes in mixed-language situations.
6
+
1
7
  ## 6.11.0 (2025-03-13)
2
8
 
3
9
  ### New features
package/dist/index.cjs CHANGED
@@ -803,8 +803,8 @@ service.
803
803
  const indentService = state.Facet.define();
804
804
  /**
805
805
  Facet for overriding the unit by which indentation happens. Should
806
- be a string consisting either entirely of the same whitespace
807
- character. When not set, this defaults to 2 spaces.
806
+ be a string consisting entirely of the same whitespace character.
807
+ When not set, this defaults to 2 spaces.
808
808
  */
809
809
  const indentUnit = state.Facet.define({
810
810
  combine: values => {
@@ -998,7 +998,8 @@ function syntaxIndentation(cx, ast, pos) {
998
998
  let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos);
999
999
  if (inner != stack.node) {
1000
1000
  let add = [];
1001
- for (let cur = inner; cur && !(cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
1001
+ for (let cur = inner; cur && !(cur.from < stack.node.from || cur.to > stack.node.to ||
1002
+ cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
1002
1003
  add.push(cur);
1003
1004
  for (let i = add.length - 1; i >= 0; i--)
1004
1005
  stack = { node: add[i], next: stack };
@@ -1579,7 +1580,7 @@ fold status indicator before foldable lines (which can be clicked
1579
1580
  to fold or unfold the line).
1580
1581
  */
1581
1582
  function foldGutter(config = {}) {
1582
- let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);
1583
+ let fullConfig = { ...foldGutterDefaults, ...config };
1583
1584
  let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);
1584
1585
  let markers = view.ViewPlugin.fromClass(class {
1585
1586
  constructor(view) {
@@ -1614,7 +1615,9 @@ function foldGutter(config = {}) {
1614
1615
  initialSpacer() {
1615
1616
  return new FoldMarker(fullConfig, false);
1616
1617
  },
1617
- domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {
1618
+ domEventHandlers: {
1619
+ ...domEventHandlers,
1620
+ click: (view, line, event) => {
1618
1621
  if (domEventHandlers.click && domEventHandlers.click(view, line, event))
1619
1622
  return true;
1620
1623
  let folded = findFold(view.state, line.from, line.to);
@@ -1628,7 +1631,8 @@ function foldGutter(config = {}) {
1628
1631
  return true;
1629
1632
  }
1630
1633
  return false;
1631
- } })
1634
+ }
1635
+ }
1632
1636
  }),
1633
1637
  codeFolding()
1634
1638
  ];
package/dist/index.d.cts CHANGED
@@ -429,8 +429,8 @@ service.
429
429
  declare const indentService: Facet<(context: IndentContext, pos: number) => number | null | undefined, readonly ((context: IndentContext, pos: number) => number | null | undefined)[]>;
430
430
  /**
431
431
  Facet for overriding the unit by which indentation happens. Should
432
- be a string consisting either entirely of the same whitespace
433
- character. When not set, this defaults to 2 spaces.
432
+ be a string consisting entirely of the same whitespace character.
433
+ When not set, this defaults to 2 spaces.
434
434
  */
435
435
  declare const indentUnit: Facet<string, string>;
436
436
  /**
package/dist/index.d.ts CHANGED
@@ -429,8 +429,8 @@ service.
429
429
  declare const indentService: Facet<(context: IndentContext, pos: number) => number | null | undefined, readonly ((context: IndentContext, pos: number) => number | null | undefined)[]>;
430
430
  /**
431
431
  Facet for overriding the unit by which indentation happens. Should
432
- be a string consisting either entirely of the same whitespace
433
- character. When not set, this defaults to 2 spaces.
432
+ be a string consisting entirely of the same whitespace character.
433
+ When not set, this defaults to 2 spaces.
434
434
  */
435
435
  declare const indentUnit: Facet<string, string>;
436
436
  /**
package/dist/index.js CHANGED
@@ -801,8 +801,8 @@ service.
801
801
  const indentService = /*@__PURE__*/Facet.define();
802
802
  /**
803
803
  Facet for overriding the unit by which indentation happens. Should
804
- be a string consisting either entirely of the same whitespace
805
- character. When not set, this defaults to 2 spaces.
804
+ be a string consisting entirely of the same whitespace character.
805
+ When not set, this defaults to 2 spaces.
806
806
  */
807
807
  const indentUnit = /*@__PURE__*/Facet.define({
808
808
  combine: values => {
@@ -996,7 +996,8 @@ function syntaxIndentation(cx, ast, pos) {
996
996
  let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos);
997
997
  if (inner != stack.node) {
998
998
  let add = [];
999
- for (let cur = inner; cur && !(cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
999
+ for (let cur = inner; cur && !(cur.from < stack.node.from || cur.to > stack.node.to ||
1000
+ cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
1000
1001
  add.push(cur);
1001
1002
  for (let i = add.length - 1; i >= 0; i--)
1002
1003
  stack = { node: add[i], next: stack };
@@ -1577,7 +1578,7 @@ fold status indicator before foldable lines (which can be clicked
1577
1578
  to fold or unfold the line).
1578
1579
  */
1579
1580
  function foldGutter(config = {}) {
1580
- let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);
1581
+ let fullConfig = { ...foldGutterDefaults, ...config };
1581
1582
  let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);
1582
1583
  let markers = ViewPlugin.fromClass(class {
1583
1584
  constructor(view) {
@@ -1612,7 +1613,9 @@ function foldGutter(config = {}) {
1612
1613
  initialSpacer() {
1613
1614
  return new FoldMarker(fullConfig, false);
1614
1615
  },
1615
- domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {
1616
+ domEventHandlers: {
1617
+ ...domEventHandlers,
1618
+ click: (view, line, event) => {
1616
1619
  if (domEventHandlers.click && domEventHandlers.click(view, line, event))
1617
1620
  return true;
1618
1621
  let folded = findFold(view.state, line.from, line.to);
@@ -1626,7 +1629,8 @@ function foldGutter(config = {}) {
1626
1629
  return true;
1627
1630
  }
1628
1631
  return false;
1629
- } })
1632
+ }
1633
+ }
1630
1634
  }),
1631
1635
  codeFolding()
1632
1636
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/language",
3
- "version": "6.11.0",
3
+ "version": "6.11.1",
4
4
  "description": "Language support infrastructure for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",