@codemirror/language 6.10.1 → 6.10.2

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.10.2 (2024-06-03)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an infinite loop that could occur when enabling `bidiIsolates` in documents with both bidirectional text and very long lines.
6
+
1
7
  ## 6.10.1 (2024-02-02)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -2619,9 +2619,13 @@ function buildDeco(view, tree, always) {
2619
2619
  function clipRTLLines(ranges, doc) {
2620
2620
  let cur = doc.iter(), pos = 0, result = [], last = null;
2621
2621
  for (let { from, to } of ranges) {
2622
- if (from != pos) {
2623
- if (pos < from)
2624
- cur.next(from - pos);
2622
+ if (last && last.to > from) {
2623
+ from = last.to;
2624
+ if (from >= to)
2625
+ continue;
2626
+ }
2627
+ if (pos + cur.value.length < from) {
2628
+ cur.next(from - (pos + cur.value.length));
2625
2629
  pos = from;
2626
2630
  }
2627
2631
  for (;;) {
@@ -2632,7 +2636,7 @@ function clipRTLLines(ranges, doc) {
2632
2636
  else
2633
2637
  result.push(last = { from: start, to: Math.min(to, end) });
2634
2638
  }
2635
- if (pos >= to)
2639
+ if (end >= to)
2636
2640
  break;
2637
2641
  pos = end;
2638
2642
  cur.next();
package/dist/index.js CHANGED
@@ -2617,9 +2617,13 @@ function buildDeco(view, tree, always) {
2617
2617
  function clipRTLLines(ranges, doc) {
2618
2618
  let cur = doc.iter(), pos = 0, result = [], last = null;
2619
2619
  for (let { from, to } of ranges) {
2620
- if (from != pos) {
2621
- if (pos < from)
2622
- cur.next(from - pos);
2620
+ if (last && last.to > from) {
2621
+ from = last.to;
2622
+ if (from >= to)
2623
+ continue;
2624
+ }
2625
+ if (pos + cur.value.length < from) {
2626
+ cur.next(from - (pos + cur.value.length));
2623
2627
  pos = from;
2624
2628
  }
2625
2629
  for (;;) {
@@ -2630,7 +2634,7 @@ function clipRTLLines(ranges, doc) {
2630
2634
  else
2631
2635
  result.push(last = { from: start, to: Math.min(to, end) });
2632
2636
  }
2633
- if (pos >= to)
2637
+ if (end >= to)
2634
2638
  break;
2635
2639
  pos = end;
2636
2640
  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.2",
4
4
  "description": "Language support infrastructure for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",