@codemirror/language 6.10.1 → 6.10.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## 6.10.3 (2024-09-19)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a TypeScript error when using `HighlightStyle` with the `exactOptionalPropertyTypes` typechecking option enabled.
6
+
7
+ Make `delimitedIndent` align to spaces after the opening token.
8
+
9
+ ## 6.10.2 (2024-06-03)
10
+
11
+ ### Bug fixes
12
+
13
+ Fix an infinite loop that could occur when enabling `bidiIsolates` in documents with both bidirectional text and very long lines.
14
+
1
15
  ## 6.10.1 (2024-02-02)
2
16
 
3
17
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1121,8 +1121,12 @@ function bracketedAligned(context) {
1121
1121
  let next = tree.childAfter(pos);
1122
1122
  if (!next || next == last)
1123
1123
  return null;
1124
- if (!next.type.isSkipped)
1125
- return next.from < lineEnd ? openToken : null;
1124
+ if (!next.type.isSkipped) {
1125
+ if (next.from >= lineEnd)
1126
+ return null;
1127
+ let space = /^ */.exec(openLine.text.slice(openToken.to - openLine.from))[0].length;
1128
+ return { from: openToken.from, to: openToken.to + space };
1129
+ }
1126
1130
  pos = next.to;
1127
1131
  }
1128
1132
  }
@@ -2619,9 +2623,13 @@ function buildDeco(view, tree, always) {
2619
2623
  function clipRTLLines(ranges, doc) {
2620
2624
  let cur = doc.iter(), pos = 0, result = [], last = null;
2621
2625
  for (let { from, to } of ranges) {
2622
- if (from != pos) {
2623
- if (pos < from)
2624
- cur.next(from - pos);
2626
+ if (last && last.to > from) {
2627
+ from = last.to;
2628
+ if (from >= to)
2629
+ continue;
2630
+ }
2631
+ if (pos + cur.value.length < from) {
2632
+ cur.next(from - (pos + cur.value.length));
2625
2633
  pos = from;
2626
2634
  }
2627
2635
  for (;;) {
@@ -2632,7 +2640,7 @@ function clipRTLLines(ranges, doc) {
2632
2640
  else
2633
2641
  result.push(last = { from: start, to: Math.min(to, end) });
2634
2642
  }
2635
- if (pos >= to)
2643
+ if (end >= to)
2636
2644
  break;
2637
2645
  pos = end;
2638
2646
  cur.next();
package/dist/index.d.cts CHANGED
@@ -845,7 +845,7 @@ declare class HighlightStyle implements Highlighter {
845
845
  */
846
846
  readonly module: StyleModule | null;
847
847
  readonly style: (tags: readonly Tag[]) => string | null;
848
- readonly scope: ((type: NodeType) => boolean) | undefined;
848
+ readonly scope?: (type: NodeType) => boolean;
849
849
  private constructor();
850
850
  /**
851
851
  Create a highlighter style that associates the given styles to
package/dist/index.d.ts CHANGED
@@ -845,7 +845,7 @@ declare class HighlightStyle implements Highlighter {
845
845
  */
846
846
  readonly module: StyleModule | null;
847
847
  readonly style: (tags: readonly Tag[]) => string | null;
848
- readonly scope: ((type: NodeType) => boolean) | undefined;
848
+ readonly scope?: (type: NodeType) => boolean;
849
849
  private constructor();
850
850
  /**
851
851
  Create a highlighter style that associates the given styles to
package/dist/index.js CHANGED
@@ -1119,8 +1119,12 @@ function bracketedAligned(context) {
1119
1119
  let next = tree.childAfter(pos);
1120
1120
  if (!next || next == last)
1121
1121
  return null;
1122
- if (!next.type.isSkipped)
1123
- return next.from < lineEnd ? openToken : null;
1122
+ if (!next.type.isSkipped) {
1123
+ if (next.from >= lineEnd)
1124
+ return null;
1125
+ let space = /^ */.exec(openLine.text.slice(openToken.to - openLine.from))[0].length;
1126
+ return { from: openToken.from, to: openToken.to + space };
1127
+ }
1124
1128
  pos = next.to;
1125
1129
  }
1126
1130
  }
@@ -2617,9 +2621,13 @@ function buildDeco(view, tree, always) {
2617
2621
  function clipRTLLines(ranges, doc) {
2618
2622
  let cur = doc.iter(), pos = 0, result = [], last = null;
2619
2623
  for (let { from, to } of ranges) {
2620
- if (from != pos) {
2621
- if (pos < from)
2622
- cur.next(from - pos);
2624
+ if (last && last.to > from) {
2625
+ from = last.to;
2626
+ if (from >= to)
2627
+ continue;
2628
+ }
2629
+ if (pos + cur.value.length < from) {
2630
+ cur.next(from - (pos + cur.value.length));
2623
2631
  pos = from;
2624
2632
  }
2625
2633
  for (;;) {
@@ -2630,7 +2638,7 @@ function clipRTLLines(ranges, doc) {
2630
2638
  else
2631
2639
  result.push(last = { from: start, to: Math.min(to, end) });
2632
2640
  }
2633
- if (pos >= to)
2641
+ if (end >= to)
2634
2642
  break;
2635
2643
  pos = end;
2636
2644
  cur.next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/language",
3
- "version": "6.10.1",
3
+ "version": "6.10.3",
4
4
  "description": "Language support infrastructure for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",