@pierre/diffs 1.3.0-beta.3 → 1.3.0-beta.5
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/README.md +6 -6
- package/dist/components/CodeView.js +6 -6
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +3 -2
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +35 -21
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +8 -4
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +66 -56
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.js +4 -2
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.js +1 -1
- package/dist/components/VirtualizedFile.d.ts +6 -2
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +89 -24
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +8 -2
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +91 -15
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/editor/command.d.ts +1 -1
- package/dist/editor/command.d.ts.map +1 -1
- package/dist/editor/command.js +3 -3
- package/dist/editor/command.js.map +1 -1
- package/dist/editor/editStack.d.ts +1 -1
- package/dist/editor/editor.d.ts +37 -9
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +558 -449
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +1 -1
- package/dist/editor/editor2.js.map +1 -1
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/lineAnnotations.d.ts +2 -1
- package/dist/editor/lineAnnotations.d.ts.map +1 -1
- package/dist/editor/lineAnnotations.js +111 -1
- package/dist/editor/lineAnnotations.js.map +1 -1
- package/dist/editor/marker.d.ts +33 -0
- package/dist/editor/marker.d.ts.map +1 -0
- package/dist/editor/marker.js +185 -0
- package/dist/editor/marker.js.map +1 -0
- package/dist/editor/pieceTable.d.ts +8 -3
- package/dist/editor/pieceTable.d.ts.map +1 -1
- package/dist/editor/pieceTable.js +74 -12
- package/dist/editor/pieceTable.js.map +1 -1
- package/dist/editor/searchPanel.d.ts +12 -3
- package/dist/editor/searchPanel.d.ts.map +1 -1
- package/dist/editor/searchPanel.js +168 -54
- package/dist/editor/searchPanel.js.map +1 -1
- package/dist/editor/selection.d.ts +19 -3
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/selection.js +188 -37
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/{quickEdit.d.ts → selectionAction.d.ts} +8 -8
- package/dist/editor/selectionAction.d.ts.map +1 -0
- package/dist/editor/{quickEdit.js → selectionAction.js} +18 -18
- package/dist/editor/selectionAction.js.map +1 -0
- package/dist/editor/sprite.d.ts +4 -3
- package/dist/editor/sprite.d.ts.map +1 -1
- package/dist/editor/sprite.js +19 -5
- package/dist/editor/sprite.js.map +1 -1
- package/dist/editor/textDocument.d.ts +4 -4
- package/dist/editor/textDocument.d.ts.map +1 -1
- package/dist/editor/textDocument.js +7 -7
- package/dist/editor/textDocument.js.map +1 -1
- package/dist/editor/textMeasure.d.ts +1 -0
- package/dist/editor/textMeasure.d.ts.map +1 -1
- package/dist/editor/textMeasure.js +6 -0
- package/dist/editor/textMeasure.js.map +1 -1
- package/dist/editor/tokenzier.js +20 -9
- package/dist/editor/tokenzier.js.map +1 -1
- package/dist/editor/utils.d.ts +3 -1
- package/dist/editor/utils.d.ts.map +1 -1
- package/dist/editor/utils.js +16 -1
- package/dist/editor/utils.js.map +1 -1
- package/dist/highlighter/shared_highlighter.js +3 -29
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/highlighter/themes/attachResolvedThemes.js +4 -3
- package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.js +3 -2
- package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/constants.d.ts +1 -7
- package/dist/highlighter/themes/constants.d.ts.map +1 -1
- package/dist/highlighter/themes/constants.js +1 -4
- package/dist/highlighter/themes/constants.js.map +1 -1
- package/dist/highlighter/themes/getResolvedOrResolveTheme.js +2 -2
- package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
- package/dist/highlighter/themes/getResolvedThemes.js +2 -8
- package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/hasResolvedThemes.js +2 -3
- package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +1 -1
- package/dist/highlighter/themes/registerCustomTheme.d.ts +5 -3
- package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomTheme.js +15 -5
- package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
- package/dist/highlighter/themes/resolveTheme.js +6 -27
- package/dist/highlighter/themes/resolveTheme.js.map +1 -1
- package/dist/highlighter/themes/resolveThemes.js +5 -12
- package/dist/highlighter/themes/resolveThemes.js.map +1 -1
- package/dist/highlighter/themes/themeResolution.d.ts +8 -0
- package/dist/highlighter/themes/themeResolution.d.ts.map +1 -0
- package/dist/highlighter/themes/themeResolution.js +22 -0
- package/dist/highlighter/themes/themeResolution.js.map +1 -0
- package/dist/highlighter/themes/themeResolver.d.ts +8 -0
- package/dist/highlighter/themes/themeResolver.d.ts.map +1 -0
- package/dist/highlighter/themes/themeResolver.js +8 -0
- package/dist/highlighter/themes/themeResolver.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/managers/InteractionManager.js +1 -1
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.js +1 -1
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/react/CodeView.js +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/utils/useFileDiffInstance.js +1 -0
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +6 -2
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +183 -12
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +2 -2
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +17 -5
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/FileDiffReact.js +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/types.d.ts +25 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/getHighlighterThemeStyles.js +16 -12
- package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
- package/dist/utils/includesFileAnnotations.d.ts +17 -0
- package/dist/utils/includesFileAnnotations.d.ts.map +1 -0
- package/dist/utils/includesFileAnnotations.js +19 -0
- package/dist/utils/includesFileAnnotations.js.map +1 -0
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.js +93 -4
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +4 -2
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +4 -2
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/updateDiffHunks.d.ts +13 -0
- package/dist/utils/updateDiffHunks.d.ts.map +1 -0
- package/dist/utils/updateDiffHunks.js +171 -0
- package/dist/utils/updateDiffHunks.js.map +1 -0
- package/dist/utils/virtualDiffLayout.d.ts +2 -1
- package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
- package/dist/utils/virtualDiffLayout.js +9 -1
- package/dist/utils/virtualDiffLayout.js.map +1 -1
- package/dist/worker/{wasm-BaDzIkIn.js → wasm-qE0LgnY3.js} +2 -2
- package/dist/worker/{wasm-BaDzIkIn.js.map → wasm-qE0LgnY3.js.map} +1 -1
- package/dist/worker/worker-portable.js +1016 -275
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +31 -19
- package/dist/worker/worker.js.map +1 -1
- package/package.json +5 -10
- package/dist/editor/quickEdit.d.ts.map +0 -1
- package/dist/editor/quickEdit.js.map +0 -1
|
@@ -59,6 +59,7 @@ var PieceTable = class {
|
|
|
59
59
|
#length = 0;
|
|
60
60
|
#lineCount = 0;
|
|
61
61
|
#lastVisitedLine = null;
|
|
62
|
+
#lastVisitedLineLength = null;
|
|
62
63
|
constructor(originalText) {
|
|
63
64
|
this.#original = new TextBuffer(originalText);
|
|
64
65
|
this.#setPieces([this.#createPiece(Piece.Original, 0, originalText.length)]);
|
|
@@ -72,14 +73,48 @@ var PieceTable = class {
|
|
|
72
73
|
const end = this.offsetAt(range.end);
|
|
73
74
|
return this.getTextSlice(start, end);
|
|
74
75
|
}
|
|
75
|
-
getLineText(line,
|
|
76
|
-
if (this.#lastVisitedLine !== null && this.#lastVisitedLine[0] === line) return this.#lastVisitedLine[
|
|
76
|
+
getLineText(line, includeLineBreak = false) {
|
|
77
|
+
if (this.#lastVisitedLine !== null && this.#lastVisitedLine[0] === line && this.#lastVisitedLine[1] === includeLineBreak) return this.#lastVisitedLine[2];
|
|
77
78
|
const offset = this.#getLineOffset(line);
|
|
78
79
|
if (offset === void 0) throw new Error(`Line index out of range: ${line}`);
|
|
79
|
-
const text = this.getTextSlice(offset[0], offset[1],
|
|
80
|
-
this.#lastVisitedLine = [
|
|
80
|
+
const text = this.getTextSlice(offset[0], offset[1], !includeLineBreak);
|
|
81
|
+
this.#lastVisitedLine = [
|
|
82
|
+
line,
|
|
83
|
+
includeLineBreak,
|
|
84
|
+
text
|
|
85
|
+
];
|
|
86
|
+
this.#lastVisitedLineLength = [
|
|
87
|
+
line,
|
|
88
|
+
includeLineBreak,
|
|
89
|
+
text.length
|
|
90
|
+
];
|
|
81
91
|
return text;
|
|
82
92
|
}
|
|
93
|
+
getLineLength(line, includeLineBreak = false) {
|
|
94
|
+
const lastVisitedLineLength = this.#lastVisitedLineLength;
|
|
95
|
+
const lastVisitedLine = this.#lastVisitedLine;
|
|
96
|
+
if (lastVisitedLineLength !== null && lastVisitedLineLength[0] === line && lastVisitedLineLength[1] === includeLineBreak) return lastVisitedLineLength[2];
|
|
97
|
+
if (lastVisitedLine !== null && lastVisitedLine[0] === line && lastVisitedLine[1] === includeLineBreak) {
|
|
98
|
+
const length$1 = lastVisitedLine[2].length;
|
|
99
|
+
this.#lastVisitedLineLength = [
|
|
100
|
+
line,
|
|
101
|
+
includeLineBreak,
|
|
102
|
+
length$1
|
|
103
|
+
];
|
|
104
|
+
return length$1;
|
|
105
|
+
}
|
|
106
|
+
const offset = this.#getLineOffset(line);
|
|
107
|
+
if (offset === void 0) throw new Error(`Line index out of range: ${line}`);
|
|
108
|
+
const [start, end] = offset;
|
|
109
|
+
let length = end - start;
|
|
110
|
+
if (!includeLineBreak) while (length > 0 && isEOL(this.charAt(start + length - 1).charCodeAt(0))) length--;
|
|
111
|
+
this.#lastVisitedLineLength = [
|
|
112
|
+
line,
|
|
113
|
+
includeLineBreak,
|
|
114
|
+
length
|
|
115
|
+
];
|
|
116
|
+
return length;
|
|
117
|
+
}
|
|
83
118
|
getTextSlice(start, end, trimEOF = false) {
|
|
84
119
|
if (start >= end) return "";
|
|
85
120
|
const sliceStart = clamp(start, 0, this.#length);
|
|
@@ -223,6 +258,7 @@ var PieceTable = class {
|
|
|
223
258
|
if (!inserted) nextPieces.push(insertedPiece);
|
|
224
259
|
this.#setPieces(nextPieces);
|
|
225
260
|
this.#lastVisitedLine = null;
|
|
261
|
+
this.#lastVisitedLineLength = null;
|
|
226
262
|
}
|
|
227
263
|
delete(offset, length) {
|
|
228
264
|
if (length <= 0 || this.#length === 0) return;
|
|
@@ -242,6 +278,7 @@ var PieceTable = class {
|
|
|
242
278
|
}
|
|
243
279
|
this.#setPieces(nextPieces);
|
|
244
280
|
this.#lastVisitedLine = null;
|
|
281
|
+
this.#lastVisitedLineLength = null;
|
|
245
282
|
}
|
|
246
283
|
applyEdits(edits) {
|
|
247
284
|
if (edits.length === 0) return;
|
|
@@ -285,6 +322,7 @@ var PieceTable = class {
|
|
|
285
322
|
appendRange(copyCursor, this.#length);
|
|
286
323
|
this.#setPieces(nextPieces);
|
|
287
324
|
this.#lastVisitedLine = null;
|
|
325
|
+
this.#lastVisitedLineLength = null;
|
|
288
326
|
}
|
|
289
327
|
positionAt(offset) {
|
|
290
328
|
const clampedOffset = clamp(offset, 0, this.#length);
|
|
@@ -316,13 +354,6 @@ var PieceTable = class {
|
|
|
316
354
|
const character = clamp(position.character, 0, offset[1] - offset[0]);
|
|
317
355
|
return offset[0] + character;
|
|
318
356
|
}
|
|
319
|
-
offsetsAt(positions) {
|
|
320
|
-
const offsets = Array.from({ length: positions.length });
|
|
321
|
-
if (positions.length === 0) return offsets;
|
|
322
|
-
if (this.#length === 0) return offsets.fill(0);
|
|
323
|
-
for (let i = 0; i < positions.length; i++) offsets[i] = this.offsetAt(positions[i]);
|
|
324
|
-
return offsets;
|
|
325
|
-
}
|
|
326
357
|
#findPieceAtOffset(offset) {
|
|
327
358
|
if (offset < 0 || offset >= this.#length) return;
|
|
328
359
|
let node = this.#root;
|
|
@@ -556,6 +587,37 @@ function compileSearchRegExp(source, isRegex, caseSensitive) {
|
|
|
556
587
|
const flags = `g${caseSensitive ? "" : "i"}${isRegex ? "m" : ""}`;
|
|
557
588
|
return new RegExp(body, flags);
|
|
558
589
|
}
|
|
590
|
+
/** Expands `$&`, `$1`, `$$`, etc. in a regex replace string using a match. */
|
|
591
|
+
function expandReplaceString(replacement, match) {
|
|
592
|
+
return replacement.replace(/\$([$&]|\d+)/g, (_token, group) => {
|
|
593
|
+
if (group === "$") return "$";
|
|
594
|
+
if (group === "&") return match[0] ?? "";
|
|
595
|
+
return match[Number(group)] ?? "";
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Builds the text to insert for one search match, including regex capture
|
|
600
|
+
* substitution when regex mode is enabled.
|
|
601
|
+
*/
|
|
602
|
+
function buildSearchReplacementText(positionAt, offsetAt, getLineText, searchParams, matchStart, matchEnd) {
|
|
603
|
+
if (!searchParams.regex) return searchParams.replaceText;
|
|
604
|
+
const position = positionAt(matchStart);
|
|
605
|
+
const lineText = getLineText(position.line);
|
|
606
|
+
const relStart = matchStart - offsetAt({
|
|
607
|
+
line: position.line,
|
|
608
|
+
character: 0
|
|
609
|
+
});
|
|
610
|
+
const matched = lineText.slice(relStart, relStart + (matchEnd - matchStart));
|
|
611
|
+
let pattern;
|
|
612
|
+
try {
|
|
613
|
+
pattern = compileSearchRegExp(searchParams.text, true, searchParams.caseSensitive);
|
|
614
|
+
} catch {
|
|
615
|
+
return searchParams.replaceText;
|
|
616
|
+
}
|
|
617
|
+
const match = new RegExp(pattern.source, pattern.flags.replace("g", "")).exec(matched);
|
|
618
|
+
if (match === null || match[0].length !== matched.length) return searchParams.replaceText;
|
|
619
|
+
return expandReplaceString(searchParams.replaceText, match);
|
|
620
|
+
}
|
|
559
621
|
function advancePastEmptyMatch(text, index) {
|
|
560
622
|
if (index + 1 < text.length) {
|
|
561
623
|
const first = text.charCodeAt(index);
|
|
@@ -566,5 +628,5 @@ function advancePastEmptyMatch(text, index) {
|
|
|
566
628
|
}
|
|
567
629
|
|
|
568
630
|
//#endregion
|
|
569
|
-
export { PieceTable };
|
|
631
|
+
export { PieceTable, buildSearchReplacementText };
|
|
570
632
|
//# sourceMappingURL=pieceTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pieceTable.js","names":["source: number","offset: number","length: number","lineOffsetStart: number","lineOffsetEnd: number","text: string","piece: Piece","subtreeLength: number","subtreeLineBreakCount: number","#original","#setPieces","#createPiece","#lineCount","#textFromPieces","#lastVisitedLine","#getLineOffset","#length","#findPieceAtOffset","chunks: string[]","#bufferFor","start","end","#nextNode","#forEachPieceSegment","wrappedOffset: number | undefined","foundOffset: number | undefined","pattern: RegExp","#collectSearchMatchesLineByLine","out: [number, number][]","match: RegExpExecArray | null","#add","#pieces","nextPieces: Piece[]","#lineAtOffset","#lineBreakOffset","positions: Position[]","offsets: number[]","#root","#walk","#piecesCache","#buildBalancedTree","normalized: [start: number, end: number][]","merged: [start: number, end: number][]","coalescedPieces: Piece[]"],"sources":["../../src/editor/pieceTable.ts"],"sourcesContent":["import { computeLineOffsets } from '../utils/computeFileOffsets';\nimport type { SearchParams } from './searchPanel';\nimport type { Position, Range, ResolvedTextEdit } from './textDocument';\n\nconst MAX_FIND_MATCHES = 100000;\n// TODO(ije): use Intl.Segmenter instead of regex for word separators\nconst WORD_SEPARATORS = '`~!@#$%^&*()-=+[{]}\\\\|;:\\'\",.<>/?' as const;\n\n// A piece is a segment of text that is either original or added.\nclass Piece {\n static Original = 0;\n static Added = 1;\n\n constructor(\n public readonly source: number,\n public readonly offset: number,\n public readonly length: number,\n public readonly lineOffsetStart: number,\n public readonly lineOffsetEnd: number\n ) {}\n\n get lineBreakCount(): number {\n return this.lineOffsetEnd - this.lineOffsetStart;\n }\n}\n\n// A text buffer is a string with its line offsets.\nclass TextBuffer {\n lineOffsets: number[];\n\n constructor(public text: string) {\n this.lineOffsets = computeLineOffsets(text);\n }\n\n // the append operation is efficient because it only appends\n // elements to the lineOffsets array in the end\n append(text: string): number {\n const offset = this.text.length;\n const appendedLineOffsets = computeLineOffsets(text);\n for (let i = 1; i < appendedLineOffsets.length; i++) {\n this.lineOffsets.push(offset + appendedLineOffsets[i]);\n }\n this.text += text;\n return offset;\n }\n}\n\n// A node in the balanced piece tree.\nclass PieceNode {\n left: PieceNode | null = null;\n right: PieceNode | null = null;\n parent: PieceNode | null = null;\n\n constructor(\n public piece: Piece,\n public subtreeLength: number = piece.length,\n public subtreeLineBreakCount: number = piece.lineBreakCount\n ) {}\n\n updateSubtreeLength(): void {\n this.subtreeLength =\n (this.left?.subtreeLength ?? 0) +\n this.piece.length +\n (this.right?.subtreeLength ?? 0);\n this.subtreeLineBreakCount =\n (this.left?.subtreeLineBreakCount ?? 0) +\n this.piece.lineBreakCount +\n (this.right?.subtreeLineBreakCount ?? 0);\n }\n}\n\n/**\n * A piece table is a data structure that allows for efficient insertion and deletion of text.\n * It is a tree of pieces, where each piece is a segment of text that is either original or added.\n * The tree is rebuilt as a balanced tree after edits to keep lookups efficient.\n * Inspired by https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation\n */\nexport class PieceTable {\n #original: TextBuffer;\n #add = new TextBuffer('');\n #root: PieceNode | null = null;\n #piecesCache: Piece[] = [];\n #length = 0;\n #lineCount = 0;\n #lastVisitedLine: [number, string] | null = null;\n\n constructor(originalText: string) {\n this.#original = new TextBuffer(originalText);\n this.#setPieces([\n this.#createPiece(Piece.Original, 0, originalText.length),\n ]);\n }\n\n get lineCount(): number {\n return this.#lineCount;\n }\n\n getText(range?: Range): string {\n if (range === undefined) {\n return this.#textFromPieces();\n }\n const start = this.offsetAt(range.start);\n const end = this.offsetAt(range.end);\n return this.getTextSlice(start, end);\n }\n\n getLineText(line: number, trimEOF = true): string {\n if (this.#lastVisitedLine !== null && this.#lastVisitedLine[0] === line) {\n return this.#lastVisitedLine[1];\n }\n const offset = this.#getLineOffset(line);\n if (offset === undefined) {\n throw new Error(`Line index out of range: ${line}`);\n }\n const text = this.getTextSlice(offset[0], offset[1], trimEOF);\n this.#lastVisitedLine = [line, text];\n return text;\n }\n\n getTextSlice(start: number, end: number, trimEOF = false): string {\n if (start >= end) {\n return '';\n }\n\n const sliceStart = clamp(start, 0, this.#length);\n const sliceEnd = clamp(end, sliceStart, this.#length);\n if (sliceStart >= sliceEnd) {\n return '';\n }\n\n const location = this.#findPieceAtOffset(sliceStart);\n if (location === undefined) {\n return '';\n }\n\n const chunks: string[] = [];\n let [node, offsetInPiece] = location as [PieceNode | null, number];\n let remaining = sliceEnd - sliceStart;\n while (node !== null && remaining > 0) {\n const takeLength = Math.min(node.piece.length - offsetInPiece, remaining);\n const buffer = this.#bufferFor(node.piece.source);\n const start = node.piece.offset + offsetInPiece;\n let end = start + takeLength;\n if (trimEOF) {\n while (end > start && isEOL(buffer.text.charCodeAt(end - 1))) {\n end--;\n }\n }\n chunks.push(buffer.text.slice(start, end));\n remaining -= takeLength;\n offsetInPiece = 0;\n node = this.#nextNode(node);\n }\n\n return chunks.join('');\n }\n\n charAt(offset: number): string {\n const location = this.#findPieceAtOffset(offset);\n if (location === undefined) {\n return '';\n }\n\n const [node, offsetInPiece] = location;\n const buffer = this.#bufferFor(node.piece.source);\n return buffer.text.charAt(node.piece.offset + offsetInPiece);\n }\n\n includes(needle: string): boolean {\n if (needle.length === 0) {\n return true;\n }\n\n const prefixTable = createPrefixTable(needle);\n let matched = 0;\n let found = false;\n this.#forEachPieceSegment((segment) => {\n for (let offset = segment.start; offset < segment.end; offset++) {\n const charCode = segment.text.charCodeAt(offset);\n while (matched > 0 && charCode !== needle.charCodeAt(matched)) {\n matched = prefixTable[matched - 1];\n }\n if (charCode === needle.charCodeAt(matched)) {\n matched++;\n }\n if (matched === needle.length) {\n found = true;\n return false;\n }\n }\n return true;\n });\n return found;\n }\n\n findNextNonOverlappingSubstring(\n needle: string,\n occupied: readonly [start: number, end: number][]\n ): number | undefined {\n if (needle.length === 0 || needle.length > this.#length) {\n return undefined;\n }\n\n const ranges = normalizeRanges(occupied, this.#length);\n const pivot = ranges.reduce((max, [, end]) => Math.max(max, end), 0);\n const prefixTable = createPrefixTable(needle);\n let matched = 0;\n let documentOffset = 0;\n let wrappedOffset: number | undefined;\n let foundOffset: number | undefined;\n\n this.#forEachPieceSegment((segment) => {\n for (let offset = segment.start; offset < segment.end; offset++) {\n const charCode = segment.text.charCodeAt(offset);\n while (matched > 0 && charCode !== needle.charCodeAt(matched)) {\n matched = prefixTable[matched - 1];\n }\n if (charCode === needle.charCodeAt(matched)) {\n matched++;\n }\n if (matched === needle.length) {\n const start = documentOffset - needle.length + 1;\n if (!rangeOverlaps(ranges, start, start + needle.length)) {\n if (start >= pivot) {\n foundOffset = start;\n return false;\n }\n wrappedOffset ??= start;\n }\n matched = prefixTable[matched - 1];\n }\n documentOffset++;\n }\n return true;\n });\n\n return foundOffset ?? wrappedOffset;\n }\n\n search(searchParams: SearchParams): [start: number, end: number][] {\n if (searchParams.text.length === 0 || this.#length === 0) {\n return [];\n }\n\n // Search currently operates line-by-line, so newline-spanning patterns are unsupported.\n if (\n searchParams.text.includes('\\n') ||\n searchParams.text.includes('\\r') ||\n (searchParams.regex &&\n (searchParams.text.includes('\\\\n') ||\n searchParams.text.includes('\\\\r')))\n ) {\n return [];\n }\n\n let pattern: RegExp;\n try {\n pattern = compileSearchRegExp(\n searchParams.text,\n searchParams.regex,\n searchParams.caseSensitive\n );\n } catch {\n return [];\n }\n\n return this.#collectSearchMatchesLineByLine(\n pattern,\n searchParams.wholeWord,\n MAX_FIND_MATCHES\n );\n }\n\n #collectSearchMatchesLineByLine(\n pattern: RegExp,\n wholeWord: boolean,\n limit: number\n ): [number, number][] {\n const out: [number, number][] = [];\n const docLength = this.#length;\n const charAt = (offset: number) => this.charAt(offset);\n\n for (let line = 0; line < this.#lineCount; line++) {\n const lineText = this.getLineText(line);\n const lineStart = this.offsetAt({ line, character: 0 });\n const re = new RegExp(pattern.source, pattern.flags);\n re.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(lineText)) !== null) {\n const rel = match.index;\n const fragment = match[0];\n if (fragment.length === 0) {\n re.lastIndex = advancePastEmptyMatch(lineText, rel);\n continue;\n }\n const docStart = lineStart + rel;\n if (\n !wholeWord ||\n isWholeWordAtDocOffsets(docStart, fragment.length, docLength, charAt)\n ) {\n out.push([docStart, docStart + fragment.length]);\n if (out.length >= limit) {\n return out;\n }\n }\n if (rel === re.lastIndex) {\n re.lastIndex = advancePastEmptyMatch(lineText, rel);\n }\n }\n }\n return out;\n }\n\n insert(text: string, offset: number): void {\n if (text.length === 0) {\n return;\n }\n\n const insertOffset = clamp(offset, 0, this.#length);\n const addOffset = this.#add.append(text);\n const insertedPiece = this.#createPiece(\n Piece.Added,\n addOffset,\n text.length\n );\n const pieces = this.#pieces();\n const nextPieces: Piece[] = [];\n\n let cursor = 0;\n let inserted = false;\n\n for (const piece of pieces) {\n const pieceEnd = cursor + piece.length;\n if (!inserted && insertOffset <= pieceEnd) {\n const splitOffset = insertOffset - cursor;\n if (splitOffset > 0) {\n nextPieces.push(\n this.#createPiece(piece.source, piece.offset, splitOffset)\n );\n }\n nextPieces.push(insertedPiece);\n if (splitOffset < piece.length) {\n nextPieces.push(\n this.#createPiece(\n piece.source,\n piece.offset + splitOffset,\n piece.length - splitOffset\n )\n );\n }\n inserted = true;\n } else {\n nextPieces.push(piece);\n }\n cursor = pieceEnd;\n }\n\n if (!inserted) {\n nextPieces.push(insertedPiece);\n }\n\n this.#setPieces(nextPieces);\n this.#lastVisitedLine = null;\n }\n\n delete(offset: number, length: number): void {\n if (length <= 0 || this.#length === 0) {\n return;\n }\n\n const start = clamp(offset, 0, this.#length);\n const end = clamp(start + length, start, this.#length);\n if (start === end) {\n return;\n }\n\n const nextPieces: Piece[] = [];\n let cursor = 0;\n for (const piece of this.#pieces()) {\n const pieceStart = cursor;\n const pieceEnd = cursor + piece.length;\n const keepBefore = clamp(start - pieceStart, 0, piece.length);\n const keepAfter = clamp(pieceEnd - end, 0, piece.length);\n\n if (keepBefore > 0) {\n nextPieces.push(\n this.#createPiece(piece.source, piece.offset, keepBefore)\n );\n }\n if (keepAfter > 0) {\n nextPieces.push(\n this.#createPiece(\n piece.source,\n piece.offset + piece.length - keepAfter,\n keepAfter\n )\n );\n }\n cursor = pieceEnd;\n }\n\n this.#setPieces(nextPieces);\n this.#lastVisitedLine = null;\n }\n\n applyEdits(edits: readonly ResolvedTextEdit[]): void {\n if (edits.length === 0) {\n return;\n }\n\n let pieceIndex = 0;\n let pieceStart = 0;\n let copyCursor = 0;\n\n const pieces = this.#pieces();\n const insertedPieces = edits.map((edit) =>\n edit.text.length === 0\n ? undefined\n : this.#createPiece(\n Piece.Added,\n this.#add.append(edit.text),\n edit.text.length\n )\n );\n const nextPieces: Piece[] = [];\n\n const advancePiece = () => {\n const piece = pieces[pieceIndex];\n if (piece !== undefined) {\n pieceStart += piece.length;\n pieceIndex++;\n }\n };\n\n const appendRange = (start: number, end: number) => {\n let rangeStart = clamp(start, 0, this.#length);\n const rangeEnd = clamp(end, rangeStart, this.#length);\n while (\n pieceIndex < pieces.length &&\n pieceStart + pieces[pieceIndex].length <= rangeStart\n ) {\n advancePiece();\n }\n while (pieceIndex < pieces.length && rangeStart < rangeEnd) {\n const piece = pieces[pieceIndex];\n const pieceEnd = pieceStart + piece.length;\n const offsetInPiece = clamp(rangeStart - pieceStart, 0, piece.length);\n const takeEnd = Math.min(pieceEnd, rangeEnd);\n const takeLength = takeEnd - (pieceStart + offsetInPiece);\n if (takeLength > 0) {\n nextPieces.push(\n offsetInPiece === 0 && takeLength === piece.length\n ? piece\n : this.#createPiece(\n piece.source,\n piece.offset + offsetInPiece,\n takeLength\n )\n );\n }\n rangeStart = takeEnd;\n if (rangeStart >= pieceEnd) {\n advancePiece();\n }\n }\n };\n\n for (let i = 0; i < edits.length; i++) {\n const edit = edits[i];\n const start = clamp(edit.start, copyCursor, this.#length);\n const end = clamp(edit.end, start, this.#length);\n appendRange(copyCursor, start);\n\n const insertedPiece = insertedPieces[i];\n if (insertedPiece !== undefined) {\n nextPieces.push(insertedPiece);\n }\n copyCursor = end;\n }\n appendRange(copyCursor, this.#length);\n\n this.#setPieces(nextPieces);\n this.#lastVisitedLine = null;\n }\n\n positionAt(offset: number): Position {\n const clampedOffset = clamp(offset, 0, this.#length);\n if (this.#length === 0) {\n return { line: 0, character: 0 };\n }\n const line = this.#lineAtOffset(clampedOffset);\n const lineStart = line === 0 ? 0 : this.#lineBreakOffset(line - 1);\n return {\n line,\n character: clampedOffset - lineStart,\n };\n }\n\n positionsAt(offsets: readonly number[]): Position[] {\n const positions: Position[] = Array.from({ length: offsets.length });\n if (offsets.length === 0) {\n return positions;\n }\n if (this.#length === 0) {\n return positions.fill({ line: 0, character: 0 });\n }\n\n for (let i = 0; i < offsets.length; i++) {\n positions[i] = this.positionAt(offsets[i]);\n }\n\n return positions;\n }\n\n offsetAt(position: Position): number {\n if (position.line < 0 || this.#length === 0) {\n return 0;\n }\n if (position.line >= this.#lineCount) {\n throw new Error(`Line index out of range: ${position.line}`);\n }\n const offset = this.#getLineOffset(position.line);\n if (offset === undefined) {\n throw new Error(`Line index out of range: ${position.line}`);\n }\n const character = clamp(position.character, 0, offset[1] - offset[0]);\n return offset[0] + character;\n }\n\n offsetsAt(positions: readonly Position[]): number[] {\n const offsets: number[] = Array.from({ length: positions.length });\n if (positions.length === 0) {\n return offsets;\n }\n if (this.#length === 0) {\n return offsets.fill(0);\n }\n\n for (let i = 0; i < positions.length; i++) {\n offsets[i] = this.offsetAt(positions[i]);\n }\n\n return offsets;\n }\n\n #findPieceAtOffset(\n offset: number\n ): [node: PieceNode, offsetInPiece: number] | undefined {\n if (offset < 0 || offset >= this.#length) {\n return undefined;\n }\n\n let node = this.#root;\n let remaining = offset;\n while (node !== null) {\n const leftLength = node.left?.subtreeLength ?? 0;\n if (remaining < leftLength) {\n node = node.left;\n continue;\n }\n\n remaining -= leftLength;\n if (remaining < node.piece.length) {\n return [node, remaining];\n }\n\n remaining -= node.piece.length;\n node = node.right;\n }\n\n return undefined;\n }\n\n #nextNode(node: PieceNode): PieceNode | null {\n if (node.right !== null) {\n let next = node.right;\n while (next.left !== null) {\n next = next.left;\n }\n return next;\n }\n\n let current = node;\n while (current.parent !== null && current === current.parent.right) {\n current = current.parent;\n }\n return current.parent;\n }\n\n #getLineOffset(line: number): [start: number, end: number] | undefined {\n if (line < 0) {\n throw new Error(`Line index out of range: ${line}`);\n }\n if (this.#length === 0) {\n if (line === 0) {\n return [0, 0];\n }\n throw new Error(`Line index out of range: ${line}`);\n }\n if (line >= this.#lineCount) {\n throw new Error(`Line index out of range: ${line}`);\n }\n\n const start = line === 0 ? 0 : this.#lineBreakOffset(line - 1);\n const end =\n line < this.#lineCount - 1 ? this.#lineBreakOffset(line) : this.#length;\n return [start, end];\n }\n\n #lineAtOffset(offset: number): number {\n let node = this.#root;\n let remaining = clamp(offset, 0, this.#length);\n let line = 0;\n\n while (node !== null) {\n const leftLength = node.left?.subtreeLength ?? 0;\n if (remaining < leftLength) {\n node = node.left;\n continue;\n }\n\n line += node.left?.subtreeLineBreakCount ?? 0;\n remaining -= leftLength;\n if (remaining <= node.piece.length) {\n const buffer = this.#bufferFor(node.piece.source);\n line +=\n upperBound(buffer.lineOffsets, node.piece.offset + remaining) -\n node.piece.lineOffsetStart;\n return line;\n }\n\n line += node.piece.lineBreakCount;\n remaining -= node.piece.length;\n node = node.right;\n }\n\n return this.#lineCount - 1;\n }\n\n #lineBreakOffset(lineBreakIndex: number): number {\n let node = this.#root;\n let remaining = lineBreakIndex;\n let documentOffset = 0;\n\n while (node !== null) {\n const leftLineBreakCount = node.left?.subtreeLineBreakCount ?? 0;\n if (remaining < leftLineBreakCount) {\n node = node.left;\n continue;\n }\n\n const leftLength = node.left?.subtreeLength ?? 0;\n documentOffset += leftLength;\n remaining -= leftLineBreakCount;\n\n if (remaining < node.piece.lineBreakCount) {\n const bufferLineOffset = this.#bufferFor(node.piece.source).lineOffsets[\n node.piece.lineOffsetStart + remaining\n ];\n return documentOffset + (bufferLineOffset - node.piece.offset);\n }\n\n documentOffset += node.piece.length;\n remaining -= node.piece.lineBreakCount;\n node = node.right;\n }\n\n return this.#length;\n }\n\n #textFromPieces(): string {\n const chunks: string[] = [];\n this.#forEachPieceSegment((segment) => {\n chunks.push(segment.text.slice(segment.start, segment.end));\n });\n return chunks.join('');\n }\n\n #forEachPieceSegment(\n callback: (segment: {\n readonly start: number;\n readonly end: number;\n readonly text: string;\n readonly lineOffsets: number[];\n readonly lineOffsetStart: number;\n readonly lineOffsetEnd: number;\n }) => boolean | void\n ): void {\n this.#walk(this.#root, (node) => {\n const buffer = this.#bufferFor(node.piece.source);\n return callback({\n text: buffer.text,\n lineOffsets: buffer.lineOffsets,\n lineOffsetStart: node.piece.lineOffsetStart,\n lineOffsetEnd: node.piece.lineOffsetEnd,\n start: node.piece.offset,\n end: node.piece.offset + node.piece.length,\n });\n });\n }\n\n #bufferFor(source: number): TextBuffer {\n return source === Piece.Original ? this.#original : this.#add;\n }\n\n #createPiece(source: number, offset: number, length: number): Piece {\n const buffer = this.#bufferFor(source);\n return new Piece(\n source,\n offset,\n length,\n upperBound(buffer.lineOffsets, offset),\n upperBound(buffer.lineOffsets, offset + length)\n );\n }\n\n #pieces(): Piece[] {\n return this.#piecesCache;\n }\n\n #setPieces(pieces: Piece[]): void {\n const coalescedPieces = coalescePieces(pieces);\n this.#piecesCache = coalescedPieces;\n let length = 0;\n let lineBreakCount = 0;\n for (const piece of coalescedPieces) {\n length += piece.length;\n lineBreakCount += piece.lineBreakCount;\n }\n this.#root = this.#buildBalancedTree(\n coalescedPieces,\n 0,\n coalescedPieces.length,\n null\n );\n this.#length = length;\n this.#lineCount = lineBreakCount + 1;\n }\n\n #buildBalancedTree(\n pieces: Piece[],\n start: number,\n end: number,\n parent: PieceNode | null\n ): PieceNode | null {\n if (start >= end) {\n return null;\n }\n\n const middle = start + Math.floor((end - start) / 2);\n const node = new PieceNode(pieces[middle]);\n node.parent = parent;\n node.left = this.#buildBalancedTree(pieces, start, middle, node);\n node.right = this.#buildBalancedTree(pieces, middle + 1, end, node);\n node.updateSubtreeLength();\n return node;\n }\n\n #walk(\n node: PieceNode | null,\n visit: (node: PieceNode) => boolean | void\n ): boolean {\n if (node === null) {\n return true;\n }\n if (!this.#walk(node.left, visit)) {\n return false;\n }\n if (visit(node) === false) {\n return false;\n }\n return this.#walk(node.right, visit);\n }\n}\n\nfunction isEOL(charCode: number): boolean {\n return charCode === /* \\n */ 10 || charCode === /* \\r */ 13;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction createPrefixTable(text: string): number[] {\n const table = Array.from<number>({ length: text.length }).fill(0);\n let matched = 0;\n for (let i = 1; i < text.length; i++) {\n const charCode = text.charCodeAt(i);\n while (matched > 0 && charCode !== text.charCodeAt(matched)) {\n matched = table[matched - 1];\n }\n if (charCode === text.charCodeAt(matched)) {\n matched++;\n }\n table[i] = matched;\n }\n return table;\n}\n\nfunction normalizeRanges(\n ranges: readonly [start: number, end: number][],\n length: number\n): [start: number, end: number][] {\n const normalized: [start: number, end: number][] = [];\n for (const [rawStart, rawEnd] of ranges) {\n const start = clamp(rawStart, 0, length);\n const end = clamp(rawEnd, start, length);\n if (start < end) {\n normalized.push([start, end]);\n }\n }\n normalized.sort((a, b) => a[0] - b[0]);\n\n const merged: [start: number, end: number][] = [];\n for (const range of normalized) {\n const previous = merged[merged.length - 1];\n if (previous !== undefined && range[0] <= previous[1]) {\n previous[1] = Math.max(previous[1], range[1]);\n continue;\n }\n merged.push(range);\n }\n return merged;\n}\n\nfunction rangeOverlaps(\n ranges: readonly [start: number, end: number][],\n start: number,\n end: number\n): boolean {\n let low = 0;\n let high = ranges.length;\n while (low < high) {\n const mid = low + Math.floor((high - low) / 2);\n if (ranges[mid][1] <= start) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n\n const range = ranges[low];\n return range !== undefined && range[0] < end;\n}\n\n// Keeps the table compact after repeated edits by joining neighboring pieces\n// that already point at contiguous text in the same backing buffer.\nfunction coalescePieces(pieces: Piece[]): Piece[] {\n const coalescedPieces: Piece[] = [];\n for (const piece of pieces) {\n if (piece.length === 0) {\n continue;\n }\n\n const previous = coalescedPieces[coalescedPieces.length - 1];\n if (\n previous !== undefined &&\n previous.source === piece.source &&\n previous.offset + previous.length === piece.offset\n ) {\n coalescedPieces[coalescedPieces.length - 1] = new Piece(\n previous.source,\n previous.offset,\n previous.length + piece.length,\n previous.lineOffsetStart,\n piece.lineOffsetEnd\n );\n continue;\n }\n\n coalescedPieces.push(piece);\n }\n return coalescedPieces;\n}\n\n// Returns the index of the first element in the array that is greater than the target.\nfunction upperBound(values: number[], target: number): number {\n let lo = 0;\n let hi = values.length;\n while (lo < hi) {\n const mid = lo + Math.floor((hi - lo) / 2);\n if (values[mid] <= target) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n return lo;\n}\n\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction isWordSeparatorCharCode(charCode: number): boolean {\n if (charCode <= 32 || charCode === 127) {\n return true;\n }\n const ch = String.fromCharCode(charCode);\n return WORD_SEPARATORS.includes(ch);\n}\n\n// Checks if the given text is a whole word by checking if the\n// characters before and after are word separators.\nfunction isWholeWordAtDocOffsets(\n docStart: number,\n length: number,\n docLength: number,\n charAt: (offset: number) => string\n): boolean {\n const beforeOk =\n docStart <= 0 ||\n isWordSeparatorCharCode(charCodeUnitAt(charAt, docStart - 1));\n const afterOk =\n docStart + length >= docLength ||\n isWordSeparatorCharCode(charCodeUnitAt(charAt, docStart + length));\n return beforeOk && afterOk;\n}\n\nfunction charCodeUnitAt(\n charAt: (offset: number) => string,\n offset: number\n): number {\n const unit = charAt(offset);\n return unit.length === 0 ? 0 : unit.charCodeAt(0);\n}\n\nfunction compileSearchRegExp(\n source: string,\n isRegex: boolean,\n caseSensitive: boolean\n): RegExp {\n const body = isRegex ? source : escapeRegExp(source);\n const flags = `g${caseSensitive ? '' : 'i'}${isRegex ? 'm' : ''}`;\n return new RegExp(body, flags);\n}\n\nfunction advancePastEmptyMatch(text: string, index: number): number {\n if (index + 1 < text.length) {\n const first = text.charCodeAt(index);\n const second = text.charCodeAt(index + 1);\n if (\n first >= 0xd800 &&\n first <= 0xdbff &&\n second >= 0xdc00 &&\n second <= 0xdfff\n ) {\n return index + 2;\n }\n }\n return index + 1;\n}\n"],"mappings":";;;AAIA,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB;AAGxB,IAAM,QAAN,MAAY;CACV,OAAO,WA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IAAI,KAAK;CACT,IAAI,KAAK,OAAO;AAChB,QAAO,KAAK,IAAI;EACd,MAAM,MAAM,KAAK,KAAK,OAAO,KAAK,MAAM,EAAE;AAC1C,MAAI,OAAO,QAAQ,OACjB,MAAK,MAAM;MAEX,MAAK;;AAGT,QAAO;;AAGT,SAAS,aAAa,MAAsB;AAC1C,QAAO,KAAK,QAAQ,uBAAuB,OAAO;;AAGpD,SAAS,wBAAwB,UAA2B;AAC1D,KAAI,YAAY,MAAM,aAAa,IACjC,QAAO;CAET,MAAM,KAAK,OAAO,aAAa,SAAS;AACxC,QAAO,gBAAgB,SAAS,GAAG;;AAKrC,SAAS,wBACP,UACA,QACA,WACA,QACS;CACT,MAAM,WACJ,YAAY,KACZ,wBAAwB,eAAe,QAAQ,WAAW,EAAE,CAAC;CAC/D,MAAM,UACJ,WAAW,UAAU,aACrB,wBAAwB,eAAe,QAAQ,WAAW,OAAO,CAAC;AACpE,QAAO,YAAY;;AAGrB,SAAS,eACP,QACA,QACQ;CACR,MAAM,OAAO,OAAO,OAAO;AAC3B,QAAO,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,EAAE;;AAGnD,SAAS,oBACP,QACA,SACA,eACQ;CACR,MAAM,OAAO,UAAU,SAAS,aAAa,OAAO;CACpD,MAAM,QAAQ,IAAI,gBAAgB,KAAK,MAAM,UAAU,MAAM;AAC7D,QAAO,IAAI,OAAO,MAAM,MAAM;;AAGhC,SAAS,sBAAsB,MAAc,OAAuB;AAClE,KAAI,QAAQ,IAAI,KAAK,QAAQ;EAC3B,MAAM,QAAQ,KAAK,WAAW,MAAM;EACpC,MAAM,SAAS,KAAK,WAAW,QAAQ,EAAE;AACzC,MACE,SAAS,SACT,SAAS,SACT,UAAU,SACV,UAAU,MAEV,QAAO,QAAQ;;AAGnB,QAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"pieceTable.js","names":["source: number","offset: number","length: number","lineOffsetStart: number","lineOffsetEnd: number","text: string","piece: Piece","subtreeLength: number","subtreeLineBreakCount: number","#original","#setPieces","#createPiece","#lineCount","#textFromPieces","#lastVisitedLine","#getLineOffset","#lastVisitedLineLength","length","#length","#findPieceAtOffset","chunks: string[]","#bufferFor","start","end","#nextNode","#forEachPieceSegment","wrappedOffset: number | undefined","foundOffset: number | undefined","pattern: RegExp","#collectSearchMatchesLineByLine","out: [number, number][]","match: RegExpExecArray | null","#add","#pieces","nextPieces: Piece[]","#lineAtOffset","#lineBreakOffset","positions: Position[]","#root","#walk","#piecesCache","#buildBalancedTree","normalized: [start: number, end: number][]","merged: [start: number, end: number][]","coalescedPieces: Piece[]"],"sources":["../../src/editor/pieceTable.ts"],"sourcesContent":["import { computeLineOffsets } from '../utils/computeFileOffsets';\nimport type { SearchParams } from './searchPanel';\nimport type { Position, Range, ResolvedTextEdit } from './textDocument';\n\nconst MAX_FIND_MATCHES = 100000;\n// TODO(ije): use Intl.Segmenter instead of regex for word separators\nconst WORD_SEPARATORS = '`~!@#$%^&*()-=+[{]}\\\\|;:\\'\",.<>/?' as const;\n\n// A piece is a segment of text that is either original or added.\nclass Piece {\n static Original = 0;\n static Added = 1;\n\n constructor(\n public readonly source: number,\n public readonly offset: number,\n public readonly length: number,\n public readonly lineOffsetStart: number,\n public readonly lineOffsetEnd: number\n ) {}\n\n get lineBreakCount(): number {\n return this.lineOffsetEnd - this.lineOffsetStart;\n }\n}\n\n// A text buffer is a string with its line offsets.\nclass TextBuffer {\n lineOffsets: number[];\n\n constructor(public text: string) {\n this.lineOffsets = computeLineOffsets(text);\n }\n\n // the append operation is efficient because it only appends\n // elements to the lineOffsets array in the end\n append(text: string): number {\n const offset = this.text.length;\n const appendedLineOffsets = computeLineOffsets(text);\n for (let i = 1; i < appendedLineOffsets.length; i++) {\n this.lineOffsets.push(offset + appendedLineOffsets[i]);\n }\n this.text += text;\n return offset;\n }\n}\n\n// A node in the balanced piece tree.\nclass PieceNode {\n left: PieceNode | null = null;\n right: PieceNode | null = null;\n parent: PieceNode | null = null;\n\n constructor(\n public piece: Piece,\n public subtreeLength: number = piece.length,\n public subtreeLineBreakCount: number = piece.lineBreakCount\n ) {}\n\n updateSubtreeLength(): void {\n this.subtreeLength =\n (this.left?.subtreeLength ?? 0) +\n this.piece.length +\n (this.right?.subtreeLength ?? 0);\n this.subtreeLineBreakCount =\n (this.left?.subtreeLineBreakCount ?? 0) +\n this.piece.lineBreakCount +\n (this.right?.subtreeLineBreakCount ?? 0);\n }\n}\n\n/**\n * A piece table is a data structure that allows for efficient insertion and deletion of text.\n * It is a tree of pieces, where each piece is a segment of text that is either original or added.\n * The tree is rebuilt as a balanced tree after edits to keep lookups efficient.\n * Inspired by https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation\n */\nexport class PieceTable {\n #original: TextBuffer;\n #add = new TextBuffer('');\n #root: PieceNode | null = null;\n #piecesCache: Piece[] = [];\n #length = 0;\n #lineCount = 0;\n #lastVisitedLine: [number, boolean, string] | null = null;\n #lastVisitedLineLength: [number, boolean, number] | null = null;\n\n constructor(originalText: string) {\n this.#original = new TextBuffer(originalText);\n this.#setPieces([\n this.#createPiece(Piece.Original, 0, originalText.length),\n ]);\n }\n\n get lineCount(): number {\n return this.#lineCount;\n }\n\n getText(range?: Range): string {\n if (range === undefined) {\n return this.#textFromPieces();\n }\n const start = this.offsetAt(range.start);\n const end = this.offsetAt(range.end);\n return this.getTextSlice(start, end);\n }\n\n getLineText(line: number, includeLineBreak = false): string {\n if (\n this.#lastVisitedLine !== null &&\n this.#lastVisitedLine[0] === line &&\n this.#lastVisitedLine[1] === includeLineBreak\n ) {\n return this.#lastVisitedLine[2];\n }\n const offset = this.#getLineOffset(line);\n if (offset === undefined) {\n throw new Error(`Line index out of range: ${line}`);\n }\n const text = this.getTextSlice(offset[0], offset[1], !includeLineBreak);\n this.#lastVisitedLine = [line, includeLineBreak, text];\n this.#lastVisitedLineLength = [line, includeLineBreak, text.length];\n return text;\n }\n\n getLineLength(line: number, includeLineBreak = false): number {\n const lastVisitedLineLength = this.#lastVisitedLineLength;\n const lastVisitedLine = this.#lastVisitedLine;\n if (\n lastVisitedLineLength !== null &&\n lastVisitedLineLength[0] === line &&\n lastVisitedLineLength[1] === includeLineBreak\n ) {\n return lastVisitedLineLength[2];\n }\n if (\n lastVisitedLine !== null &&\n lastVisitedLine[0] === line &&\n lastVisitedLine[1] === includeLineBreak\n ) {\n const length = lastVisitedLine[2].length;\n this.#lastVisitedLineLength = [line, includeLineBreak, length];\n return length;\n }\n const offset = this.#getLineOffset(line);\n if (offset === undefined) {\n throw new Error(`Line index out of range: ${line}`);\n }\n const [start, end] = offset;\n let length = end - start;\n if (!includeLineBreak) {\n while (\n length > 0 &&\n isEOL(this.charAt(start + length - 1).charCodeAt(0))\n ) {\n length--;\n }\n }\n this.#lastVisitedLineLength = [line, includeLineBreak, length];\n return length;\n }\n\n getTextSlice(start: number, end: number, trimEOF = false): string {\n if (start >= end) {\n return '';\n }\n\n const sliceStart = clamp(start, 0, this.#length);\n const sliceEnd = clamp(end, sliceStart, this.#length);\n if (sliceStart >= sliceEnd) {\n return '';\n }\n\n const location = this.#findPieceAtOffset(sliceStart);\n if (location === undefined) {\n return '';\n }\n\n const chunks: string[] = [];\n let [node, offsetInPiece] = location as [PieceNode | null, number];\n let remaining = sliceEnd - sliceStart;\n while (node !== null && remaining > 0) {\n const takeLength = Math.min(node.piece.length - offsetInPiece, remaining);\n const buffer = this.#bufferFor(node.piece.source);\n const start = node.piece.offset + offsetInPiece;\n let end = start + takeLength;\n if (trimEOF) {\n while (end > start && isEOL(buffer.text.charCodeAt(end - 1))) {\n end--;\n }\n }\n chunks.push(buffer.text.slice(start, end));\n remaining -= takeLength;\n offsetInPiece = 0;\n node = this.#nextNode(node);\n }\n\n return chunks.join('');\n }\n\n charAt(offset: number): string {\n const location = this.#findPieceAtOffset(offset);\n if (location === undefined) {\n return '';\n }\n\n const [node, offsetInPiece] = location;\n const buffer = this.#bufferFor(node.piece.source);\n return buffer.text.charAt(node.piece.offset + offsetInPiece);\n }\n\n includes(needle: string): boolean {\n if (needle.length === 0) {\n return true;\n }\n\n const prefixTable = createPrefixTable(needle);\n let matched = 0;\n let found = false;\n this.#forEachPieceSegment((segment) => {\n for (let offset = segment.start; offset < segment.end; offset++) {\n const charCode = segment.text.charCodeAt(offset);\n while (matched > 0 && charCode !== needle.charCodeAt(matched)) {\n matched = prefixTable[matched - 1];\n }\n if (charCode === needle.charCodeAt(matched)) {\n matched++;\n }\n if (matched === needle.length) {\n found = true;\n return false;\n }\n }\n return true;\n });\n return found;\n }\n\n findNextNonOverlappingSubstring(\n needle: string,\n occupied: readonly [start: number, end: number][]\n ): number | undefined {\n if (needle.length === 0 || needle.length > this.#length) {\n return undefined;\n }\n\n const ranges = normalizeRanges(occupied, this.#length);\n const pivot = ranges.reduce((max, [, end]) => Math.max(max, end), 0);\n const prefixTable = createPrefixTable(needle);\n let matched = 0;\n let documentOffset = 0;\n let wrappedOffset: number | undefined;\n let foundOffset: number | undefined;\n\n this.#forEachPieceSegment((segment) => {\n for (let offset = segment.start; offset < segment.end; offset++) {\n const charCode = segment.text.charCodeAt(offset);\n while (matched > 0 && charCode !== needle.charCodeAt(matched)) {\n matched = prefixTable[matched - 1];\n }\n if (charCode === needle.charCodeAt(matched)) {\n matched++;\n }\n if (matched === needle.length) {\n const start = documentOffset - needle.length + 1;\n if (!rangeOverlaps(ranges, start, start + needle.length)) {\n if (start >= pivot) {\n foundOffset = start;\n return false;\n }\n wrappedOffset ??= start;\n }\n matched = prefixTable[matched - 1];\n }\n documentOffset++;\n }\n return true;\n });\n\n return foundOffset ?? wrappedOffset;\n }\n\n search(searchParams: SearchParams): [start: number, end: number][] {\n if (searchParams.text.length === 0 || this.#length === 0) {\n return [];\n }\n\n // Search currently operates line-by-line, so newline-spanning patterns are unsupported.\n if (\n searchParams.text.includes('\\n') ||\n searchParams.text.includes('\\r') ||\n (searchParams.regex &&\n (searchParams.text.includes('\\\\n') ||\n searchParams.text.includes('\\\\r')))\n ) {\n return [];\n }\n\n let pattern: RegExp;\n try {\n pattern = compileSearchRegExp(\n searchParams.text,\n searchParams.regex,\n searchParams.caseSensitive\n );\n } catch {\n return [];\n }\n\n return this.#collectSearchMatchesLineByLine(\n pattern,\n searchParams.wholeWord,\n MAX_FIND_MATCHES\n );\n }\n\n #collectSearchMatchesLineByLine(\n pattern: RegExp,\n wholeWord: boolean,\n limit: number\n ): [number, number][] {\n const out: [number, number][] = [];\n const docLength = this.#length;\n const charAt = (offset: number) => this.charAt(offset);\n\n for (let line = 0; line < this.#lineCount; line++) {\n const lineText = this.getLineText(line);\n const lineStart = this.offsetAt({ line, character: 0 });\n const re = new RegExp(pattern.source, pattern.flags);\n re.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(lineText)) !== null) {\n const rel = match.index;\n const fragment = match[0];\n if (fragment.length === 0) {\n re.lastIndex = advancePastEmptyMatch(lineText, rel);\n continue;\n }\n const docStart = lineStart + rel;\n if (\n !wholeWord ||\n isWholeWordAtDocOffsets(docStart, fragment.length, docLength, charAt)\n ) {\n out.push([docStart, docStart + fragment.length]);\n if (out.length >= limit) {\n return out;\n }\n }\n if (rel === re.lastIndex) {\n re.lastIndex = advancePastEmptyMatch(lineText, rel);\n }\n }\n }\n return out;\n }\n\n insert(text: string, offset: number): void {\n if (text.length === 0) {\n return;\n }\n\n const insertOffset = clamp(offset, 0, this.#length);\n const addOffset = this.#add.append(text);\n const insertedPiece = this.#createPiece(\n Piece.Added,\n addOffset,\n text.length\n );\n const pieces = this.#pieces();\n const nextPieces: Piece[] = [];\n\n let cursor = 0;\n let inserted = false;\n\n for (const piece of pieces) {\n const pieceEnd = cursor + piece.length;\n if (!inserted && insertOffset <= pieceEnd) {\n const splitOffset = insertOffset - cursor;\n if (splitOffset > 0) {\n nextPieces.push(\n this.#createPiece(piece.source, piece.offset, splitOffset)\n );\n }\n nextPieces.push(insertedPiece);\n if (splitOffset < piece.length) {\n nextPieces.push(\n this.#createPiece(\n piece.source,\n piece.offset + splitOffset,\n piece.length - splitOffset\n )\n );\n }\n inserted = true;\n } else {\n nextPieces.push(piece);\n }\n cursor = pieceEnd;\n }\n\n if (!inserted) {\n nextPieces.push(insertedPiece);\n }\n\n this.#setPieces(nextPieces);\n this.#lastVisitedLine = null;\n this.#lastVisitedLineLength = null;\n }\n\n delete(offset: number, length: number): void {\n if (length <= 0 || this.#length === 0) {\n return;\n }\n\n const start = clamp(offset, 0, this.#length);\n const end = clamp(start + length, start, this.#length);\n if (start === end) {\n return;\n }\n\n const nextPieces: Piece[] = [];\n let cursor = 0;\n for (const piece of this.#pieces()) {\n const pieceStart = cursor;\n const pieceEnd = cursor + piece.length;\n const keepBefore = clamp(start - pieceStart, 0, piece.length);\n const keepAfter = clamp(pieceEnd - end, 0, piece.length);\n\n if (keepBefore > 0) {\n nextPieces.push(\n this.#createPiece(piece.source, piece.offset, keepBefore)\n );\n }\n if (keepAfter > 0) {\n nextPieces.push(\n this.#createPiece(\n piece.source,\n piece.offset + piece.length - keepAfter,\n keepAfter\n )\n );\n }\n cursor = pieceEnd;\n }\n\n this.#setPieces(nextPieces);\n this.#lastVisitedLine = null;\n this.#lastVisitedLineLength = null;\n }\n\n applyEdits(edits: readonly ResolvedTextEdit[]): void {\n if (edits.length === 0) {\n return;\n }\n\n let pieceIndex = 0;\n let pieceStart = 0;\n let copyCursor = 0;\n\n const pieces = this.#pieces();\n const insertedPieces = edits.map((edit) =>\n edit.text.length === 0\n ? undefined\n : this.#createPiece(\n Piece.Added,\n this.#add.append(edit.text),\n edit.text.length\n )\n );\n const nextPieces: Piece[] = [];\n\n const advancePiece = () => {\n const piece = pieces[pieceIndex];\n if (piece !== undefined) {\n pieceStart += piece.length;\n pieceIndex++;\n }\n };\n\n const appendRange = (start: number, end: number) => {\n let rangeStart = clamp(start, 0, this.#length);\n const rangeEnd = clamp(end, rangeStart, this.#length);\n while (\n pieceIndex < pieces.length &&\n pieceStart + pieces[pieceIndex].length <= rangeStart\n ) {\n advancePiece();\n }\n while (pieceIndex < pieces.length && rangeStart < rangeEnd) {\n const piece = pieces[pieceIndex];\n const pieceEnd = pieceStart + piece.length;\n const offsetInPiece = clamp(rangeStart - pieceStart, 0, piece.length);\n const takeEnd = Math.min(pieceEnd, rangeEnd);\n const takeLength = takeEnd - (pieceStart + offsetInPiece);\n if (takeLength > 0) {\n nextPieces.push(\n offsetInPiece === 0 && takeLength === piece.length\n ? piece\n : this.#createPiece(\n piece.source,\n piece.offset + offsetInPiece,\n takeLength\n )\n );\n }\n rangeStart = takeEnd;\n if (rangeStart >= pieceEnd) {\n advancePiece();\n }\n }\n };\n\n for (let i = 0; i < edits.length; i++) {\n const edit = edits[i];\n const start = clamp(edit.start, copyCursor, this.#length);\n const end = clamp(edit.end, start, this.#length);\n appendRange(copyCursor, start);\n\n const insertedPiece = insertedPieces[i];\n if (insertedPiece !== undefined) {\n nextPieces.push(insertedPiece);\n }\n copyCursor = end;\n }\n appendRange(copyCursor, this.#length);\n\n this.#setPieces(nextPieces);\n this.#lastVisitedLine = null;\n this.#lastVisitedLineLength = null;\n }\n\n positionAt(offset: number): Position {\n const clampedOffset = clamp(offset, 0, this.#length);\n if (this.#length === 0) {\n return { line: 0, character: 0 };\n }\n const line = this.#lineAtOffset(clampedOffset);\n const lineStart = line === 0 ? 0 : this.#lineBreakOffset(line - 1);\n return {\n line,\n character: clampedOffset - lineStart,\n };\n }\n\n positionsAt(offsets: readonly number[]): Position[] {\n const positions: Position[] = Array.from({ length: offsets.length });\n if (offsets.length === 0) {\n return positions;\n }\n if (this.#length === 0) {\n return positions.fill({ line: 0, character: 0 });\n }\n\n for (let i = 0; i < offsets.length; i++) {\n positions[i] = this.positionAt(offsets[i]);\n }\n\n return positions;\n }\n\n offsetAt(position: Position): number {\n if (position.line < 0 || this.#length === 0) {\n return 0;\n }\n if (position.line >= this.#lineCount) {\n throw new Error(`Line index out of range: ${position.line}`);\n }\n const offset = this.#getLineOffset(position.line);\n if (offset === undefined) {\n throw new Error(`Line index out of range: ${position.line}`);\n }\n const character = clamp(position.character, 0, offset[1] - offset[0]);\n return offset[0] + character;\n }\n\n #findPieceAtOffset(\n offset: number\n ): [node: PieceNode, offsetInPiece: number] | undefined {\n if (offset < 0 || offset >= this.#length) {\n return undefined;\n }\n\n let node = this.#root;\n let remaining = offset;\n while (node !== null) {\n const leftLength = node.left?.subtreeLength ?? 0;\n if (remaining < leftLength) {\n node = node.left;\n continue;\n }\n\n remaining -= leftLength;\n if (remaining < node.piece.length) {\n return [node, remaining];\n }\n\n remaining -= node.piece.length;\n node = node.right;\n }\n\n return undefined;\n }\n\n #nextNode(node: PieceNode): PieceNode | null {\n if (node.right !== null) {\n let next = node.right;\n while (next.left !== null) {\n next = next.left;\n }\n return next;\n }\n\n let current = node;\n while (current.parent !== null && current === current.parent.right) {\n current = current.parent;\n }\n return current.parent;\n }\n\n #getLineOffset(line: number): [start: number, end: number] | undefined {\n if (line < 0) {\n throw new Error(`Line index out of range: ${line}`);\n }\n if (this.#length === 0) {\n if (line === 0) {\n return [0, 0];\n }\n throw new Error(`Line index out of range: ${line}`);\n }\n if (line >= this.#lineCount) {\n throw new Error(`Line index out of range: ${line}`);\n }\n\n const start = line === 0 ? 0 : this.#lineBreakOffset(line - 1);\n const end =\n line < this.#lineCount - 1 ? this.#lineBreakOffset(line) : this.#length;\n return [start, end];\n }\n\n #lineAtOffset(offset: number): number {\n let node = this.#root;\n let remaining = clamp(offset, 0, this.#length);\n let line = 0;\n\n while (node !== null) {\n const leftLength = node.left?.subtreeLength ?? 0;\n if (remaining < leftLength) {\n node = node.left;\n continue;\n }\n\n line += node.left?.subtreeLineBreakCount ?? 0;\n remaining -= leftLength;\n if (remaining <= node.piece.length) {\n const buffer = this.#bufferFor(node.piece.source);\n line +=\n upperBound(buffer.lineOffsets, node.piece.offset + remaining) -\n node.piece.lineOffsetStart;\n return line;\n }\n\n line += node.piece.lineBreakCount;\n remaining -= node.piece.length;\n node = node.right;\n }\n\n return this.#lineCount - 1;\n }\n\n #lineBreakOffset(lineBreakIndex: number): number {\n let node = this.#root;\n let remaining = lineBreakIndex;\n let documentOffset = 0;\n\n while (node !== null) {\n const leftLineBreakCount = node.left?.subtreeLineBreakCount ?? 0;\n if (remaining < leftLineBreakCount) {\n node = node.left;\n continue;\n }\n\n const leftLength = node.left?.subtreeLength ?? 0;\n documentOffset += leftLength;\n remaining -= leftLineBreakCount;\n\n if (remaining < node.piece.lineBreakCount) {\n const bufferLineOffset = this.#bufferFor(node.piece.source).lineOffsets[\n node.piece.lineOffsetStart + remaining\n ];\n return documentOffset + (bufferLineOffset - node.piece.offset);\n }\n\n documentOffset += node.piece.length;\n remaining -= node.piece.lineBreakCount;\n node = node.right;\n }\n\n return this.#length;\n }\n\n #textFromPieces(): string {\n const chunks: string[] = [];\n this.#forEachPieceSegment((segment) => {\n chunks.push(segment.text.slice(segment.start, segment.end));\n });\n return chunks.join('');\n }\n\n #forEachPieceSegment(\n callback: (segment: {\n readonly start: number;\n readonly end: number;\n readonly text: string;\n readonly lineOffsets: number[];\n readonly lineOffsetStart: number;\n readonly lineOffsetEnd: number;\n }) => boolean | void\n ): void {\n this.#walk(this.#root, (node) => {\n const buffer = this.#bufferFor(node.piece.source);\n return callback({\n text: buffer.text,\n lineOffsets: buffer.lineOffsets,\n lineOffsetStart: node.piece.lineOffsetStart,\n lineOffsetEnd: node.piece.lineOffsetEnd,\n start: node.piece.offset,\n end: node.piece.offset + node.piece.length,\n });\n });\n }\n\n #bufferFor(source: number): TextBuffer {\n return source === Piece.Original ? this.#original : this.#add;\n }\n\n #createPiece(source: number, offset: number, length: number): Piece {\n const buffer = this.#bufferFor(source);\n return new Piece(\n source,\n offset,\n length,\n upperBound(buffer.lineOffsets, offset),\n upperBound(buffer.lineOffsets, offset + length)\n );\n }\n\n #pieces(): Piece[] {\n return this.#piecesCache;\n }\n\n #setPieces(pieces: Piece[]): void {\n const coalescedPieces = coalescePieces(pieces);\n this.#piecesCache = coalescedPieces;\n let length = 0;\n let lineBreakCount = 0;\n for (const piece of coalescedPieces) {\n length += piece.length;\n lineBreakCount += piece.lineBreakCount;\n }\n this.#root = this.#buildBalancedTree(\n coalescedPieces,\n 0,\n coalescedPieces.length,\n null\n );\n this.#length = length;\n this.#lineCount = lineBreakCount + 1;\n }\n\n #buildBalancedTree(\n pieces: Piece[],\n start: number,\n end: number,\n parent: PieceNode | null\n ): PieceNode | null {\n if (start >= end) {\n return null;\n }\n\n const middle = start + Math.floor((end - start) / 2);\n const node = new PieceNode(pieces[middle]);\n node.parent = parent;\n node.left = this.#buildBalancedTree(pieces, start, middle, node);\n node.right = this.#buildBalancedTree(pieces, middle + 1, end, node);\n node.updateSubtreeLength();\n return node;\n }\n\n #walk(\n node: PieceNode | null,\n visit: (node: PieceNode) => boolean | void\n ): boolean {\n if (node === null) {\n return true;\n }\n if (!this.#walk(node.left, visit)) {\n return false;\n }\n if (visit(node) === false) {\n return false;\n }\n return this.#walk(node.right, visit);\n }\n}\n\nfunction isEOL(charCode: number): boolean {\n return charCode === /* \\n */ 10 || charCode === /* \\r */ 13;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction createPrefixTable(text: string): number[] {\n const table = Array.from<number>({ length: text.length }).fill(0);\n let matched = 0;\n for (let i = 1; i < text.length; i++) {\n const charCode = text.charCodeAt(i);\n while (matched > 0 && charCode !== text.charCodeAt(matched)) {\n matched = table[matched - 1];\n }\n if (charCode === text.charCodeAt(matched)) {\n matched++;\n }\n table[i] = matched;\n }\n return table;\n}\n\nfunction normalizeRanges(\n ranges: readonly [start: number, end: number][],\n length: number\n): [start: number, end: number][] {\n const normalized: [start: number, end: number][] = [];\n for (const [rawStart, rawEnd] of ranges) {\n const start = clamp(rawStart, 0, length);\n const end = clamp(rawEnd, start, length);\n if (start < end) {\n normalized.push([start, end]);\n }\n }\n normalized.sort((a, b) => a[0] - b[0]);\n\n const merged: [start: number, end: number][] = [];\n for (const range of normalized) {\n const previous = merged[merged.length - 1];\n if (previous !== undefined && range[0] <= previous[1]) {\n previous[1] = Math.max(previous[1], range[1]);\n continue;\n }\n merged.push(range);\n }\n return merged;\n}\n\nfunction rangeOverlaps(\n ranges: readonly [start: number, end: number][],\n start: number,\n end: number\n): boolean {\n let low = 0;\n let high = ranges.length;\n while (low < high) {\n const mid = low + Math.floor((high - low) / 2);\n if (ranges[mid][1] <= start) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n\n const range = ranges[low];\n return range !== undefined && range[0] < end;\n}\n\n// Keeps the table compact after repeated edits by joining neighboring pieces\n// that already point at contiguous text in the same backing buffer.\nfunction coalescePieces(pieces: Piece[]): Piece[] {\n const coalescedPieces: Piece[] = [];\n for (const piece of pieces) {\n if (piece.length === 0) {\n continue;\n }\n\n const previous = coalescedPieces[coalescedPieces.length - 1];\n if (\n previous !== undefined &&\n previous.source === piece.source &&\n previous.offset + previous.length === piece.offset\n ) {\n coalescedPieces[coalescedPieces.length - 1] = new Piece(\n previous.source,\n previous.offset,\n previous.length + piece.length,\n previous.lineOffsetStart,\n piece.lineOffsetEnd\n );\n continue;\n }\n\n coalescedPieces.push(piece);\n }\n return coalescedPieces;\n}\n\n// Returns the index of the first element in the array that is greater than the target.\nfunction upperBound(values: number[], target: number): number {\n let lo = 0;\n let hi = values.length;\n while (lo < hi) {\n const mid = lo + Math.floor((hi - lo) / 2);\n if (values[mid] <= target) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n return lo;\n}\n\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction isWordSeparatorCharCode(charCode: number): boolean {\n if (charCode <= 32 || charCode === 127) {\n return true;\n }\n const ch = String.fromCharCode(charCode);\n return WORD_SEPARATORS.includes(ch);\n}\n\n// Checks if the given text is a whole word by checking if the\n// characters before and after are word separators.\nfunction isWholeWordAtDocOffsets(\n docStart: number,\n length: number,\n docLength: number,\n charAt: (offset: number) => string\n): boolean {\n const beforeOk =\n docStart <= 0 ||\n isWordSeparatorCharCode(charCodeUnitAt(charAt, docStart - 1));\n const afterOk =\n docStart + length >= docLength ||\n isWordSeparatorCharCode(charCodeUnitAt(charAt, docStart + length));\n return beforeOk && afterOk;\n}\n\nfunction charCodeUnitAt(\n charAt: (offset: number) => string,\n offset: number\n): number {\n const unit = charAt(offset);\n return unit.length === 0 ? 0 : unit.charCodeAt(0);\n}\n\nfunction compileSearchRegExp(\n source: string,\n isRegex: boolean,\n caseSensitive: boolean\n): RegExp {\n const body = isRegex ? source : escapeRegExp(source);\n const flags = `g${caseSensitive ? '' : 'i'}${isRegex ? 'm' : ''}`;\n return new RegExp(body, flags);\n}\n\n/** Expands `$&`, `$1`, `$$`, etc. in a regex replace string using a match. */\nfunction expandReplaceString(\n replacement: string,\n match: RegExpExecArray\n): string {\n return replacement.replace(/\\$([$&]|\\d+)/g, (_token, group: string) => {\n if (group === '$') {\n return '$';\n }\n if (group === '&') {\n return match[0] ?? '';\n }\n const index = Number(group);\n return match[index] ?? '';\n });\n}\n\n/**\n * Builds the text to insert for one search match, including regex capture\n * substitution when regex mode is enabled.\n */\nexport function buildSearchReplacementText(\n positionAt: (offset: number) => Position,\n offsetAt: (position: Position) => number,\n getLineText: (line: number) => string,\n searchParams: SearchParams,\n matchStart: number,\n matchEnd: number\n): string {\n if (!searchParams.regex) {\n return searchParams.replaceText;\n }\n\n const position = positionAt(matchStart);\n const lineText = getLineText(position.line);\n const lineStart = offsetAt({ line: position.line, character: 0 });\n const relStart = matchStart - lineStart;\n const matched = lineText.slice(relStart, relStart + (matchEnd - matchStart));\n\n let pattern: RegExp;\n try {\n pattern = compileSearchRegExp(\n searchParams.text,\n true,\n searchParams.caseSensitive\n );\n } catch {\n return searchParams.replaceText;\n }\n\n const re = new RegExp(pattern.source, pattern.flags.replace('g', ''));\n const match = re.exec(matched);\n if (match === null || match[0].length !== matched.length) {\n return searchParams.replaceText;\n }\n return expandReplaceString(searchParams.replaceText, match);\n}\n\nfunction advancePastEmptyMatch(text: string, index: number): number {\n if (index + 1 < text.length) {\n const first = text.charCodeAt(index);\n const second = text.charCodeAt(index + 1);\n if (\n first >= 0xd800 &&\n first <= 0xdbff &&\n second >= 0xdc00 &&\n second <= 0xdfff\n ) {\n return index + 2;\n }\n }\n return index + 1;\n}\n"],"mappings":";;;AAIA,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB;AAGxB,IAAM,QAAN,MAAY;CACV,OAAO,WAAW;CAClB,OAAO,QAAQ;CAEf,YACE,AAAgBA,QAChB,AAAgBC,QAChB,AAAgBC,QAChB,AAAgBC,iBAChB,AAAgBC,eAChB;EALgB;EACA;EACA;EACA;EACA;;CAGlB,IAAI,iBAAyB;AAC3B,SAAO,KAAK,gBAAgB,KAAK;;;AAKrC,IAAM,aAAN,MAAiB;CACf;CAEA,YAAY,AAAOC,MAAc;EAAd;AACjB,OAAK,cAAc,mBAAmB,KAAK;;CAK7C,OAAO,MAAsB;EAC3B,MAAM,SAAS,KAAK,KAAK;EACzB,MAAM,sBAAsB,mBAAmB,KAAK;AACpD,OAAK,IAAI,IAAI,GAAG,IAAI,oBAAoB,QAAQ,IAC9C,MAAK,YAAY,KAAK,SAAS,oBAAoB,GAAG;AAExD,OAAK,QAAQ;AACb,SAAO;;;AAKX,IAAM,YAAN,MAAgB;CACd,OAAyB;CACzB,QAA0B;CAC1B,SAA2B;CAE3B,YACE,AAAOC,OACP,AAAOC,gBAAwB,MAAM,QACrC,AAAOC,wBAAgC,MAAM,gBAC7C;EAHO;EACA;EACA;;CAGT,sBAA4B;AAC1B,OAAK,iBACF,KAAK,MAAM,iBAAiB,KAC7B,KAAK,MAAM,UACV,KAAK,OAAO,iBAAiB;AAChC,OAAK,yBACF,KAAK,MAAM,yBAAyB,KACrC,KAAK,MAAM,kBACV,KAAK,OAAO,yBAAyB;;;;;;;;;AAU5C,IAAa,aAAb,MAAwB;CACtB;CACA,OAAO,IAAI,WAAW,GAAG;CACzB,QAA0B;CAC1B,eAAwB,EAAE;CAC1B,U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,aAAa,aAAa,MAAM;;AAG7D,SAAS,sBAAsB,MAAc,OAAuB;AAClE,KAAI,QAAQ,IAAI,KAAK,QAAQ;EAC3B,MAAM,QAAQ,KAAK,WAAW,MAAM;EACpC,MAAM,SAAS,KAAK,WAAW,QAAQ,EAAE;AACzC,MACE,SAAS,SACT,SAAS,SACT,UAAU,SACV,UAAU,MAEV,QAAO,QAAQ;;AAGnB,QAAO,QAAQ"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { TextDocument } from "./textDocument.js";
|
|
1
|
+
import { ResolvedTextEdit, TextDocument } from "./textDocument.js";
|
|
2
2
|
|
|
3
3
|
//#region src/editor/searchPanel.d.ts
|
|
4
4
|
type MatchRange = [startOffset: number, endOffset: number];
|
|
5
|
+
type SearchPanelMode = 'find' | 'replace';
|
|
5
6
|
interface SearchParams {
|
|
6
7
|
text: string;
|
|
7
8
|
replaceText: string;
|
|
@@ -13,17 +14,25 @@ interface SearchPanelOptions {
|
|
|
13
14
|
textDocument: TextDocument<unknown>;
|
|
14
15
|
containerElement: HTMLElement;
|
|
15
16
|
defaultQuery: string;
|
|
17
|
+
mode?: SearchPanelMode;
|
|
16
18
|
initialMatch?: MatchRange;
|
|
17
19
|
scrollToMatch: (nextMatch: MatchRange, retainFocus: boolean) => void;
|
|
18
|
-
|
|
20
|
+
applyReplace: (edits: ResolvedTextEdit[]) => void;
|
|
21
|
+
onUpdate: (matches: MatchRange[], options?: {
|
|
22
|
+
syncSelection?: boolean;
|
|
23
|
+
}) => MatchRange | undefined;
|
|
19
24
|
onClose: () => void;
|
|
20
25
|
}
|
|
21
26
|
declare class SearchPanelWidget {
|
|
22
27
|
#private;
|
|
23
28
|
constructor(options: SearchPanelOptions);
|
|
24
29
|
focus(): void;
|
|
30
|
+
updateMatches(options?: {
|
|
31
|
+
syncSelection?: boolean;
|
|
32
|
+
}): void;
|
|
33
|
+
setMode(mode: SearchPanelMode): void;
|
|
25
34
|
cleanup(): void;
|
|
26
35
|
}
|
|
27
36
|
//#endregion
|
|
28
|
-
export { MatchRange, SearchPanelOptions, SearchPanelWidget, SearchParams };
|
|
37
|
+
export { MatchRange, SearchPanelMode, SearchPanelOptions, SearchPanelWidget, SearchParams };
|
|
29
38
|
//# sourceMappingURL=searchPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchPanel.d.ts","names":["TextDocument","MatchRange","SearchParams","SearchPanelOptions","HTMLElement","SearchPanelWidget"],"sources":["../../src/editor/searchPanel.d.ts"],"sourcesContent":["import type { TextDocument } from './textDocument';\nexport type MatchRange = [startOffset: number, endOffset: number];\nexport interface SearchParams {\n text: string;\n replaceText: string;\n caseSensitive: boolean;\n wholeWord: boolean;\n regex: boolean;\n}\nexport interface SearchPanelOptions {\n textDocument: TextDocument<unknown>;\n containerElement: HTMLElement;\n defaultQuery: string;\n initialMatch?: MatchRange;\n scrollToMatch: (nextMatch: MatchRange, retainFocus: boolean) => void;\n onUpdate: (matches: MatchRange[]) => MatchRange | undefined;\n onClose: () => void;\n}\nexport declare class SearchPanelWidget {\n #private;\n constructor(options: SearchPanelOptions);\n focus(): void;\n cleanup(): void;\n}\n//# sourceMappingURL=searchPanel.d.ts.map"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"searchPanel.d.ts","names":["ResolvedTextEdit","TextDocument","MatchRange","SearchPanelMode","SearchParams","SearchPanelOptions","HTMLElement","SearchPanelWidget"],"sources":["../../src/editor/searchPanel.d.ts"],"sourcesContent":["import type { ResolvedTextEdit, TextDocument } from './textDocument';\nexport type MatchRange = [startOffset: number, endOffset: number];\nexport type SearchPanelMode = 'find' | 'replace';\nexport interface SearchParams {\n text: string;\n replaceText: string;\n caseSensitive: boolean;\n wholeWord: boolean;\n regex: boolean;\n}\nexport interface SearchPanelOptions {\n textDocument: TextDocument<unknown>;\n containerElement: HTMLElement;\n defaultQuery: string;\n mode?: SearchPanelMode;\n initialMatch?: MatchRange;\n scrollToMatch: (nextMatch: MatchRange, retainFocus: boolean) => void;\n applyReplace: (edits: ResolvedTextEdit[]) => void;\n onUpdate: (matches: MatchRange[], options?: {\n syncSelection?: boolean;\n }) => MatchRange | undefined;\n onClose: () => void;\n}\nexport declare class SearchPanelWidget {\n #private;\n constructor(options: SearchPanelOptions);\n focus(): void;\n updateMatches(options?: {\n syncSelection?: boolean;\n }): void;\n setMode(mode: SearchPanelMode): void;\n cleanup(): void;\n}\n//# sourceMappingURL=searchPanel.d.ts.map"],"mappings":";;;KACYE,UAAAA;KACAC,eAAAA;AADAD,UAEKE,YAAAA,CAFK;EACVD,IAAAA,EAAAA,MAAAA;EACKC,WAAAA,EAAAA,MAAY;EAOZC,aAAAA,EAAAA,OAAkB;EACjBJ,SAAAA,EAAAA,OAAAA;EACIK,KAAAA,EAAAA,OAAAA;;AAGHJ,UALFG,kBAAAA,CAKEH;EACYA,YAAAA,EALbD,YAKaC,CAAAA,OAAAA,CAAAA;EACLF,gBAAAA,EALJM,WAKIN;EACFE,YAAAA,EAAAA,MAAAA;EAEdA,IAAAA,CAAAA,EANCC,eAMDD;EAAU,YAAA,CAAA,EALDA,UAKC;EAGCK,aAAAA,EAAAA,CAAAA,SAAiB,EAPPL,UASNG,EAAAA,WAAAA,EAAAA,OAKPF,EAAAA,GAAAA,IAAAA;wBAbQH;sBACFE;;QAEdA;;;cAGWK,iBAAAA;;uBAEIF;;;;;gBAKPF"}
|