@adecore/editor 0.71.0 → 0.71.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/dist/tokens.js CHANGED
@@ -109,6 +109,12 @@ export class TokenCache {
109
109
  const old = this.entries[lastOld];
110
110
  this.pivotLine = old ? lastNew : -1;
111
111
  this.pivotState = old?.state;
112
+ if (delta === 0 && this.entries.length > lastNew) {
113
+ // The same lines, which is every key typed inside one: cleared in place, since a copy of a long file per key adds up.
114
+ this.entries.fill(undefined, firstLine, lastNew + 1);
115
+ this.reusableFrom = lastNew + 1;
116
+ return;
117
+ }
112
118
  // Not a spread into splice: a paste of a few hundred thousand lines would overflow the call stack.
113
119
  this.entries = this.entries.slice(0, firstLine).concat(new Array(lastNew - firstLine + 1).fill(undefined), this.entries.slice(lastOld + 1));
114
120
  this.reusableFrom = lastNew + 1;
package/dist/view.js CHANGED
@@ -1944,7 +1944,7 @@ export class EditorView {
1944
1944
  ? { x: 0, y: row.top, width: Math.max(this.layout.width, this.viewportWidth), height: row.height }
1945
1945
  : null;
1946
1946
  for (const kind of ['text', 'read', 'write']) {
1947
- const group = this.occurrences.filter((mark) => (mark.kind ?? 'text') === kind);
1947
+ const group = this.occurrences.filter((mark) => (mark.kind ?? 'text') === kind && mark.to >= shownFrom && mark.from <= shownTo);
1948
1948
  if (group.length > 0) {
1949
1949
  marks.push({
1950
1950
  className: kind === 'write' ? 'se-occurrence se-occurrence-write' : 'se-occurrence',
@@ -1972,7 +1972,8 @@ export class EditorView {
1972
1972
  const faded = [];
1973
1973
  const struck = [];
1974
1974
  for (const marker of this.markers) {
1975
- if (marker.to <= marker.from) {
1975
+ // A file can hold thousands of markers, and every frame of a scroll paints only the rows in sight.
1976
+ if (marker.to <= marker.from || marker.to < shownFrom || marker.from > shownTo) {
1976
1977
  continue;
1977
1978
  }
1978
1979
  const rects = this.paintRectangles(marker.from, marker.to, rows);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/editor",
3
- "version": "0.71.0",
3
+ "version": "0.71.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -54,8 +54,8 @@
54
54
  "test": "bun test --conditions=source"
55
55
  },
56
56
  "dependencies": {
57
- "@adecore/editor-core": "0.71.0",
58
- "@adecore/utils": "0.71.0",
57
+ "@adecore/editor-core": "0.71.2",
58
+ "@adecore/utils": "0.71.2",
59
59
  "linkedom": "^0.18.15",
60
60
  "shiki": "^4.6.0"
61
61
  },
package/src/tokens.ts CHANGED
@@ -146,6 +146,14 @@ export class TokenCache {
146
146
  const old = this.entries[lastOld];
147
147
  this.pivotLine = old ? lastNew : -1;
148
148
  this.pivotState = old?.state;
149
+ if (delta === 0 && this.entries.length > lastNew) {
150
+ // The same lines, which is every key typed inside one: cleared in place, since a copy of a long file per key adds up.
151
+ this.entries.fill(undefined, firstLine, lastNew + 1);
152
+ this.reusableFrom = lastNew + 1;
153
+
154
+ return;
155
+ }
156
+
149
157
  // Not a spread into splice: a paste of a few hundred thousand lines would overflow the call stack.
150
158
  this.entries = this.entries.slice(0, firstLine).concat(new Array<undefined>(lastNew - firstLine + 1).fill(undefined), this.entries.slice(lastOld + 1));
151
159
  this.reusableFrom = lastNew + 1;
package/src/view.ts CHANGED
@@ -2587,7 +2587,7 @@ export class EditorView {
2587
2587
  : null;
2588
2588
 
2589
2589
  for (const kind of ['text', 'read', 'write'] as const) {
2590
- const group = this.occurrences.filter((mark) => (mark.kind ?? 'text') === kind);
2590
+ const group = this.occurrences.filter((mark) => (mark.kind ?? 'text') === kind && mark.to >= shownFrom && mark.from <= shownTo);
2591
2591
 
2592
2592
  if (group.length > 0) {
2593
2593
  marks.push({
@@ -2624,7 +2624,8 @@ export class EditorView {
2624
2624
  const struck: LayoutRect[] = [];
2625
2625
 
2626
2626
  for (const marker of this.markers) {
2627
- if (marker.to <= marker.from) {
2627
+ // A file can hold thousands of markers, and every frame of a scroll paints only the rows in sight.
2628
+ if (marker.to <= marker.from || marker.to < shownFrom || marker.from > shownTo) {
2628
2629
  continue;
2629
2630
  }
2630
2631