@pierre/diffs 1.3.0-beta.1 → 1.3.0-beta.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.
Files changed (82) hide show
  1. package/dist/components/CodeView.d.ts +4 -0
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +38 -0
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts.map +1 -1
  6. package/dist/components/File.js +9 -9
  7. package/dist/components/File.js.map +1 -1
  8. package/dist/components/FileDiff.d.ts.map +1 -1
  9. package/dist/components/FileDiff.js +3 -2
  10. package/dist/components/FileDiff.js.map +1 -1
  11. package/dist/components/VirtualizedFile.js +6 -1
  12. package/dist/components/VirtualizedFile.js.map +1 -1
  13. package/dist/components/VirtualizedFileDiff.js +22 -42
  14. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  15. package/dist/components/Virtualizer.js +5 -3
  16. package/dist/components/Virtualizer.js.map +1 -1
  17. package/dist/editor/editor.d.ts +7 -1
  18. package/dist/editor/editor.d.ts.map +1 -1
  19. package/dist/editor/editor.js +550 -405
  20. package/dist/editor/editor.js.map +1 -1
  21. package/dist/editor/editor2.js +6 -0
  22. package/dist/editor/editor2.js.map +1 -0
  23. package/dist/editor/pieceTable.d.ts +1 -1
  24. package/dist/editor/pieceTable.d.ts.map +1 -1
  25. package/dist/editor/pieceTable.js +2 -22
  26. package/dist/editor/pieceTable.js.map +1 -1
  27. package/dist/editor/quickEdit.js +2 -4
  28. package/dist/editor/quickEdit.js.map +1 -1
  29. package/dist/editor/searchPanel.d.ts +6 -7
  30. package/dist/editor/searchPanel.d.ts.map +1 -1
  31. package/dist/editor/searchPanel.js +102 -137
  32. package/dist/editor/searchPanel.js.map +1 -1
  33. package/dist/editor/selection.js +8 -2
  34. package/dist/editor/selection.js.map +1 -1
  35. package/dist/editor/sprite.d.ts +7 -0
  36. package/dist/editor/sprite.d.ts.map +1 -0
  37. package/dist/editor/sprite.js +38 -0
  38. package/dist/editor/sprite.js.map +1 -0
  39. package/dist/editor/textDocument.d.ts +1 -1
  40. package/dist/editor/textDocument.d.ts.map +1 -1
  41. package/dist/editor/textDocument.js +2 -2
  42. package/dist/editor/textDocument.js.map +1 -1
  43. package/dist/editor/textMeasure.js +3 -3
  44. package/dist/editor/textMeasure.js.map +1 -1
  45. package/dist/editor/tokenzier.d.ts +6 -2
  46. package/dist/editor/tokenzier.d.ts.map +1 -1
  47. package/dist/editor/tokenzier.js +127 -85
  48. package/dist/editor/tokenzier.js.map +1 -1
  49. package/dist/index.d.ts +2 -2
  50. package/dist/react/index.d.ts +2 -2
  51. package/dist/react/jsx.d.ts +1 -0
  52. package/dist/react/jsx.d.ts.map +1 -1
  53. package/dist/react/types.js +1 -0
  54. package/dist/renderers/DiffHunksRenderer.js +5 -9
  55. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  56. package/dist/ssr/index.d.ts +2 -2
  57. package/dist/style.js +1 -1
  58. package/dist/style.js.map +1 -1
  59. package/dist/types.d.ts +13 -12
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/utils/computeEstimatedDiffHeights.js +9 -20
  62. package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
  63. package/dist/utils/iterateOverDiff.js +147 -182
  64. package/dist/utils/iterateOverDiff.js.map +1 -1
  65. package/dist/utils/virtualDiffLayout.d.ts +23 -2
  66. package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
  67. package/dist/utils/virtualDiffLayout.js +41 -1
  68. package/dist/utils/virtualDiffLayout.js.map +1 -1
  69. package/dist/worker/WorkerPoolManager.js +1 -1
  70. package/dist/worker/WorkerPoolManager.js.map +1 -1
  71. package/dist/worker/{wasm-D4DU5jgR.js → wasm-BaDzIkIn.js} +2 -2
  72. package/dist/worker/wasm-BaDzIkIn.js.map +1 -0
  73. package/dist/worker/worker-portable.js +294 -292
  74. package/dist/worker/worker-portable.js.map +1 -1
  75. package/dist/worker/worker.js +179 -181
  76. package/dist/worker/worker.js.map +1 -1
  77. package/package.json +22 -21
  78. package/dist/editor/css.d.ts +0 -6
  79. package/dist/editor/css.d.ts.map +0 -1
  80. package/dist/editor/css.js +0 -218
  81. package/dist/editor/css.js.map +0 -1
  82. package/dist/worker/wasm-D4DU5jgR.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"selection.js","names":["edits: TextEdit[]","newSelection: EditorSelection","selectionPositions: Position[]","ordered: Array<{\n index: number;\n start: number;\n end: number;\n }>","edits: ResolvedTextEdit[]","nextSelectionOffsets: Array<[number, number] | undefined>","mergedGroup:\n | {\n start: number;\n end: number;\n indices: number[];\n }\n | undefined","nextOffsets: [number, number]","ordered: Array<{\n index: number;\n start: number;\n end: number;\n text: string;\n }>","nextSelectionOffsets: number[]","nextOffsetPairs: Array<[number, number]>","edit: ResolvedTextEdit | undefined","deleteSelections: EditorSelection[]","accepted: {\n index: number;\n selection: EditorSelection;\n }[]","last: HTMLElement | null","lastTextNode: Text | null","normalizedOffsets: number[]","lineEl: HTMLElement | null","tokens: HTMLElement[]","stack: Array<{ container: Node; index: number }>","current: Node | null","offset","target: HTMLElement | null","current: HTMLElement | null","base"],"sources":["../../src/editor/selection.ts"],"sourcesContent":["import type { DiffLineAnnotation } from '../types';\nimport { applyDocumentChangeToLineAnnotations } from './lineAnnotations';\nimport type {\n Position,\n Range,\n ResolvedTextEdit,\n TextDocument,\n TextDocumentChange,\n TextEdit,\n} from './textDocument';\n\nexport const DirectionBackward = -1;\nexport const DirectionNone = 0;\nexport const DirectionForward = 1;\n\nexport type SelectionDirection =\n | typeof DirectionBackward\n | typeof DirectionNone\n | typeof DirectionForward;\n\nexport interface EditorSelection extends Range {\n direction: SelectionDirection;\n}\n\n/**\n * Converts a selection from a web selection to an editor selection.\n */\nexport function convertSelection(\n range: StaticRange,\n direction: SelectionDirection = DirectionNone\n): EditorSelection | undefined {\n const start = boundaryToPosition(range.startContainer, range.startOffset);\n const end = boundaryToPosition(range.endContainer, range.endOffset);\n if (start === null || end === null) {\n return undefined;\n }\n return {\n start,\n end,\n direction,\n };\n}\n\n/**\n * Resolves the indent edits for a selection.\n */\nexport function resolveIndentEdits(\n textDocument: TextDocument<unknown>,\n selection: EditorSelection,\n tabSize: number,\n outdent: boolean\n): [edits: TextEdit[], nextSelection: EditorSelection] {\n if (textDocument === undefined) {\n return [[], selection];\n }\n const { start, end } = selection;\n const edits: TextEdit[] = [];\n let newSelection: EditorSelection = { ...selection };\n let endLine = end.line;\n if (start.line < end.line && end.character === 0) {\n endLine--;\n }\n for (let line = start.line; line <= endLine; line++) {\n const lineText = textDocument.getLineText(line);\n if (lineText === undefined) {\n continue;\n }\n const indentUnit = lineText.startsWith('\\t') ? '\\t' : ' '.repeat(tabSize);\n let deleteLength = 0;\n let newText = indentUnit;\n if (outdent) {\n if (lineText.startsWith('\\t')) {\n deleteLength = 1;\n } else if (lineText.startsWith(' ')) {\n const leadingSpacesLength =\n lineText.length - lineText.trimStart().length;\n deleteLength = Math.min(indentUnit.length, leadingSpacesLength);\n }\n if (deleteLength === 0) {\n continue;\n }\n newText = '';\n }\n edits.push({\n range: {\n start: { line, character: 0 },\n end: { line, character: deleteLength },\n },\n newText,\n });\n const delta = newText.length - deleteLength;\n if (line === start.line) {\n newSelection = {\n ...newSelection,\n start: {\n ...start,\n character: Math.max(0, start.character + delta),\n },\n };\n }\n if (line === end.line) {\n newSelection = {\n ...newSelection,\n end: {\n ...end,\n character: Math.max(0, end.character + delta),\n },\n };\n }\n }\n return [edits, newSelection];\n}\n\n/**\n * Maps the cursor move to all selections.\n */\nexport function mapCursorMove(\n textDocument: TextDocument<unknown>,\n selections: EditorSelection[],\n shortcut: 'textStart' | 'start' | 'end' | 'up' | 'down' | 'left' | 'right'\n): EditorSelection[] {\n const lineCount = textDocument.lineCount;\n return selections.map((selection) => {\n let { line, character } =\n shortcut === 'up' || shortcut === 'left'\n ? selection.start\n : selection.end;\n if (\n shortcut === 'textStart' ||\n shortcut === 'start' ||\n shortcut === 'end'\n ) {\n if (shortcut === 'textStart') {\n const indent = getLeadingSpaces(textDocument.getLineText(line));\n character = character === indent ? 0 : indent;\n } else {\n character =\n shortcut === 'start' ? 0 : textDocument.getLineText(line).length;\n }\n if (selection.direction === DirectionBackward) {\n line = selection.start.line;\n } else {\n line = selection.end.line;\n }\n } else if (shortcut === 'up') {\n line = Math.max(0, line - 1);\n } else if (shortcut === 'down') {\n line = Math.min(Math.max(lineCount - 1, 0), line + 1);\n } else if (isCollapsedSelection(selection)) {\n if (shortcut === 'left') {\n character--;\n\n if (character < 0) {\n if (line === 0) {\n character = 0;\n } else {\n line = Math.max(0, line - 1);\n character = textDocument.getLineText(line).length;\n }\n }\n } else {\n character++;\n if (character > textDocument.getLineText(line).length) {\n if (line === lineCount - 1) {\n character--;\n } else {\n line = Math.min(Math.max(lineCount - 1, 0), line + 1);\n character = 0;\n }\n }\n }\n }\n const pos = { line, character };\n return {\n start: pos,\n end: pos,\n direction: DirectionNone,\n };\n });\n}\n\n/**\n * Same as mapCursorMove, but with shift key pressed.\n */\nexport function mapSelectionShift(\n textDocument: TextDocument<unknown>,\n selections: EditorSelection[],\n shortcut: 'textStart' | 'start' | 'end' | 'up' | 'down' | 'left' | 'right'\n): EditorSelection[] {\n return selections.map((selection) => {\n const [anchorOffset, focusOffset] = getSelectionAnchorAndFocusOffsets(\n textDocument,\n selection\n );\n const focusPosition = textDocument.positionAt(focusOffset);\n const [movedFocusSelection] = mapCursorMove(\n textDocument,\n [\n {\n start: focusPosition,\n end: focusPosition,\n direction: DirectionNone,\n },\n ],\n shortcut\n );\n const movedFocusOffset = textDocument.offsetAt(movedFocusSelection.start);\n return createSelectionFromAnchorAndFocusOffsets(\n textDocument,\n anchorOffset,\n movedFocusOffset\n );\n });\n}\n\n/**\n * Applies a text change to the given text document\n */\nexport function applyTextChangeToSelections<LAnnotation>(\n textDocument: TextDocument<LAnnotation>,\n selections: EditorSelection[],\n edit: ResolvedTextEdit,\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[],\n tabSize = 2\n): {\n nextSelections: EditorSelection[];\n change?: TextDocumentChange;\n} {\n const primarySelection = selections[selections.length - 1];\n if (primarySelection === undefined) {\n return { nextSelections: [] };\n }\n const selectionPositions: Position[] = [];\n for (const selection of selections) {\n selectionPositions.push(selection.start, selection.end);\n }\n const selectionOffsets = textDocument.offsetsAt(selectionPositions);\n const primaryStartOffset = selectionOffsets[(selections.length - 1) * 2];\n const primaryEndOffset = selectionOffsets[(selections.length - 1) * 2 + 1];\n const ordered: Array<{\n index: number;\n start: number;\n end: number;\n }> = [];\n let isAlreadyOrdered = true;\n for (let index = 0; index < selections.length; index++) {\n const entry = {\n index,\n start: selectionOffsets[index * 2],\n end: selectionOffsets[index * 2 + 1],\n };\n const previous = ordered[ordered.length - 1];\n if (\n previous !== undefined &&\n (entry.start < previous.start ||\n (entry.start === previous.start && entry.end < previous.end))\n ) {\n isAlreadyOrdered = false;\n }\n ordered.push(entry);\n }\n if (!isAlreadyOrdered) {\n ordered.sort((a, b) => {\n const startOrder = a.start - b.start;\n if (startOrder !== 0) {\n return startOrder;\n }\n const endOrder = a.end - b.end;\n if (endOrder !== 0) {\n return endOrder;\n }\n return a.index - b.index;\n });\n }\n const adjustedChange = normalizeLeadingIndentForChange(\n textDocument,\n edit,\n tabSize\n );\n const edits: ResolvedTextEdit[] = [];\n const nextSelectionOffsets: Array<[number, number] | undefined> = Array.from({\n length: selections.length,\n });\n let offsetDelta = 0;\n let mergedGroup:\n | {\n start: number;\n end: number;\n indices: number[];\n }\n | undefined;\n const finalizeMergedGroup = () => {\n if (mergedGroup === undefined) {\n return;\n }\n const perGroupChange = normalizeLeadingIndentForChange(\n textDocument,\n {\n start: mergedGroup.start,\n end: mergedGroup.end,\n text: adjustedChange.text,\n },\n tabSize\n );\n const newText = expandSingleNewlineInsert(\n textDocument,\n perGroupChange.text,\n perGroupChange.start\n );\n edits.push({\n start: perGroupChange.start,\n end: perGroupChange.end,\n text: newText,\n });\n const nextOffsets: [number, number] = [\n mergedGroup.start + offsetDelta + newText.length,\n mergedGroup.start + offsetDelta + newText.length,\n ];\n for (const index of mergedGroup.indices) {\n nextSelectionOffsets[index] = nextOffsets;\n }\n offsetDelta += newText.length - (perGroupChange.end - perGroupChange.start);\n mergedGroup = undefined;\n };\n for (const entry of ordered) {\n const startOffset = Math.max(\n 0,\n entry.start + (adjustedChange.start - primaryStartOffset)\n );\n const endOffset = Math.max(\n startOffset,\n entry.end + (adjustedChange.end - primaryEndOffset)\n );\n if (mergedGroup !== undefined && startOffset < mergedGroup.end) {\n mergedGroup.end = Math.max(mergedGroup.end, endOffset);\n mergedGroup.indices.push(entry.index);\n continue;\n }\n finalizeMergedGroup();\n mergedGroup = {\n start: startOffset,\n end: endOffset,\n indices: [entry.index],\n };\n }\n finalizeMergedGroup();\n\n const change = textDocument.applyResolvedEdits(edits, true, selections);\n const nextSelections = createSelectionsFromOffsetPairs(\n textDocument,\n nextSelectionOffsets.map((offsets) => {\n if (offsets === undefined) {\n throw new Error('Missing next selection offsets');\n }\n return offsets;\n })\n );\n textDocument.setLastUndoSelectionsAfter(nextSelections);\n if (change !== undefined && lineAnnotations !== undefined) {\n const nextLineAnnotations =\n applyDocumentChangeToLineAnnotations<LAnnotation>(\n change,\n lineAnnotations\n );\n if (nextLineAnnotations !== undefined) {\n textDocument.setLastUndoLineAnnotations(\n lineAnnotations,\n nextLineAnnotations\n );\n }\n }\n return { nextSelections, change };\n}\n\n/**\n * Applies a text replace to multiple selections.\n */\nexport function applyTextReplaceToSelections<LAnnotation>(\n textDocument: TextDocument<LAnnotation>,\n selections: EditorSelection[],\n texts: string[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n): {\n nextSelections: EditorSelection[];\n change?: TextDocumentChange;\n} {\n if (selections.length !== texts.length) {\n throw new Error(\n 'Selection text replacements must match the selection count'\n );\n }\n const selectionPositions: Position[] = [];\n for (const selection of selections) {\n selectionPositions.push(selection.start, selection.end);\n }\n const selectionOffsets = textDocument.offsetsAt(selectionPositions);\n const ordered: Array<{\n index: number;\n start: number;\n end: number;\n text: string;\n }> = [];\n let isAlreadyOrdered = true;\n for (let index = 0; index < selections.length; index++) {\n const entry = {\n index,\n start: selectionOffsets[index * 2],\n end: selectionOffsets[index * 2 + 1],\n text: texts[index],\n };\n const previous = ordered[ordered.length - 1];\n if (\n previous !== undefined &&\n (entry.start < previous.start ||\n (entry.start === previous.start && entry.end < previous.end))\n ) {\n isAlreadyOrdered = false;\n }\n ordered.push(entry);\n }\n if (!isAlreadyOrdered) {\n ordered.sort((a, b) => {\n const startOrder = a.start - b.start;\n if (startOrder !== 0) {\n return startOrder;\n }\n const endOrder = a.end - b.end;\n if (endOrder !== 0) {\n return endOrder;\n }\n return a.index - b.index;\n });\n }\n const edits: ResolvedTextEdit[] = [];\n const nextSelectionOffsets: number[] = Array.from({\n length: selections.length,\n });\n let offsetDelta = 0;\n let previousEditEnd = -1;\n for (const entry of ordered) {\n if (entry.start < previousEditEnd) {\n throw new Error('Overlapping multi-selection edits are not supported');\n }\n previousEditEnd = entry.end;\n const newText = expandSingleNewlineInsert(\n textDocument,\n entry.text,\n entry.start\n );\n edits.push({\n start: entry.start,\n end: entry.end,\n text: newText,\n });\n nextSelectionOffsets[entry.index] =\n entry.start + offsetDelta + newText.length;\n offsetDelta += newText.length - (entry.end - entry.start);\n }\n\n const change = textDocument.applyResolvedEdits(edits, true, selections);\n const nextSelections = createSelectionsFromOffsetPairs(\n textDocument,\n nextSelectionOffsets.map((offset) => [offset, offset])\n );\n textDocument.setLastUndoSelectionsAfter(nextSelections);\n if (change !== undefined && lineAnnotations !== undefined) {\n const nextLineAnnotations =\n applyDocumentChangeToLineAnnotations<LAnnotation>(\n change,\n lineAnnotations\n );\n if (nextLineAnnotations !== undefined) {\n textDocument.setLastUndoLineAnnotations(\n lineAnnotations,\n nextLineAnnotations\n );\n }\n }\n return { nextSelections, change };\n}\n\n/**\n * Swaps the two characters adjacent to a collapsed selection, matching browser\n * insertTranspose (Ctrl+T) behavior.\n */\nexport function applyTransposeToSelections<LAnnotation>(\n textDocument: TextDocument<LAnnotation>,\n selections: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n): {\n nextSelections: EditorSelection[];\n change?: TextDocumentChange;\n} {\n const text = textDocument.getText();\n const edits: ResolvedTextEdit[] = [];\n const nextOffsetPairs: Array<[number, number]> = [];\n\n for (const selection of selections) {\n const [anchor, focus] = getSelectionAnchorAndFocusOffsets(\n textDocument,\n selection\n );\n if (!isCollapsedSelection(selection)) {\n nextOffsetPairs.push([anchor, focus]);\n continue;\n }\n\n const { line, character } = selection.start;\n const offset = anchor;\n const lineLength = textDocument.getLineText(line).length;\n let edit: ResolvedTextEdit | undefined;\n\n if (character > 0 && character < lineLength) {\n edit = {\n start: offset - 1,\n end: offset + 1,\n text: text[offset] + text[offset - 1],\n };\n nextOffsetPairs.push([offset + 1, offset + 1]);\n } else if (character === lineLength && lineLength >= 2) {\n edit = {\n start: offset - 2,\n end: offset,\n text: text[offset - 1] + text[offset - 2],\n };\n nextOffsetPairs.push([offset, offset]);\n } else if (character === 0 && line > 0 && lineLength > 0) {\n const prevLine = line - 1;\n const prevLength = textDocument.getLineText(prevLine).length;\n const prevEnd = textDocument.offsetAt({\n line: prevLine,\n character: prevLength,\n });\n const prevStart = prevLength > 0 ? prevEnd - 1 : prevEnd;\n edit = {\n start: prevStart,\n end: offset + 1,\n text:\n text[offset] +\n text.slice(prevEnd, offset) +\n text.slice(prevStart, prevEnd),\n };\n nextOffsetPairs.push([offset + 1, offset + 1]);\n } else {\n nextOffsetPairs.push([anchor, focus]);\n continue;\n }\n\n edits.push(edit);\n }\n\n if (edits.length === 0) {\n return { nextSelections: selections };\n }\n\n edits.sort((a, b) => a.start - b.start);\n for (let index = 1; index < edits.length; index++) {\n if (edits[index].start < edits[index - 1].end) {\n throw new Error('Overlapping multi-selection edits are not supported');\n }\n }\n\n const change = textDocument.applyResolvedEdits(edits, true, selections);\n const nextSelections = createSelectionsFromOffsetPairs(\n textDocument,\n nextOffsetPairs\n );\n textDocument.setLastUndoSelectionsAfter(nextSelections);\n if (change !== undefined && lineAnnotations !== undefined) {\n const nextLineAnnotations =\n applyDocumentChangeToLineAnnotations<LAnnotation>(\n change,\n lineAnnotations\n );\n if (nextLineAnnotations !== undefined) {\n textDocument.setLastUndoLineAnnotations(\n lineAnnotations,\n nextLineAnnotations\n );\n }\n }\n return { nextSelections, change };\n}\n\n/**\n * Deletes from each selection to the end of its line, including the line break\n * when the caret is already at the end of a non-final line. Non-collapsed\n * selections delete their selected text instead.\n */\nexport function applyDeleteHardLineForwardToSelections<LAnnotation>(\n textDocument: TextDocument<LAnnotation>,\n selections: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n): {\n nextSelections: EditorSelection[];\n change?: TextDocumentChange;\n} {\n const deleteSelections: EditorSelection[] = selections.map((selection) => {\n const range = resolveDeleteHardLineForwardRange(textDocument, selection);\n const deleteSelection: EditorSelection = {\n start: range.start,\n end: range.end,\n direction: DirectionNone,\n };\n return deleteSelection;\n });\n const hasEffect = deleteSelections.some(\n (selection) => comparePosition(selection.start, selection.end) !== 0\n );\n if (!hasEffect) {\n return { nextSelections: selections };\n }\n return applyTextReplaceToSelections(\n textDocument,\n deleteSelections,\n deleteSelections.map(() => ''),\n lineAnnotations\n );\n}\n\n/**\n * Checks if a selection is collapsed.\n */\nexport function isCollapsedSelection(selection: EditorSelection): boolean {\n return (\n selection.start.line === selection.end.line &&\n selection.start.character === selection.end.character\n );\n}\n\n/**\n * Returns the caret (focus) position for a selection.\n */\nexport function getCaretPosition(selection: EditorSelection): Position {\n const { start, end, direction } = selection;\n return direction === DirectionBackward ? start : end;\n}\n\n/**\n * Checks if a line is editable.\n */\nexport function isLineEditable(lineType: string): boolean {\n return (\n lineType === 'context' ||\n lineType === 'change-addition' ||\n lineType === 'context-expanded'\n );\n}\n\n/**\n * Checks whether selections `a` and `b` intersect.\n */\nexport function selectionIntersects(\n a: EditorSelection,\n b: EditorSelection\n): boolean {\n const aCollapsed = isCollapsedSelection(a);\n const bCollapsed = isCollapsedSelection(b);\n if (aCollapsed && bCollapsed) {\n return comparePosition(a.start, b.start) === 0;\n }\n if (aCollapsed) {\n return (\n comparePosition(b.start, a.start) <= 0 &&\n comparePosition(a.start, b.end) <= 0\n );\n }\n if (bCollapsed) {\n return (\n comparePosition(a.start, b.start) <= 0 &&\n comparePosition(b.start, a.end) <= 0\n );\n }\n return (\n comparePosition(a.start, b.end) < 0 && comparePosition(b.start, a.end) < 0\n );\n}\n\n/**\n * Compares two positions.\n */\nexport function comparePosition(a: Position, b: Position): number {\n if (a.line !== b.line) {\n return a.line - b.line;\n }\n return a.character - b.character;\n}\n\n/**\n * Creates a selection from anchor and focus offsets.\n */\nexport function createSelectionFromAnchorAndFocusOffsets(\n textDocument: TextDocument<unknown>,\n anchorOffset: number,\n focusOffset: number\n): EditorSelection {\n const direction =\n anchorOffset === focusOffset\n ? DirectionNone\n : anchorOffset < focusOffset\n ? DirectionForward\n : DirectionBackward;\n const start = Math.min(anchorOffset, focusOffset);\n const end = Math.max(anchorOffset, focusOffset);\n return {\n start: textDocument.positionAt(start),\n end: textDocument.positionAt(end),\n direction,\n };\n}\n\n/**\n * Creates a selection from a anchor and focus selection.\n */\nexport function createSelectionFrom(\n anchorSelection: EditorSelection,\n focusSelection: EditorSelection\n): EditorSelection {\n const anchor =\n anchorSelection.direction === DirectionBackward\n ? anchorSelection.end\n : anchorSelection.start;\n const currentStartOrder = comparePosition(anchor, focusSelection.start);\n const currentEndOrder = comparePosition(anchor, focusSelection.end);\n let focus = focusSelection.end;\n if (currentStartOrder <= 0) {\n focus = focusSelection.end;\n } else if (currentEndOrder >= 0) {\n focus = focusSelection.start;\n } else {\n // When the original anchor sits inside `current`, keep whichever edge\n // stayed at the anchor so drag direction remains stable.\n focus = currentStartOrder === 0 ? focusSelection.end : focusSelection.start;\n }\n const anchorVsFocus = comparePosition(anchor, focus);\n const direction: SelectionDirection =\n anchorVsFocus === 0\n ? DirectionNone\n : anchorVsFocus < 0\n ? DirectionForward\n : DirectionBackward;\n const selectionStart = anchorVsFocus <= 0 ? anchor : focus;\n const selectionEnd = anchorVsFocus <= 0 ? focus : anchor;\n return {\n start: selectionStart,\n end: selectionEnd,\n direction,\n };\n}\n\n/**\n * Extends or shrinks the selection `original` using the endpoints of `target`, \\\n * matching contenteditable shift + click extend behavior.\n */\nexport function extendSelection(\n original: EditorSelection,\n target: EditorSelection\n): EditorSelection {\n const leftExtended = comparePosition(target.start, original.start) < 0;\n const rightExtended = comparePosition(target.end, original.end) > 0;\n\n if (leftExtended && !rightExtended) {\n return {\n start: target.start,\n end: original.end,\n direction: DirectionBackward,\n };\n }\n\n if (rightExtended && !leftExtended) {\n return {\n start: original.start,\n end: target.end,\n direction: DirectionForward,\n };\n }\n\n if (original.direction === DirectionBackward) {\n return {\n start: target.start,\n end: original.end,\n direction:\n comparePosition(target.start, original.end) === 0\n ? DirectionNone\n : DirectionBackward,\n };\n }\n\n return {\n start: original.start,\n end: target.end,\n direction:\n comparePosition(original.start, target.end) === 0\n ? DirectionNone\n : DirectionForward,\n };\n}\n\n/**\n * Extends multiple selections.\n */\nexport function extendSelections(\n selections: EditorSelection[],\n target: EditorSelection\n): EditorSelection[] {\n const newSelections = selections.map((selection) => {\n return extendSelection(selection, target);\n });\n return mergeOverlappingSelections(newSelections);\n}\n\n/**\n * Merges overlapping selections.\n */\nexport function mergeOverlappingSelections(\n selections: EditorSelection[]\n): EditorSelection[] {\n if (selections.length <= 1) {\n return selections;\n }\n const selected = new Set<number>();\n const accepted: {\n index: number;\n selection: EditorSelection;\n }[] = [];\n for (let i = selections.length - 1; i >= 0; i--) {\n const selection = selections[i];\n if (selection === undefined) {\n continue;\n }\n let left = 0;\n let right = accepted.length;\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n const candidate = accepted[mid]?.selection;\n if (candidate === undefined) {\n break;\n }\n if (comparePosition(candidate.start, selection.start) < 0) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n const previous = accepted[left - 1]?.selection;\n const next = accepted[left]?.selection;\n if (\n (previous !== undefined && selectionIntersects(previous, selection)) ||\n (next !== undefined && selectionIntersects(next, selection))\n ) {\n continue;\n }\n accepted.splice(left, 0, { index: i, selection });\n selected.add(i);\n }\n return selections.filter((_, index) => selected.has(index));\n}\n\n/**\n * Finds the next matching word and updates the selections.\n */\nexport function findNexMatch(\n textDocument: TextDocument<unknown>,\n selections: EditorSelection[]\n): EditorSelection[] | undefined {\n if (selections.length === 0) {\n return undefined;\n }\n\n const normalizedSelections = selections.map((selection) =>\n isCollapsedSelection(selection)\n ? expandCollapsedSelectionToWord(textDocument, selection)\n : selection\n );\n const texts = normalizedSelections.map((s) => textDocument.getText(s));\n const needle = texts[0];\n if (needle.length === 0 || texts.some((t) => t !== needle)) {\n return undefined;\n }\n\n const occupied = normalizedSelections.map(\n (s) =>\n [textDocument.offsetAt(s.start), textDocument.offsetAt(s.end)] as [\n number,\n number,\n ]\n );\n const nextOffset = textDocument.findNextNonOverlappingSubstring(\n needle,\n occupied\n );\n if (nextOffset === undefined) {\n return normalizedSelections.some((selection, index) => {\n const original = selections[index];\n return (\n comparePosition(selection.start, original.start) !== 0 ||\n comparePosition(selection.end, original.end) !== 0 ||\n selection.direction !== original.direction\n );\n })\n ? normalizedSelections\n : undefined;\n }\n const added = createSelectionFromAnchorAndFocusOffsets(\n textDocument,\n nextOffset,\n nextOffset + needle.length\n );\n return [...normalizedSelections, added];\n}\n\n/**\n * Get the full selection of the document.\n */\nexport function getDocumentFullSelection(\n textDocument: TextDocument<unknown>\n): EditorSelection {\n const lastLine = textDocument.lineCount - 1;\n const lastCharacter = textDocument.getLineText(lastLine)?.length ?? 0;\n return {\n start: { line: 0, character: 0 },\n end: { line: lastLine, character: lastCharacter },\n direction: DirectionForward,\n };\n}\n\n/**\n * Get the boundary selection of the document.\n */\nexport function getDocumentBoundarySelection(\n textDocument: TextDocument<unknown>,\n atEnd: boolean\n): EditorSelection {\n const line = atEnd ? textDocument.lineCount - 1 : 0;\n const character = atEnd ? (textDocument.getLineText(line)?.length ?? 0) : 0;\n const start = { line, character };\n return {\n start: start,\n end: start,\n direction: DirectionForward,\n };\n}\n\n/**\n * Get the text of the selections for the given text document.\n */\nexport function getSelectionText(\n textDocument: TextDocument<unknown>,\n selections: EditorSelection[]\n): string {\n return [...selections]\n .sort((a, b) => {\n const startOrder = comparePosition(a.start, b.start);\n if (startOrder !== 0) {\n return startOrder;\n }\n return comparePosition(a.end, b.end);\n })\n .map((selection) => {\n if (isCollapsedSelection(selection)) {\n return textDocument.getLineText(selection.start.line, false);\n }\n return textDocument.getText(selection);\n })\n .join('\\n');\n}\n\n/**\n * Get the anchor node and offset for a selection.\n */\nexport function getSelectionAnchor(\n lineElement: HTMLElement,\n character: number\n): [Node, number] {\n const ch = Math.max(0, character);\n const tokens = collectTokens(lineElement);\n\n let last: HTMLElement | null = null;\n for (const token of tokens) {\n last = token;\n const base = getCharacterIndex(token)!;\n const end = base + (token.textContent?.length ?? 0);\n if (ch <= end) {\n const anchor = textAt(token, ch < base ? 0 : ch - base);\n if (anchor !== null) {\n return anchor;\n }\n }\n }\n\n if (last !== null) {\n const anchor = textAt(last, last.textContent?.length ?? 0);\n if (anchor !== null) {\n return anchor;\n }\n return [last, 0];\n }\n\n let textOffset = 0;\n let lastTextNode: Text | null = null;\n for (const child of lineElement.childNodes) {\n if (child.nodeType === 1 && (child as HTMLElement).tagName === 'BR') {\n return [child, 0];\n }\n if (child.nodeType !== 3) {\n continue;\n }\n lastTextNode = child as Text;\n const len = getTextOffset(\n lastTextNode.textContent,\n lastTextNode.textContent?.length ?? 0\n );\n if (ch <= textOffset + len) {\n return [\n lastTextNode,\n getTextOffset(lastTextNode.textContent, ch - textOffset),\n ];\n }\n textOffset += len;\n }\n\n if (lastTextNode !== null) {\n return [\n lastTextNode,\n getTextOffset(\n lastTextNode.textContent,\n lastTextNode.textContent?.length ?? 0\n ),\n ];\n }\n return [lineElement, 0];\n}\n\n/**\n * Expands a zero-width selection to the word-like segment that contains the caret.\n */\nexport function expandCollapsedSelectionToWord(\n textDocument: TextDocument<unknown>,\n selection: EditorSelection\n): EditorSelection {\n const { line, character } = selection.start;\n const lineText = textDocument.getLineText(line);\n const ch = Math.max(0, Math.min(character, lineText.length));\n const span = expandCollapsedLineWord(lineText, ch);\n if (span === undefined) {\n return selection;\n }\n return {\n start: { line, character: span.start },\n end: { line, character: span.end },\n direction: DirectionForward,\n };\n}\n\nfunction expandCollapsedLineWord(\n lineText: string,\n character: number\n): { start: number; end: number } | undefined {\n const segmenter = new Intl.Segmenter(undefined, {\n granularity: 'word',\n });\n for (const seg of segmenter.segment(lineText)) {\n if (seg.isWordLike !== true) {\n continue;\n }\n const lo = seg.index;\n const hi = lo + seg.segment.length;\n // Match when the cursor is inside the word or immediately touching\n // one of its boundaries — not when separated by non-word characters.\n if (character >= lo && character <= hi) {\n return { start: lo, end: hi };\n }\n }\n return undefined;\n}\n\nfunction getSelectionAnchorAndFocusOffsets(\n textDocument: TextDocument<unknown>,\n selection: EditorSelection\n): [anchorOffset: number, focusOffset: number] {\n const isBackward = selection.direction === DirectionBackward;\n return [\n textDocument.offsetAt(isBackward ? selection.end : selection.start),\n textDocument.offsetAt(getCaretPosition(selection)),\n ];\n}\n\n// Resolves the range removed by deleteHardLineForward for one selection.\nfunction resolveDeleteHardLineForwardRange(\n textDocument: TextDocument<unknown>,\n selection: EditorSelection\n): Range {\n if (!isCollapsedSelection(selection)) {\n return { start: selection.start, end: selection.end };\n }\n const { line, character } = selection.start;\n const lineText = textDocument.getLineText(line);\n const lineLength = lineText.length;\n if (character < lineLength) {\n return {\n start: { line, character },\n end: { line, character: lineLength },\n };\n }\n if (line < textDocument.lineCount - 1) {\n return {\n start: { line, character },\n end: { line: line + 1, character: 0 },\n };\n }\n return {\n start: { line, character },\n end: { line, character },\n };\n}\n\n// When the user inserts a lone line break, copy the current line's indentation onto the new line.\nfunction expandSingleNewlineInsert(\n textDocument: TextDocument<unknown>,\n insertText: string,\n insertStartOffset: number\n): string {\n if (insertText !== '\\n' && insertText !== '\\r\\n') {\n return insertText;\n }\n const line = textDocument.positionAt(insertStartOffset).line;\n const lineText = textDocument.getLineText(line);\n const indentLen = getLeadingSpaces(lineText);\n if (indentLen === 0) {\n return insertText;\n }\n return insertText + lineText.slice(0, indentLen);\n}\n\nfunction getLeadingSpaces(text: string): number {\n let indent = 0;\n for (; indent < text.length; indent++) {\n const c = text.charCodeAt(indent);\n if (c !== /* space */ 32 && c !== /* tab */ 9) {\n break;\n }\n }\n return indent;\n}\n\nfunction createSelectionsFromOffsetPairs(\n textDocument: TextDocument<unknown>,\n offsetPairs: readonly [anchorOffset: number, focusOffset: number][]\n): EditorSelection[] {\n const normalizedOffsets: number[] = [];\n for (const [anchorOffset, focusOffset] of offsetPairs) {\n normalizedOffsets.push(\n Math.min(anchorOffset, focusOffset),\n Math.max(anchorOffset, focusOffset)\n );\n }\n const positions = textDocument.positionsAt(normalizedOffsets);\n return offsetPairs.map(([anchorOffset, focusOffset], index) => {\n const direction =\n anchorOffset === focusOffset\n ? DirectionNone\n : anchorOffset < focusOffset\n ? DirectionForward\n : DirectionBackward;\n return {\n start: positions[index * 2],\n end: positions[index * 2 + 1],\n direction,\n };\n });\n}\n\n// Expands a backspace over leading spaces into one soft-tab width so mixed hard/soft indentation\n// behaves like the explicit outdent command.\nfunction normalizeLeadingIndentForChange(\n textDocument: TextDocument<unknown>,\n change: ResolvedTextEdit,\n tabSize: number\n): ResolvedTextEdit {\n if (change.text !== '' || change.start !== change.end - 1) {\n return change;\n }\n const caretPosition = textDocument.positionAt(change.end);\n if (caretPosition.character === 0) {\n return change;\n }\n const lineText = textDocument.getLineText(caretPosition.line);\n const leadingText = lineText.slice(0, caretPosition.character);\n if (/[^ \\t]/.test(leadingText)) {\n return change;\n }\n if (lineText[caretPosition.character - 1] === '\\t') {\n return change;\n }\n const softTabStart = Math.max(0, caretPosition.character - tabSize);\n const softTabText = lineText.slice(softTabStart, caretPosition.character);\n if (softTabText.length === tabSize && /^ +$/.test(softTabText)) {\n return {\n ...change,\n start: change.end - softTabText.length,\n };\n }\n return change;\n}\n\nfunction boundaryToPosition(node: Node, offset: number): Position | null {\n const host = node.nodeType === 1 ? (node as HTMLElement) : node.parentElement;\n let lineEl: HTMLElement | null = host;\n while (lineEl !== null && getLineIndex(lineEl) === undefined) {\n lineEl = lineEl.parentElement;\n }\n if (lineEl === null) {\n return null;\n }\n const line = getLineIndex(lineEl);\n if (line === undefined) {\n return null;\n }\n\n if (node.nodeType === 3) {\n if (node.parentElement === null) {\n return null;\n }\n if (findTokenSpan(node.parentElement) !== null) {\n return { line, character: getLineChildEnd(node, offset) };\n }\n return {\n line,\n character:\n offsetBefore(lineEl, node) + getTextOffset(node.textContent, offset),\n };\n }\n\n if (node.nodeType === 1) {\n const el = node as HTMLElement;\n if (el.tagName === 'DIV') {\n let character = 0;\n for (let i = 0; i < offset; i++) {\n character = getLineChildEnd(el.childNodes[i]);\n }\n return { line, character };\n }\n if (el.tagName === 'BR') {\n return { line, character: 0 };\n }\n if (el.tagName === 'SPAN') {\n if (offset < el.childNodes.length) {\n const next = el.childNodes[offset];\n if (next?.nodeType === 1) {\n const nextBase = getCharacterIndex(next as HTMLElement);\n if (nextBase !== undefined) {\n return { line, character: nextBase };\n }\n const token = findTokenSpan(next as HTMLElement);\n const tokenBase =\n token === null ? undefined : getCharacterIndex(token);\n if (tokenBase !== undefined) {\n return { line, character: tokenBase };\n }\n }\n }\n return {\n line,\n character:\n offset > 0\n ? getLineChildEnd(el.childNodes[offset - 1])\n : offsetBefore(lineEl, el),\n };\n }\n return { line, character: offsetBefore(lineEl, el) };\n }\n return null;\n}\n\nfunction collectTokens(line: HTMLElement): HTMLElement[] {\n const tokens: HTMLElement[] = [];\n for (const child of line.childNodes) {\n if (child.nodeType !== 1) {\n continue;\n }\n const el = child as HTMLElement;\n if (el.tagName !== 'SPAN') {\n continue;\n }\n const base = getCharacterIndex(el);\n if (base !== undefined) {\n tokens.push(el);\n continue;\n }\n for (const nested of el.childNodes) {\n if (\n nested.nodeType === 1 &&\n getCharacterIndex(nested as HTMLElement) !== undefined\n ) {\n tokens.push(nested as HTMLElement);\n }\n }\n }\n return tokens;\n}\n\nfunction textAt(token: HTMLElement, offset: number): [Node, number] | null {\n let remaining = Math.max(0, offset);\n const stack: Array<{ container: Node; index: number }> = [\n { container: token, index: 0 },\n ];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame.index >= frame.container.childNodes.length) {\n stack.pop();\n continue;\n }\n const walkNode = frame.container.childNodes[frame.index];\n frame.index++;\n if (walkNode.nodeType === 3) {\n const len = getTextOffset(\n walkNode.textContent,\n walkNode.textContent?.length ?? 0\n );\n if (remaining <= len) {\n return [walkNode, remaining];\n }\n remaining -= len;\n } else if (walkNode.nodeType === 1) {\n stack.push({ container: walkNode, index: 0 });\n }\n }\n return null;\n}\n\nfunction textLengthBefore(root: Node, target: Node): number {\n let before = 0;\n const stack: Array<{ container: Node; index: number }> = [\n { container: root, index: 0 },\n ];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame.index >= frame.container.childNodes.length) {\n stack.pop();\n continue;\n }\n const walkNode = frame.container.childNodes[frame.index];\n if (walkNode === target) {\n return before;\n }\n frame.index++;\n if (walkNode.nodeType === 3) {\n before += getTextOffset(\n walkNode.textContent,\n walkNode.textContent?.length ?? 0\n );\n } else if (walkNode.nodeType === 1) {\n stack.push({ container: walkNode, index: 0 });\n }\n }\n return before;\n}\n\nfunction isInside(token: HTMLElement, node: Node): boolean {\n let current: Node | null = node;\n while (current !== null) {\n if (current === token) {\n return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n\nfunction offsetBefore(line: HTMLElement, node: Node): number {\n if (node.parentElement === line) {\n let offset = 0;\n const index = Array.prototype.indexOf.call(line.childNodes, node);\n for (let i = 0; i < index; i++) {\n offset = getLineChildEnd(line.childNodes[i]);\n }\n return offset;\n }\n for (const token of collectTokens(line)) {\n if (isInside(token, node)) {\n const base = getCharacterIndex(token)!;\n return base + (node.nodeType === 3 ? textLengthBefore(token, node) : 0);\n }\n }\n let offset = 0;\n let target: HTMLElement | null =\n node.nodeType === 1 ? (node as HTMLElement) : node.parentElement;\n while (target !== null && target.parentElement !== null) {\n if (getLineIndex(target.parentElement) !== undefined) {\n break;\n }\n const parent = target.parentElement;\n const index = Array.prototype.indexOf.call(parent.childNodes, target);\n for (let i = 0; i < index; i++) {\n offset = getLineChildEnd(parent.childNodes[i]);\n }\n target = parent;\n }\n return offset;\n}\n\nfunction findTokenSpan(el: HTMLElement): HTMLElement | null {\n let current: HTMLElement | null = el;\n while (current !== null) {\n if (getLineIndex(current) !== undefined) {\n return null;\n }\n if (getCharacterIndex(current) !== undefined) {\n return current;\n }\n current = current.parentElement;\n }\n return null;\n}\n\nfunction getLineChildEnd(\n child: Node | undefined,\n textOffsetInChild?: number\n): number {\n if (child === undefined) {\n return 0;\n }\n if (child.nodeType === 3) {\n const parent = child.parentElement;\n if (parent === null) {\n return 0;\n }\n const token = findTokenSpan(parent);\n if (token === null) {\n return 0;\n }\n const base = getCharacterIndex(token);\n if (base === undefined) {\n return 0;\n }\n const length =\n textOffsetInChild === undefined\n ? getTextOffset(child.textContent, child.textContent?.length ?? 0)\n : getTextOffset(child.textContent, textOffsetInChild);\n return base + textLengthBefore(token, child) + length;\n }\n if (child.nodeType !== 1) {\n return 0;\n }\n const el = child as HTMLElement;\n if (el.tagName !== 'SPAN' && el.tagName !== 'BR') {\n return 0;\n }\n const base = getCharacterIndex(el);\n if (base !== undefined) {\n return base + (el.textContent?.length ?? 0);\n }\n let end = 0;\n for (const token of el.childNodes) {\n end = Math.max(end, getLineChildEnd(token));\n }\n return end;\n}\n\nfunction getLineIndex(el: HTMLElement): number | undefined {\n const { line } = el.dataset;\n if (line !== undefined) {\n return parseInt(line) - 1;\n }\n return undefined;\n}\n\nfunction getCharacterIndex(el: HTMLElement): number | undefined {\n const { char } = el.dataset;\n return char !== undefined ? parseInt(char) : undefined;\n}\n\nfunction getTextOffset(\n text: string | null | undefined,\n offset: number\n): number {\n const value = text ?? '';\n const lineBreakIndex = value.search(/[\\r\\n]/);\n return Math.min(\n offset,\n lineBreakIndex === -1 ? value.length : lineBreakIndex\n );\n}\n"],"mappings":";;;AAWA,MAAa,oBAAoB;AACjC,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;;;;AAchC,SAAgB,iBACd,OACA,YAAgC,eACH;CAC7B,MAAM,QAAQ,mBAAmB,MAAM,gBAAgB,MAAM,YAAY;CACzE,MAAM,MAAM,mBAAmB,MAAM,cAAc,MAAM,UAAU;AACnE,KAAI,UAAU,QAAQ,QAAQ,KAC5B;AAEF,QAAO;EACL;EACA;EACA;EACD;;;;;AAMH,SAAgB,mBACd,cACA,WACA,SACA,SACqD;AACrD,KAAI,iBAAiB,OACnB,QAAO,CAAC,EAAE,EAAE,UAAU;CAExB,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAMA,QAAoB,EAAE;CAC5B,IAAIC,eAAgC,EAAE,GAAG,WAAW;CACpD,IAAI,UAAU,IAAI;AAClB,KAAI,MAAM,OAAO,IAAI,QAAQ,IAAI,cAAc,EAC7C;AAEF,MAAK,IAAI,OAAO,MAAM,MAAM,QAAQ,SAAS,QAAQ;EACnD,MAAM,WAAW,aAAa,YAAY,KAAK;AAC/C,MAAI,aAAa,OACf;EAEF,MAAM,aAAa,SAAS,WAAW,IAAK,GAAG,MAAO,IAAI,OAAO,QAAQ;EACzE,IAAI,eAAe;EACnB,IAAI,UAAU;AACd,MAAI,SAAS;AACX,OAAI,SAAS,WAAW,IAAK,CAC3B,gBAAe;YACN,SAAS,WAAW,IAAI,EAAE;IACnC,MAAM,sBACJ,SAAS,SAAS,SAAS,WAAW,CAAC;AACzC,mBAAe,KAAK,IAAI,WAAW,QAAQ,oBAAoB;;AAEjE,OAAI,iBAAiB,EACnB;AAEF,aAAU;;AAEZ,QAA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S,kBAAkB,IAAqC;CAC9D,MAAM,EAAE,SAAS,GAAG;AACpB,QAAO,SAAS,SAAY,SAAS,KAAK,GAAG;;AAG/C,SAAS,cACP,MACA,QACQ;CACR,MAAM,QAAQ,QAAQ;CACtB,MAAM,iBAAiB,MAAM,OAAO,SAAS;AAC7C,QAAO,KAAK,IACV,QACA,mBAAmB,KAAK,MAAM,SAAS,eACxC"}
1
+ {"version":3,"file":"selection.js","names":["edits: TextEdit[]","newSelection: EditorSelection","selectionPositions: Position[]","ordered: Array<{\n index: number;\n start: number;\n end: number;\n }>","edits: ResolvedTextEdit[]","nextSelectionOffsets: Array<[number, number] | undefined>","mergedGroup:\n | {\n start: number;\n end: number;\n indices: number[];\n }\n | undefined","nextOffsets: [number, number]","ordered: Array<{\n index: number;\n start: number;\n end: number;\n text: string;\n }>","nextSelectionOffsets: number[]","nextOffsetPairs: Array<[number, number]>","edit: ResolvedTextEdit | undefined","deleteSelections: EditorSelection[]","accepted: {\n index: number;\n selection: EditorSelection;\n }[]","last: HTMLElement | null","lastTextNode: Text | null","normalizedOffsets: number[]","lineEl: HTMLElement | null","tokens: HTMLElement[]","stack: Array<{ container: Node; index: number }>","current: Node | null","offset","target: HTMLElement | null","current: HTMLElement | null","base"],"sources":["../../src/editor/selection.ts"],"sourcesContent":["import type { DiffLineAnnotation } from '../types';\nimport { applyDocumentChangeToLineAnnotations } from './lineAnnotations';\nimport type {\n Position,\n Range,\n ResolvedTextEdit,\n TextDocument,\n TextDocumentChange,\n TextEdit,\n} from './textDocument';\n\nexport const DirectionBackward = -1;\nexport const DirectionNone = 0;\nexport const DirectionForward = 1;\n\nexport type SelectionDirection =\n | typeof DirectionBackward\n | typeof DirectionNone\n | typeof DirectionForward;\n\nexport interface EditorSelection extends Range {\n direction: SelectionDirection;\n}\n\n/**\n * Converts a selection from a web selection to an editor selection.\n */\nexport function convertSelection(\n range: StaticRange,\n direction: SelectionDirection = DirectionNone\n): EditorSelection | undefined {\n const start = boundaryToPosition(range.startContainer, range.startOffset);\n const end = boundaryToPosition(range.endContainer, range.endOffset);\n if (start === null || end === null) {\n return undefined;\n }\n return {\n start,\n end,\n direction,\n };\n}\n\n/**\n * Resolves the indent edits for a selection.\n */\nexport function resolveIndentEdits(\n textDocument: TextDocument<unknown>,\n selection: EditorSelection,\n tabSize: number,\n outdent: boolean\n): [edits: TextEdit[], nextSelection: EditorSelection] {\n if (textDocument === undefined) {\n return [[], selection];\n }\n const { start, end } = selection;\n const edits: TextEdit[] = [];\n let newSelection: EditorSelection = { ...selection };\n let endLine = end.line;\n if (start.line < end.line && end.character === 0) {\n endLine--;\n }\n for (let line = start.line; line <= endLine; line++) {\n const lineText = textDocument.getLineText(line);\n if (lineText === undefined) {\n continue;\n }\n const indentUnit = lineText.startsWith('\\t') ? '\\t' : ' '.repeat(tabSize);\n let deleteLength = 0;\n let newText = indentUnit;\n if (outdent) {\n if (lineText.startsWith('\\t')) {\n deleteLength = 1;\n } else if (lineText.startsWith(' ')) {\n const leadingSpacesLength =\n lineText.length - lineText.trimStart().length;\n deleteLength = Math.min(indentUnit.length, leadingSpacesLength);\n }\n if (deleteLength === 0) {\n continue;\n }\n newText = '';\n }\n edits.push({\n range: {\n start: { line, character: 0 },\n end: { line, character: deleteLength },\n },\n newText,\n });\n const delta = newText.length - deleteLength;\n if (line === start.line) {\n newSelection = {\n ...newSelection,\n start: {\n ...start,\n character: Math.max(0, start.character + delta),\n },\n };\n }\n if (line === end.line) {\n newSelection = {\n ...newSelection,\n end: {\n ...end,\n character: Math.max(0, end.character + delta),\n },\n };\n }\n }\n return [edits, newSelection];\n}\n\n/**\n * Maps the cursor move to all selections.\n */\nexport function mapCursorMove(\n textDocument: TextDocument<unknown>,\n selections: EditorSelection[],\n shortcut: 'textStart' | 'start' | 'end' | 'up' | 'down' | 'left' | 'right'\n): EditorSelection[] {\n const lineCount = textDocument.lineCount;\n return selections.map((selection) => {\n let { line, character } =\n shortcut === 'up' || shortcut === 'left'\n ? selection.start\n : selection.end;\n if (\n shortcut === 'textStart' ||\n shortcut === 'start' ||\n shortcut === 'end'\n ) {\n if (shortcut === 'textStart') {\n const indent = getLeadingSpaces(textDocument.getLineText(line));\n character = character === indent ? 0 : indent;\n } else {\n character =\n shortcut === 'start' ? 0 : textDocument.getLineText(line).length;\n }\n if (selection.direction === DirectionBackward) {\n line = selection.start.line;\n } else {\n line = selection.end.line;\n }\n } else if (shortcut === 'up') {\n line = Math.max(0, line - 1);\n } else if (shortcut === 'down') {\n line = Math.min(Math.max(lineCount - 1, 0), line + 1);\n } else if (isCollapsedSelection(selection)) {\n if (shortcut === 'left') {\n character--;\n\n if (character < 0) {\n if (line === 0) {\n character = 0;\n } else {\n line = Math.max(0, line - 1);\n character = textDocument.getLineText(line).length;\n }\n }\n } else {\n character++;\n if (character > textDocument.getLineText(line).length) {\n if (line === lineCount - 1) {\n character--;\n } else {\n line = Math.min(Math.max(lineCount - 1, 0), line + 1);\n character = 0;\n }\n }\n }\n }\n const pos = { line, character };\n return {\n start: pos,\n end: pos,\n direction: DirectionNone,\n };\n });\n}\n\n/**\n * Same as mapCursorMove, but with shift key pressed.\n */\nexport function mapSelectionShift(\n textDocument: TextDocument<unknown>,\n selections: EditorSelection[],\n shortcut: 'textStart' | 'start' | 'end' | 'up' | 'down' | 'left' | 'right'\n): EditorSelection[] {\n return selections.map((selection) => {\n const [anchorOffset, focusOffset] = getSelectionAnchorAndFocusOffsets(\n textDocument,\n selection\n );\n const focusPosition = textDocument.positionAt(focusOffset);\n const [movedFocusSelection] = mapCursorMove(\n textDocument,\n [\n {\n start: focusPosition,\n end: focusPosition,\n direction: DirectionNone,\n },\n ],\n shortcut\n );\n const movedFocusOffset = textDocument.offsetAt(movedFocusSelection.start);\n return createSelectionFromAnchorAndFocusOffsets(\n textDocument,\n anchorOffset,\n movedFocusOffset\n );\n });\n}\n\n/**\n * Applies a text change to the given text document\n */\nexport function applyTextChangeToSelections<LAnnotation>(\n textDocument: TextDocument<LAnnotation>,\n selections: EditorSelection[],\n edit: ResolvedTextEdit,\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[],\n tabSize = 2\n): {\n nextSelections: EditorSelection[];\n change?: TextDocumentChange;\n} {\n const primarySelection = selections[selections.length - 1];\n if (primarySelection === undefined) {\n return { nextSelections: [] };\n }\n const selectionPositions: Position[] = [];\n for (const selection of selections) {\n selectionPositions.push(selection.start, selection.end);\n }\n const selectionOffsets = textDocument.offsetsAt(selectionPositions);\n const primaryStartOffset = selectionOffsets[(selections.length - 1) * 2];\n const primaryEndOffset = selectionOffsets[(selections.length - 1) * 2 + 1];\n const ordered: Array<{\n index: number;\n start: number;\n end: number;\n }> = [];\n let isAlreadyOrdered = true;\n for (let index = 0; index < selections.length; index++) {\n const entry = {\n index,\n start: selectionOffsets[index * 2],\n end: selectionOffsets[index * 2 + 1],\n };\n const previous = ordered[ordered.length - 1];\n if (\n previous !== undefined &&\n (entry.start < previous.start ||\n (entry.start === previous.start && entry.end < previous.end))\n ) {\n isAlreadyOrdered = false;\n }\n ordered.push(entry);\n }\n if (!isAlreadyOrdered) {\n ordered.sort((a, b) => {\n const startOrder = a.start - b.start;\n if (startOrder !== 0) {\n return startOrder;\n }\n const endOrder = a.end - b.end;\n if (endOrder !== 0) {\n return endOrder;\n }\n return a.index - b.index;\n });\n }\n const adjustedChange = normalizeLeadingIndentForChange(\n textDocument,\n edit,\n tabSize\n );\n const edits: ResolvedTextEdit[] = [];\n const nextSelectionOffsets: Array<[number, number] | undefined> = Array.from({\n length: selections.length,\n });\n let offsetDelta = 0;\n let mergedGroup:\n | {\n start: number;\n end: number;\n indices: number[];\n }\n | undefined;\n const finalizeMergedGroup = () => {\n if (mergedGroup === undefined) {\n return;\n }\n const perGroupChange = normalizeLeadingIndentForChange(\n textDocument,\n {\n start: mergedGroup.start,\n end: mergedGroup.end,\n text: adjustedChange.text,\n },\n tabSize\n );\n const newText = expandSingleNewlineInsert(\n textDocument,\n perGroupChange.text,\n perGroupChange.start\n );\n edits.push({\n start: perGroupChange.start,\n end: perGroupChange.end,\n text: newText,\n });\n const nextOffsets: [number, number] = [\n mergedGroup.start + offsetDelta + newText.length,\n mergedGroup.start + offsetDelta + newText.length,\n ];\n for (const index of mergedGroup.indices) {\n nextSelectionOffsets[index] = nextOffsets;\n }\n offsetDelta += newText.length - (perGroupChange.end - perGroupChange.start);\n mergedGroup = undefined;\n };\n for (const entry of ordered) {\n const startOffset = Math.max(\n 0,\n entry.start + (adjustedChange.start - primaryStartOffset)\n );\n const endOffset = Math.max(\n startOffset,\n entry.end + (adjustedChange.end - primaryEndOffset)\n );\n if (mergedGroup !== undefined && startOffset < mergedGroup.end) {\n mergedGroup.end = Math.max(mergedGroup.end, endOffset);\n mergedGroup.indices.push(entry.index);\n continue;\n }\n finalizeMergedGroup();\n mergedGroup = {\n start: startOffset,\n end: endOffset,\n indices: [entry.index],\n };\n }\n finalizeMergedGroup();\n\n const change = textDocument.applyResolvedEdits(edits, true, selections);\n const nextSelections = createSelectionsFromOffsetPairs(\n textDocument,\n nextSelectionOffsets.map((offsets) => {\n if (offsets === undefined) {\n throw new Error('Missing next selection offsets');\n }\n return offsets;\n })\n );\n textDocument.setLastUndoSelectionsAfter(nextSelections);\n if (change !== undefined && lineAnnotations !== undefined) {\n const nextLineAnnotations =\n applyDocumentChangeToLineAnnotations<LAnnotation>(\n change,\n lineAnnotations\n );\n if (nextLineAnnotations !== undefined) {\n textDocument.setLastUndoLineAnnotations(\n lineAnnotations,\n nextLineAnnotations\n );\n }\n }\n return { nextSelections, change };\n}\n\n/**\n * Applies a text replace to multiple selections.\n */\nexport function applyTextReplaceToSelections<LAnnotation>(\n textDocument: TextDocument<LAnnotation>,\n selections: EditorSelection[],\n texts: string[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n): {\n nextSelections: EditorSelection[];\n change?: TextDocumentChange;\n} {\n if (selections.length !== texts.length) {\n throw new Error(\n 'Selection text replacements must match the selection count'\n );\n }\n const selectionPositions: Position[] = [];\n for (const selection of selections) {\n selectionPositions.push(selection.start, selection.end);\n }\n const selectionOffsets = textDocument.offsetsAt(selectionPositions);\n const ordered: Array<{\n index: number;\n start: number;\n end: number;\n text: string;\n }> = [];\n let isAlreadyOrdered = true;\n for (let index = 0; index < selections.length; index++) {\n const entry = {\n index,\n start: selectionOffsets[index * 2],\n end: selectionOffsets[index * 2 + 1],\n text: texts[index],\n };\n const previous = ordered[ordered.length - 1];\n if (\n previous !== undefined &&\n (entry.start < previous.start ||\n (entry.start === previous.start && entry.end < previous.end))\n ) {\n isAlreadyOrdered = false;\n }\n ordered.push(entry);\n }\n if (!isAlreadyOrdered) {\n ordered.sort((a, b) => {\n const startOrder = a.start - b.start;\n if (startOrder !== 0) {\n return startOrder;\n }\n const endOrder = a.end - b.end;\n if (endOrder !== 0) {\n return endOrder;\n }\n return a.index - b.index;\n });\n }\n const edits: ResolvedTextEdit[] = [];\n const nextSelectionOffsets: number[] = Array.from({\n length: selections.length,\n });\n let offsetDelta = 0;\n let previousEditEnd = -1;\n for (const entry of ordered) {\n if (entry.start < previousEditEnd) {\n throw new Error('Overlapping multi-selection edits are not supported');\n }\n previousEditEnd = entry.end;\n const newText = expandSingleNewlineInsert(\n textDocument,\n entry.text,\n entry.start\n );\n edits.push({\n start: entry.start,\n end: entry.end,\n text: newText,\n });\n nextSelectionOffsets[entry.index] =\n entry.start + offsetDelta + newText.length;\n offsetDelta += newText.length - (entry.end - entry.start);\n }\n\n const change = textDocument.applyResolvedEdits(edits, true, selections);\n const nextSelections = createSelectionsFromOffsetPairs(\n textDocument,\n nextSelectionOffsets.map((offset) => [offset, offset])\n );\n textDocument.setLastUndoSelectionsAfter(nextSelections);\n if (change !== undefined && lineAnnotations !== undefined) {\n const nextLineAnnotations =\n applyDocumentChangeToLineAnnotations<LAnnotation>(\n change,\n lineAnnotations\n );\n if (nextLineAnnotations !== undefined) {\n textDocument.setLastUndoLineAnnotations(\n lineAnnotations,\n nextLineAnnotations\n );\n }\n }\n return { nextSelections, change };\n}\n\n/**\n * Swaps the two characters adjacent to a collapsed selection, matching browser\n * insertTranspose (Ctrl+T) behavior.\n */\nexport function applyTransposeToSelections<LAnnotation>(\n textDocument: TextDocument<LAnnotation>,\n selections: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n): {\n nextSelections: EditorSelection[];\n change?: TextDocumentChange;\n} {\n const text = textDocument.getText();\n const edits: ResolvedTextEdit[] = [];\n const nextOffsetPairs: Array<[number, number]> = [];\n\n for (const selection of selections) {\n const [anchor, focus] = getSelectionAnchorAndFocusOffsets(\n textDocument,\n selection\n );\n if (!isCollapsedSelection(selection)) {\n nextOffsetPairs.push([anchor, focus]);\n continue;\n }\n\n const { line, character } = selection.start;\n const offset = anchor;\n const lineLength = textDocument.getLineText(line).length;\n let edit: ResolvedTextEdit | undefined;\n\n if (character > 0 && character < lineLength) {\n edit = {\n start: offset - 1,\n end: offset + 1,\n text: text[offset] + text[offset - 1],\n };\n nextOffsetPairs.push([offset + 1, offset + 1]);\n } else if (character === lineLength && lineLength >= 2) {\n edit = {\n start: offset - 2,\n end: offset,\n text: text[offset - 1] + text[offset - 2],\n };\n nextOffsetPairs.push([offset, offset]);\n } else if (character === 0 && line > 0 && lineLength > 0) {\n const prevLine = line - 1;\n const prevLength = textDocument.getLineText(prevLine).length;\n const prevEnd = textDocument.offsetAt({\n line: prevLine,\n character: prevLength,\n });\n const prevStart = prevLength > 0 ? prevEnd - 1 : prevEnd;\n edit = {\n start: prevStart,\n end: offset + 1,\n text:\n text[offset] +\n text.slice(prevEnd, offset) +\n text.slice(prevStart, prevEnd),\n };\n nextOffsetPairs.push([offset + 1, offset + 1]);\n } else {\n nextOffsetPairs.push([anchor, focus]);\n continue;\n }\n\n edits.push(edit);\n }\n\n if (edits.length === 0) {\n return { nextSelections: selections };\n }\n\n edits.sort((a, b) => a.start - b.start);\n for (let index = 1; index < edits.length; index++) {\n if (edits[index].start < edits[index - 1].end) {\n throw new Error('Overlapping multi-selection edits are not supported');\n }\n }\n\n const change = textDocument.applyResolvedEdits(edits, true, selections);\n const nextSelections = createSelectionsFromOffsetPairs(\n textDocument,\n nextOffsetPairs\n );\n textDocument.setLastUndoSelectionsAfter(nextSelections);\n if (change !== undefined && lineAnnotations !== undefined) {\n const nextLineAnnotations =\n applyDocumentChangeToLineAnnotations<LAnnotation>(\n change,\n lineAnnotations\n );\n if (nextLineAnnotations !== undefined) {\n textDocument.setLastUndoLineAnnotations(\n lineAnnotations,\n nextLineAnnotations\n );\n }\n }\n return { nextSelections, change };\n}\n\n/**\n * Deletes from each selection to the end of its line, including the line break\n * when the caret is already at the end of a non-final line. Non-collapsed\n * selections delete their selected text instead.\n */\nexport function applyDeleteHardLineForwardToSelections<LAnnotation>(\n textDocument: TextDocument<LAnnotation>,\n selections: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n): {\n nextSelections: EditorSelection[];\n change?: TextDocumentChange;\n} {\n const deleteSelections: EditorSelection[] = selections.map((selection) => {\n const range = resolveDeleteHardLineForwardRange(textDocument, selection);\n const deleteSelection: EditorSelection = {\n start: range.start,\n end: range.end,\n direction: DirectionNone,\n };\n return deleteSelection;\n });\n const hasEffect = deleteSelections.some(\n (selection) => comparePosition(selection.start, selection.end) !== 0\n );\n if (!hasEffect) {\n return { nextSelections: selections };\n }\n return applyTextReplaceToSelections(\n textDocument,\n deleteSelections,\n deleteSelections.map(() => ''),\n lineAnnotations\n );\n}\n\n/**\n * Checks if a selection is collapsed.\n */\nexport function isCollapsedSelection(selection: EditorSelection): boolean {\n return (\n selection.start.line === selection.end.line &&\n selection.start.character === selection.end.character\n );\n}\n\n/**\n * Returns the caret (focus) position for a selection.\n */\nexport function getCaretPosition(selection: EditorSelection): Position {\n const { start, end, direction } = selection;\n return direction === DirectionBackward ? start : end;\n}\n\n/**\n * Checks if a line is editable.\n */\nexport function isLineEditable(lineType: string): boolean {\n return (\n lineType === 'context' ||\n lineType === 'change-addition' ||\n lineType === 'context-expanded'\n );\n}\n\n/**\n * Checks whether selections `a` and `b` intersect.\n */\nexport function selectionIntersects(\n a: EditorSelection,\n b: EditorSelection\n): boolean {\n const aCollapsed = isCollapsedSelection(a);\n const bCollapsed = isCollapsedSelection(b);\n if (aCollapsed && bCollapsed) {\n return comparePosition(a.start, b.start) === 0;\n }\n if (aCollapsed) {\n return (\n comparePosition(b.start, a.start) <= 0 &&\n comparePosition(a.start, b.end) <= 0\n );\n }\n if (bCollapsed) {\n return (\n comparePosition(a.start, b.start) <= 0 &&\n comparePosition(b.start, a.end) <= 0\n );\n }\n return (\n comparePosition(a.start, b.end) < 0 && comparePosition(b.start, a.end) < 0\n );\n}\n\n/**\n * Compares two positions.\n */\nexport function comparePosition(a: Position, b: Position): number {\n if (a.line !== b.line) {\n return a.line - b.line;\n }\n return a.character - b.character;\n}\n\n/**\n * Creates a selection from anchor and focus offsets.\n */\nexport function createSelectionFromAnchorAndFocusOffsets(\n textDocument: TextDocument<unknown>,\n anchorOffset: number,\n focusOffset: number\n): EditorSelection {\n const direction =\n anchorOffset === focusOffset\n ? DirectionNone\n : anchorOffset < focusOffset\n ? DirectionForward\n : DirectionBackward;\n const start = Math.min(anchorOffset, focusOffset);\n const end = Math.max(anchorOffset, focusOffset);\n return {\n start: textDocument.positionAt(start),\n end: textDocument.positionAt(end),\n direction,\n };\n}\n\n/**\n * Creates a selection from a anchor and focus selection.\n */\nexport function createSelectionFrom(\n anchorSelection: EditorSelection,\n focusSelection: EditorSelection\n): EditorSelection {\n const anchor =\n anchorSelection.direction === DirectionBackward\n ? anchorSelection.end\n : anchorSelection.start;\n const currentStartOrder = comparePosition(anchor, focusSelection.start);\n const currentEndOrder = comparePosition(anchor, focusSelection.end);\n let focus = focusSelection.end;\n if (currentStartOrder <= 0) {\n focus = focusSelection.end;\n } else if (currentEndOrder >= 0) {\n focus = focusSelection.start;\n } else {\n // When the original anchor sits inside `current`, keep whichever edge\n // stayed at the anchor so drag direction remains stable.\n focus = currentStartOrder === 0 ? focusSelection.end : focusSelection.start;\n }\n const anchorVsFocus = comparePosition(anchor, focus);\n const direction: SelectionDirection =\n anchorVsFocus === 0\n ? DirectionNone\n : anchorVsFocus < 0\n ? DirectionForward\n : DirectionBackward;\n const selectionStart = anchorVsFocus <= 0 ? anchor : focus;\n const selectionEnd = anchorVsFocus <= 0 ? focus : anchor;\n return {\n start: selectionStart,\n end: selectionEnd,\n direction,\n };\n}\n\n/**\n * Extends or shrinks the selection `original` using the endpoints of `target`, \\\n * matching contenteditable shift + click extend behavior.\n */\nexport function extendSelection(\n original: EditorSelection,\n target: EditorSelection\n): EditorSelection {\n const leftExtended = comparePosition(target.start, original.start) < 0;\n const rightExtended = comparePosition(target.end, original.end) > 0;\n\n if (leftExtended && !rightExtended) {\n return {\n start: target.start,\n end: original.end,\n direction: DirectionBackward,\n };\n }\n\n if (rightExtended && !leftExtended) {\n return {\n start: original.start,\n end: target.end,\n direction: DirectionForward,\n };\n }\n\n if (original.direction === DirectionBackward) {\n return {\n start: target.start,\n end: original.end,\n direction:\n comparePosition(target.start, original.end) === 0\n ? DirectionNone\n : DirectionBackward,\n };\n }\n\n return {\n start: original.start,\n end: target.end,\n direction:\n comparePosition(original.start, target.end) === 0\n ? DirectionNone\n : DirectionForward,\n };\n}\n\n/**\n * Extends multiple selections.\n */\nexport function extendSelections(\n selections: EditorSelection[],\n target: EditorSelection\n): EditorSelection[] {\n const newSelections = selections.map((selection) => {\n return extendSelection(selection, target);\n });\n return mergeOverlappingSelections(newSelections);\n}\n\n/**\n * Merges overlapping selections.\n */\nexport function mergeOverlappingSelections(\n selections: EditorSelection[]\n): EditorSelection[] {\n if (selections.length <= 1) {\n return selections;\n }\n const selected = new Set<number>();\n const accepted: {\n index: number;\n selection: EditorSelection;\n }[] = [];\n for (let i = selections.length - 1; i >= 0; i--) {\n const selection = selections[i];\n if (selection === undefined) {\n continue;\n }\n let left = 0;\n let right = accepted.length;\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n const candidate = accepted[mid]?.selection;\n if (candidate === undefined) {\n break;\n }\n if (comparePosition(candidate.start, selection.start) < 0) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n const previous = accepted[left - 1]?.selection;\n const next = accepted[left]?.selection;\n if (\n (previous !== undefined && selectionIntersects(previous, selection)) ||\n (next !== undefined && selectionIntersects(next, selection))\n ) {\n continue;\n }\n accepted.splice(left, 0, { index: i, selection });\n selected.add(i);\n }\n return selections.filter((_, index) => selected.has(index));\n}\n\n/**\n * Finds the next matching word and updates the selections.\n */\nexport function findNexMatch(\n textDocument: TextDocument<unknown>,\n selections: EditorSelection[]\n): EditorSelection[] | undefined {\n if (selections.length === 0) {\n return undefined;\n }\n\n const normalizedSelections = selections.map((selection) =>\n isCollapsedSelection(selection)\n ? expandCollapsedSelectionToWord(textDocument, selection)\n : selection\n );\n const texts = normalizedSelections.map((s) => textDocument.getText(s));\n const needle = texts[0];\n if (needle.length === 0 || texts.some((t) => t !== needle)) {\n return undefined;\n }\n\n const occupied = normalizedSelections.map(\n (s) =>\n [textDocument.offsetAt(s.start), textDocument.offsetAt(s.end)] as [\n number,\n number,\n ]\n );\n const nextOffset = textDocument.findNextNonOverlappingSubstring(\n needle,\n occupied\n );\n if (nextOffset === undefined) {\n return normalizedSelections.some((selection, index) => {\n const original = selections[index];\n return (\n comparePosition(selection.start, original.start) !== 0 ||\n comparePosition(selection.end, original.end) !== 0 ||\n selection.direction !== original.direction\n );\n })\n ? normalizedSelections\n : undefined;\n }\n const added = createSelectionFromAnchorAndFocusOffsets(\n textDocument,\n nextOffset,\n nextOffset + needle.length\n );\n return [...normalizedSelections, added];\n}\n\n/**\n * Get the full selection of the document.\n */\nexport function getDocumentFullSelection(\n textDocument: TextDocument<unknown>\n): EditorSelection {\n const lastLine = textDocument.lineCount - 1;\n const lastCharacter = textDocument.getLineText(lastLine)?.length ?? 0;\n return {\n start: { line: 0, character: 0 },\n end: { line: lastLine, character: lastCharacter },\n direction: DirectionForward,\n };\n}\n\n/**\n * Get the boundary selection of the document.\n */\nexport function getDocumentBoundarySelection(\n textDocument: TextDocument<unknown>,\n atEnd: boolean\n): EditorSelection {\n const line = atEnd ? textDocument.lineCount - 1 : 0;\n const character = atEnd ? (textDocument.getLineText(line)?.length ?? 0) : 0;\n const start = { line, character };\n return {\n start: start,\n end: start,\n direction: DirectionForward,\n };\n}\n\n/**\n * Get the text of the selections for the given text document.\n */\nexport function getSelectionText(\n textDocument: TextDocument<unknown>,\n selections: EditorSelection[]\n): string {\n return [...selections]\n .sort((a, b) => {\n const startOrder = comparePosition(a.start, b.start);\n if (startOrder !== 0) {\n return startOrder;\n }\n return comparePosition(a.end, b.end);\n })\n .map((selection) => {\n if (isCollapsedSelection(selection)) {\n return textDocument.getLineText(selection.start.line, false);\n }\n return textDocument.getText(selection);\n })\n .join('\\n');\n}\n\n/**\n * Get the anchor node and offset for a selection.\n */\nexport function getSelectionAnchor(\n lineElement: HTMLElement,\n character: number\n): [Node, number] {\n const ch = Math.max(0, character);\n const tokens = collectTokens(lineElement);\n\n let last: HTMLElement | null = null;\n for (const token of tokens) {\n last = token;\n const base = getCharacterIndex(token)!;\n const end = base + (token.textContent?.length ?? 0);\n if (ch <= end) {\n const anchor = textAt(token, ch < base ? 0 : ch - base);\n if (anchor !== null) {\n return anchor;\n }\n }\n }\n\n if (last !== null) {\n const anchor = textAt(last, last.textContent?.length ?? 0);\n if (anchor !== null) {\n return anchor;\n }\n return [last, 0];\n }\n\n let textOffset = 0;\n let lastTextNode: Text | null = null;\n for (const child of lineElement.childNodes) {\n if (child.nodeType === 1 && (child as HTMLElement).tagName === 'BR') {\n return [child, 0];\n }\n if (child.nodeType !== 3) {\n continue;\n }\n lastTextNode = child as Text;\n const len = getTextOffset(\n lastTextNode.textContent,\n lastTextNode.textContent?.length ?? 0\n );\n if (ch <= textOffset + len) {\n return [\n lastTextNode,\n getTextOffset(lastTextNode.textContent, ch - textOffset),\n ];\n }\n textOffset += len;\n }\n\n if (lastTextNode !== null) {\n return [\n lastTextNode,\n getTextOffset(\n lastTextNode.textContent,\n lastTextNode.textContent?.length ?? 0\n ),\n ];\n }\n return [lineElement, 0];\n}\n\n/**\n * Expands a zero-width selection to the word-like segment that contains the caret.\n */\nexport function expandCollapsedSelectionToWord(\n textDocument: TextDocument<unknown>,\n selection: EditorSelection\n): EditorSelection {\n const { line, character } = selection.start;\n const lineText = textDocument.getLineText(line);\n const ch = Math.max(0, Math.min(character, lineText.length));\n const span = expandCollapsedLineWord(lineText, ch);\n if (span === undefined) {\n return selection;\n }\n return {\n start: { line, character: span.start },\n end: { line, character: span.end },\n direction: DirectionForward,\n };\n}\n\nfunction expandCollapsedLineWord(\n lineText: string,\n character: number\n): { start: number; end: number } | undefined {\n const segmenter = new Intl.Segmenter(undefined, {\n granularity: 'word',\n });\n for (const seg of segmenter.segment(lineText)) {\n if (seg.isWordLike !== true) {\n continue;\n }\n const lo = seg.index;\n const hi = lo + seg.segment.length;\n // Match when the cursor is inside the word or immediately touching\n // one of its boundaries — not when separated by non-word characters.\n if (character >= lo && character <= hi) {\n return { start: lo, end: hi };\n }\n }\n return undefined;\n}\n\nfunction getSelectionAnchorAndFocusOffsets(\n textDocument: TextDocument<unknown>,\n selection: EditorSelection\n): [anchorOffset: number, focusOffset: number] {\n const isBackward = selection.direction === DirectionBackward;\n return [\n textDocument.offsetAt(isBackward ? selection.end : selection.start),\n textDocument.offsetAt(getCaretPosition(selection)),\n ];\n}\n\n// Resolves the range removed by deleteHardLineForward for one selection.\nfunction resolveDeleteHardLineForwardRange(\n textDocument: TextDocument<unknown>,\n selection: EditorSelection\n): Range {\n if (!isCollapsedSelection(selection)) {\n return { start: selection.start, end: selection.end };\n }\n const { line, character } = selection.start;\n const lineText = textDocument.getLineText(line);\n const lineLength = lineText.length;\n if (character < lineLength) {\n return {\n start: { line, character },\n end: { line, character: lineLength },\n };\n }\n if (line < textDocument.lineCount - 1) {\n return {\n start: { line, character },\n end: { line: line + 1, character: 0 },\n };\n }\n return {\n start: { line, character },\n end: { line, character },\n };\n}\n\n// When the user inserts a lone line break, copy the current line's indentation onto the new line.\nfunction expandSingleNewlineInsert(\n textDocument: TextDocument<unknown>,\n insertText: string,\n insertStartOffset: number\n): string {\n if (insertText !== '\\n' && insertText !== '\\r\\n') {\n return insertText;\n }\n const line = textDocument.positionAt(insertStartOffset).line;\n const lineText = textDocument.getLineText(line);\n const indentLen = getLeadingSpaces(lineText);\n if (indentLen === 0) {\n return insertText;\n }\n return insertText + lineText.slice(0, indentLen);\n}\n\nfunction getLeadingSpaces(text: string): number {\n let indent = 0;\n for (; indent < text.length; indent++) {\n const c = text.charCodeAt(indent);\n if (c !== /* space */ 32 && c !== /* tab */ 9) {\n break;\n }\n }\n return indent;\n}\n\nfunction createSelectionsFromOffsetPairs(\n textDocument: TextDocument<unknown>,\n offsetPairs: readonly [anchorOffset: number, focusOffset: number][]\n): EditorSelection[] {\n const normalizedOffsets: number[] = [];\n for (const [anchorOffset, focusOffset] of offsetPairs) {\n normalizedOffsets.push(\n Math.min(anchorOffset, focusOffset),\n Math.max(anchorOffset, focusOffset)\n );\n }\n const positions = textDocument.positionsAt(normalizedOffsets);\n return offsetPairs.map(([anchorOffset, focusOffset], index) => {\n const direction =\n anchorOffset === focusOffset\n ? DirectionNone\n : anchorOffset < focusOffset\n ? DirectionForward\n : DirectionBackward;\n return {\n start: positions[index * 2],\n end: positions[index * 2 + 1],\n direction,\n };\n });\n}\n\n// Expands a backspace over leading spaces into one soft-tab width so mixed hard/soft indentation\n// behaves like the explicit outdent command.\nfunction normalizeLeadingIndentForChange(\n textDocument: TextDocument<unknown>,\n change: ResolvedTextEdit,\n tabSize: number\n): ResolvedTextEdit {\n if (change.text !== '' || change.start !== change.end - 1) {\n return change;\n }\n const caretPosition = textDocument.positionAt(change.end);\n if (caretPosition.character === 0) {\n return change;\n }\n const lineText = textDocument.getLineText(caretPosition.line);\n const leadingText = lineText.slice(0, caretPosition.character);\n if (/[^ \\t]/.test(leadingText)) {\n return change;\n }\n if (lineText[caretPosition.character - 1] === '\\t') {\n return change;\n }\n const softTabStart = Math.max(0, caretPosition.character - tabSize);\n const softTabText = lineText.slice(softTabStart, caretPosition.character);\n if (softTabText.length === tabSize && /^ +$/.test(softTabText)) {\n return {\n ...change,\n start: change.end - softTabText.length,\n };\n }\n return change;\n}\n\nfunction boundaryToPosition(node: Node, offset: number): Position | null {\n const host = node.nodeType === 1 ? (node as HTMLElement) : node.parentElement;\n let lineEl: HTMLElement | null = host;\n while (lineEl !== null && getLineIndex(lineEl) === undefined) {\n lineEl = lineEl.parentElement;\n }\n if (lineEl === null) {\n return null;\n }\n const line = getLineIndex(lineEl);\n if (line === undefined) {\n return null;\n }\n\n if (node.nodeType === 3) {\n if (node.parentElement === null) {\n return null;\n }\n if (findTokenSpan(node.parentElement) !== null) {\n return { line, character: getLineChildEnd(node, offset) };\n }\n return {\n line,\n character:\n offsetBefore(lineEl, node) + getTextOffset(node.textContent, offset),\n };\n }\n\n if (node.nodeType === 1) {\n const el = node as HTMLElement;\n if (el.tagName === 'DIV') {\n let character = 0;\n for (let i = 0; i < offset; i++) {\n character = getLineChildEnd(el.childNodes[i]);\n }\n return { line, character };\n }\n if (el.tagName === 'BR') {\n return { line, character: 0 };\n }\n if (el.tagName === 'SPAN') {\n if (offset < el.childNodes.length) {\n const next = el.childNodes[offset];\n if (next?.nodeType === 1) {\n const nextBase = getCharacterIndex(next as HTMLElement);\n if (nextBase !== undefined) {\n return { line, character: nextBase };\n }\n const token = findTokenSpan(next as HTMLElement);\n const tokenBase =\n token === null ? undefined : getCharacterIndex(token);\n if (tokenBase !== undefined) {\n return { line, character: tokenBase };\n }\n }\n }\n return {\n line,\n character:\n offset > 0\n ? getLineChildEnd(el.childNodes[offset - 1])\n : offsetBefore(lineEl, el),\n };\n }\n return { line, character: offsetBefore(lineEl, el) };\n }\n return null;\n}\n\nfunction collectTokens(line: HTMLElement): HTMLElement[] {\n const tokens: HTMLElement[] = [];\n for (const child of line.childNodes) {\n if (child.nodeType !== 1) {\n continue;\n }\n const el = child as HTMLElement;\n if (el.tagName !== 'SPAN') {\n continue;\n }\n const base = getCharacterIndex(el);\n if (base !== undefined) {\n tokens.push(el);\n continue;\n }\n for (const nested of el.childNodes) {\n if (\n nested.nodeType === 1 &&\n getCharacterIndex(nested as HTMLElement) !== undefined\n ) {\n tokens.push(nested as HTMLElement);\n }\n }\n }\n return tokens;\n}\n\nfunction textAt(token: HTMLElement, offset: number): [Node, number] | null {\n let remaining = Math.max(0, offset);\n const stack: Array<{ container: Node; index: number }> = [\n { container: token, index: 0 },\n ];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame.index >= frame.container.childNodes.length) {\n stack.pop();\n continue;\n }\n const walkNode = frame.container.childNodes[frame.index];\n frame.index++;\n if (walkNode.nodeType === 3) {\n const len = getTextOffset(\n walkNode.textContent,\n walkNode.textContent?.length ?? 0\n );\n if (remaining <= len) {\n return [walkNode, remaining];\n }\n remaining -= len;\n } else if (walkNode.nodeType === 1) {\n stack.push({ container: walkNode, index: 0 });\n }\n }\n return null;\n}\n\nfunction textLengthBefore(root: Node, target: Node): number {\n let before = 0;\n const stack: Array<{ container: Node; index: number }> = [\n { container: root, index: 0 },\n ];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame.index >= frame.container.childNodes.length) {\n stack.pop();\n continue;\n }\n const walkNode = frame.container.childNodes[frame.index];\n if (walkNode === target) {\n return before;\n }\n frame.index++;\n if (walkNode.nodeType === 3) {\n before += getTextOffset(\n walkNode.textContent,\n walkNode.textContent?.length ?? 0\n );\n } else if (walkNode.nodeType === 1) {\n stack.push({ container: walkNode, index: 0 });\n }\n }\n return before;\n}\n\nfunction isInside(token: HTMLElement, node: Node): boolean {\n let current: Node | null = node;\n while (current !== null) {\n if (current === token) {\n return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n\nfunction offsetBefore(line: HTMLElement, node: Node): number {\n if (node.parentElement === line) {\n let offset = 0;\n const index = Array.prototype.indexOf.call(line.childNodes, node);\n for (let i = 0; i < index; i++) {\n offset = getLineChildEnd(line.childNodes[i]);\n }\n return offset;\n }\n for (const token of collectTokens(line)) {\n if (isInside(token, node)) {\n const base = getCharacterIndex(token)!;\n return base + (node.nodeType === 3 ? textLengthBefore(token, node) : 0);\n }\n }\n let offset = 0;\n let target: HTMLElement | null =\n node.nodeType === 1 ? (node as HTMLElement) : node.parentElement;\n while (target !== null && target.parentElement !== null) {\n if (getLineIndex(target.parentElement) !== undefined) {\n break;\n }\n const parent = target.parentElement;\n const index = Array.prototype.indexOf.call(parent.childNodes, target);\n for (let i = 0; i < index; i++) {\n offset = getLineChildEnd(parent.childNodes[i]);\n }\n target = parent;\n }\n return offset;\n}\n\nfunction findTokenSpan(el: HTMLElement): HTMLElement | null {\n let current: HTMLElement | null = el;\n while (current !== null) {\n if (getLineIndex(current) !== undefined) {\n return null;\n }\n if (getCharacterIndex(current) !== undefined) {\n return current;\n }\n current = current.parentElement;\n }\n return null;\n}\n\nfunction getLineChildEnd(\n child: Node | undefined,\n textOffsetInChild?: number\n): number {\n if (child === undefined) {\n return 0;\n }\n if (child.nodeType === 3) {\n const parent = child.parentElement;\n if (parent === null) {\n return 0;\n }\n const token = findTokenSpan(parent);\n if (token === null) {\n return 0;\n }\n const base = getCharacterIndex(token);\n if (base === undefined) {\n return 0;\n }\n const length =\n textOffsetInChild === undefined\n ? getTextOffset(child.textContent, child.textContent?.length ?? 0)\n : getTextOffset(child.textContent, textOffsetInChild);\n return base + textLengthBefore(token, child) + length;\n }\n if (child.nodeType !== 1) {\n return 0;\n }\n const el = child as HTMLElement;\n if (el.tagName !== 'SPAN' && el.tagName !== 'BR') {\n return 0;\n }\n const base = getCharacterIndex(el);\n if (base !== undefined) {\n return base + (el.textContent?.length ?? 0);\n }\n let end = 0;\n for (const token of el.childNodes) {\n end = Math.max(end, getLineChildEnd(token));\n }\n return end;\n}\n\nfunction getLineIndex(el: HTMLElement): number | undefined {\n const { line } = el.dataset;\n if (line !== undefined) {\n const lineNumber = parseInt(line, 10);\n if (!Number.isNaN(lineNumber)) {\n return lineNumber - 1;\n }\n }\n return undefined;\n}\n\nfunction getCharacterIndex(el: HTMLElement): number | undefined {\n const { char } = el.dataset;\n if (char !== undefined) {\n const charIndex = parseInt(char, 10);\n if (!Number.isNaN(charIndex)) {\n return charIndex;\n }\n }\n return undefined;\n}\n\nfunction getTextOffset(\n text: string | null | undefined,\n offset: number\n): number {\n const value = text ?? '';\n const lineBreakIndex = value.search(/[\\r\\n]/);\n return Math.min(\n offset,\n lineBreakIndex === -1 ? value.length : lineBreakIndex\n );\n}\n"],"mappings":";;;AAWA,MAAa,oBAAoB;AACjC,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;;;;AAchC,SAAgB,iBACd,OACA,YAAgC,eACH;CAC7B,MAAM,QAAQ,mBAAmB,MAAM,gBAAgB,MAAM,YAAY;CACzE,MAAM,MAAM,mBAAmB,MAAM,cAAc,MAAM,UAAU;AACnE,KAAI,UAAU,QAAQ,QAAQ,KAC5B;AAEF,QAAO;EACL;EACA;EACA;EACD;;;;;AAMH,SAAgB,mBACd,cACA,WACA,SACA,SACqD;AACrD,KAAI,iBAAiB,OACnB,QAAO,CAAC,EAAE,EAAE,UAAU;CAExB,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAMA,QAAoB,EAAE;CAC5B,IAAIC,eAAgC,EAAE,GAAG,WAAW;CACpD,IAAI,UAAU,IAAI;AAClB,KAAI,MAAM,OAAO,IAAI,QAAQ,IAAI,cAAc,EAC7C;AAEF,MAAK,IAAI,OAAO,MAAM,MAAM,QAAQ,SAAS,QAAQ;EACnD,MAAM,WAAW,aAAa,YAAY,KAAK;AAC/C,MAAI,aAAa,OACf;EAEF,MAAM,aAAa,SAAS,WAAW,IAAK,GAAG,MAAO,IAAI,OAAO,QAAQ;EACzE,IAAI,eAAe;EACnB,IAAI,UAAU;AACd,MAAI,SAAS;AACX,OAAI,SAAS,WAAW,IAAK,CAC3B,gBAAe;YACN,SAAS,WAAW,IAAI,EA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AK,gBAAgB,MAAM,CAAC;AAE7C,QAAO;;AAGT,SAAS,aAAa,IAAqC;CACzD,MAAM,EAAE,SAAS,GAAG;AACpB,KAAI,SAAS,QAAW;EACtB,MAAM,aAAa,SAAS,MAAM,GAAG;AACrC,MAAI,CAAC,OAAO,MAAM,WAAW,CAC3B,QAAO,aAAa;;;AAM1B,SAAS,kBAAkB,IAAqC;CAC9D,MAAM,EAAE,SAAS,GAAG;AACpB,KAAI,SAAS,QAAW;EACtB,MAAM,YAAY,SAAS,MAAM,GAAG;AACpC,MAAI,CAAC,OAAO,MAAM,UAAU,CAC1B,QAAO;;;AAMb,SAAS,cACP,MACA,QACQ;CACR,MAAM,QAAQ,QAAQ;CACtB,MAAM,iBAAiB,MAAM,OAAO,SAAS;AAC7C,QAAO,KAAK,IACV,QACA,mBAAmB,KAAK,MAAM,SAAS,eACxC"}
@@ -0,0 +1,7 @@
1
+ //#region src/editor/sprite.d.ts
2
+ type SVGSpriteNames = 'arrow-down' | 'arrow-up' | 'case' | 'close' | 'quick' | 'regex' | 'search' | 'whole-word';
3
+ declare const SVGSpriteSheet = "<svg data-editor-icon-sprite aria-hidden=\"true\" width=\"0\" height=\"0\">\n <symbol id=\"diffs-editor-icon-search\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.7747 12.8961C9.68558 13.5948 8.39011 14 7 14C3.13401 14 0 10.866 0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 8.39011 13.5948 9.68558 12.8961 10.7747L15.5607 13.4393C16.1464 14.0251 16.1464 14.9749 15.5607 15.5607C14.9749 16.1464 14.0251 16.1464 13.4393 15.5607L10.7747 12.8961ZM7 1.5C10.0376 1.5 12.5 3.96243 12.5 7C12.5 10.0376 10.0376 12.5 7 12.5C3.96243 12.5 1.5 10.0376 1.5 7C1.5 3.96243 3.96243 1.5 7 1.5Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-close\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" d=\"M3.21967 3.21967C3.51256 2.92678 3.98744 2.92678 4.28033 3.21967L8 6.93934L11.7197 3.21967C12.0126 2.92678 12.4874 2.92678 12.7803 3.21967C13.0732 3.51256 13.0732 3.98744 12.7803 4.28033L9.06066 8L12.7803 11.7197C13.0732 12.0126 13.0732 12.4874 12.7803 12.7803C12.4874 13.0732 12.0126 13.0732 11.7197 12.7803L8 9.06066L4.28033 12.7803C3.98744 13.0732 3.51256 13.0732 3.21967 12.7803C2.92678 12.4874 2.92678 12.0126 3.21967 11.7197L6.93934 8L3.21967 4.28033C2.92678 3.98744 2.92678 3.51256 3.21967 3.21967Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-arrow-up\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" transform=\"rotate(-90 8 8)\" d=\"M8.46967 4.21967C8.17678 4.51256 8.17678 4.98744 8.46967 5.28033L10.4393 7.25H3.75C3.33579 7.25 3 7.58579 3 8C3 8.41421 3.33579 8.75 3.75 8.75H10.4393L8.46967 10.7197C8.17678 11.0126 8.17678 11.4874 8.46967 11.7803C8.76256 12.0732 9.23744 12.0732 9.53033 11.7803L12.7803 8.53033C13.0732 8.23744 13.0732 7.76256 12.7803 7.46967L9.53033 4.21967C9.23744 3.92678 8.76256 3.92678 8.46967 4.21967Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-arrow-down\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" transform=\"rotate(90 8 8)\" d=\"M8.46967 4.21967C8.17678 4.51256 8.17678 4.98744 8.46967 5.28033L10.4393 7.25H3.75C3.33579 7.25 3 7.58579 3 8C3 8.41421 3.33579 8.75 3.75 8.75H10.4393L8.46967 10.7197C8.17678 11.0126 8.17678 11.4874 8.46967 11.7803C8.76256 12.0732 9.23744 12.0732 9.53033 11.7803L12.7803 8.53033C13.0732 8.23744 13.0732 7.76256 12.7803 7.46967L9.53033 4.21967C9.23744 3.92678 8.76256 3.92678 8.46967 4.21967Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-case\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" d=\"M12.2969 12.9969C10.7109 12.9969 9.61719 12.0125 9.61719 10.5047C9.61719 9.06719 10.6172 8.16094 12.5 8.15312H14.6641V7.31719C14.6641 6.23906 14.0391 5.64531 12.9297 5.64531C11.875 5.64531 11.2734 6.18437 11.1953 7.00469H9.92969C10.0156 5.56719 10.9922 4.52031 12.9766 4.52031C14.7266 4.52031 16 5.47344 16 7.2V12.8641H14.7109V11.8406H14.6719C14.2578 12.5047 13.5078 12.9969 12.2969 12.9969ZM12.6562 11.8797C13.8047 11.8797 14.6641 11.1609 14.6641 10.1375V9.18437H12.6016C11.4766 9.18437 10.9922 9.71562 10.9922 10.4578C10.9922 11.4266 11.7969 11.8797 12.6562 11.8797Z\"></path>\n <path fill=\"currentColor\" d=\"M1.42188 12.8641H0L3.79688 2H5.1875L8.98438 12.8641H7.54688L6.46875 9.66094H2.5L1.42188 12.8641ZM4.50781 3.60938H4.46875L2.86719 8.55937H6.10156L4.50781 3.60938Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-whole-word\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" d=\"M11.4089 9.99449C11.1417 9.99449 10.8961 9.95595 10.6722 9.87887C10.4519 9.80179 10.2605 9.69167 10.098 9.54852C9.93551 9.40537 9.81453 9.23469 9.73508 9.03648H9.67007V9.91191H8.5V2H9.70258V5.01721H9.76758C9.81092 4.86671 9.88314 4.7309 9.98426 4.60977C10.089 4.48497 10.2136 4.37853 10.358 4.29043C10.5025 4.19867 10.6668 4.13076 10.851 4.08672C11.0352 4.039 11.2302 4.01514 11.436 4.01514C11.8802 4.01514 12.2648 4.11792 12.5898 4.32347C12.9149 4.52535 13.164 4.81532 13.3374 5.19339C13.5107 5.57146 13.5974 6.02478 13.5974 6.55334V7.45079C13.5974 7.97568 13.5089 8.429 13.332 8.81074C13.1586 9.1888 12.9076 9.48061 12.579 9.68617C12.2504 9.89172 11.8604 9.99449 11.4089 9.99449ZM11.0785 8.99243C11.353 8.99243 11.5859 8.92636 11.7773 8.79422C11.9723 8.66208 12.1204 8.46937 12.2215 8.2161C12.3226 7.95916 12.3732 7.65267 12.3732 7.29663V6.73503C12.3732 6.37164 12.3208 6.06332 12.2161 5.81005C12.115 5.55311 11.9669 5.35673 11.7719 5.22092C11.5769 5.08511 11.3385 5.01721 11.0568 5.01721C10.7824 5.01721 10.5422 5.08328 10.3364 5.21542C10.1341 5.34389 9.97704 5.52925 9.86509 5.77151C9.75675 6.01009 9.70258 6.2964 9.70258 6.63042V7.47281C9.70258 7.77013 9.76036 8.03441 9.87592 8.26566C9.99509 8.49323 10.1576 8.67125 10.3635 8.79972C10.5729 8.92819 10.8113 8.99243 11.0785 8.99243Z\"></path>\n <path fill=\"currentColor\" d=\"M4.70482 9.99449C4.15229 9.99449 3.70087 9.83482 3.35057 9.51548C3.00388 9.19247 2.83054 8.75935 2.83054 8.2161C2.83054 7.70223 3.00207 7.28745 3.34515 6.97178C3.69184 6.65244 4.19562 6.49277 4.8565 6.49277H6.30284V5.94769C6.30284 5.61367 6.20533 5.36774 6.01032 5.20991C5.81531 5.04841 5.55349 4.96765 5.22485 4.96765C5.00817 4.96765 4.82941 4.99702 4.68857 5.05575C4.54773 5.11081 4.43758 5.18789 4.35813 5.28699C4.27868 5.38243 4.22271 5.49621 4.19021 5.62835H3.04722C3.06527 5.3861 3.12305 5.16586 3.22056 4.96765C3.32168 4.76577 3.46252 4.59326 3.64309 4.4501C3.82727 4.30328 4.05297 4.19133 4.32021 4.11425C4.59106 4.03716 4.90525 3.99862 5.26277 3.99862C5.67086 3.99862 6.04463 4.06286 6.38409 4.19133C6.72356 4.31613 6.99441 4.52168 7.19665 4.80798C7.39888 5.09429 7.5 5.4797 7.5 5.96421V9.9064H6.35701V9.1521H6.30284C6.21978 9.29892 6.10783 9.43657 5.96698 9.56504C5.82614 9.69351 5.65099 9.79812 5.44153 9.87887C5.23569 9.95595 4.99012 9.99449 4.70482 9.99449ZM5.07318 9.04749C5.3043 9.04749 5.51196 8.99977 5.69613 8.90434C5.88031 8.80523 6.02657 8.67309 6.13491 8.50791C6.24686 8.34274 6.30284 8.1537 6.30284 7.94081V7.31314H5.04609C4.69579 7.31314 4.43939 7.39206 4.27688 7.5499C4.11798 7.70773 4.03853 7.90961 4.03853 8.15554C4.03853 8.4602 4.14326 8.68594 4.35272 8.83276C4.56578 8.97591 4.80594 9.04749 5.07318 9.04749Z\"></path>\n <path fill=\"currentColor\" d=\"M2.5 12.5L13.5 12.5C14.3284 12.5 15 11.8284 15 11V9.5C15 9.22386 15.2239 9 15.5 9C15.7761 9 16 9.22386 16 9.5V11C16 12.3807 14.8807 13.5 13.5 13.5L2.5 13.5C1.11929 13.5 -7.56324e-07 12.3807 0 11L6.55675e-08 9.5C3.58362e-07 9.22386 0.223858 9 0.5 9C0.776142 9 1 9.22386 1 9.5L1 11C0.999999 11.8284 1.67157 12.5 2.5 12.5Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-regex\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" d=\"M8.60788 6.59074C8.78227 6.46701 9.02141 6.60508 9.00146 6.81797L8.77564 9.22666C8.76189 9.37331 8.87726 9.5 9.02455 9.5H9.97548C10.1228 9.5 10.2381 9.37331 10.2244 9.22667L9.99858 6.81801C9.97862 6.60513 10.2178 6.46706 10.3922 6.59079L12.3652 7.99066C12.4853 8.07589 12.6527 8.03932 12.7264 7.91177L13.2018 7.08823C13.2755 6.96068 13.2234 6.79742 13.0896 6.73601L10.8907 5.72723C10.6963 5.63807 10.6963 5.36193 10.8907 5.27277L13.0896 4.264C13.2234 4.20258 13.2755 4.03932 13.2018 3.91177L12.7263 3.08824C12.6527 2.96068 12.4853 2.92411 12.3652 3.00934L10.3922 4.40921C10.2178 4.53294 9.97862 4.39486 9.99858 4.18198L10.2244 1.77334C10.2381 1.62669 10.1228 1.5 9.97548 1.5H9.02455C8.87726 1.5 8.76189 1.62669 8.77564 1.77334L9.00146 4.18203C9.02141 4.39491 8.78227 4.53298 8.60788 4.40926L6.63479 3.00934C6.51466 2.92411 6.34726 2.96068 6.27362 3.08823L5.79815 3.91177C5.72451 4.03932 5.77654 4.20258 5.91041 4.26399L8.10929 5.27277C8.30363 5.36193 8.30363 5.63807 8.10929 5.72723L5.91041 6.73601C5.77653 6.79742 5.7245 6.96068 5.79814 7.08824L6.27361 7.91177C6.34725 8.03932 6.51466 8.07589 6.63478 7.99066L8.60788 6.59074Z\"></path>\n <path fill=\"currentColor\" d=\"M4 11C3.44772 11 3 11.4477 3 12V13C3 13.5523 3.44772 14 4 14H5C5.55228 14 6 13.5523 6 13V12C6 11.4477 5.55228 11 5 11H4Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-quick\" viewBox=\"0 0 20 20\">\n <polygon points=\"11 3 9 9 16 9 9 17 11 11 4 11 11 3\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"></polygon>\n </symbol>\n</svg>";
4
+ declare const getEditorIconSvg: (name: SVGSpriteNames, size?: number) => string;
5
+ //#endregion
6
+ export { SVGSpriteNames, SVGSpriteSheet, getEditorIconSvg };
7
+ //# sourceMappingURL=sprite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sprite.d.ts","names":["SVGSpriteNames","SVGSpriteSheet","getEditorIconSvg"],"sources":["../../src/editor/sprite.d.ts"],"sourcesContent":["export type SVGSpriteNames = 'arrow-down' | 'arrow-up' | 'case' | 'close' | 'quick' | 'regex' | 'search' | 'whole-word';\nexport declare const SVGSpriteSheet = \"<svg data-editor-icon-sprite aria-hidden=\\\"true\\\" width=\\\"0\\\" height=\\\"0\\\">\\n <symbol id=\\\"diffs-editor-icon-search\\\" viewBox=\\\"0 0 16 16\\\">\\n <path fill=\\\"currentColor\\\" fill-rule=\\\"evenodd\\\" clip-rule=\\\"evenodd\\\" d=\\\"M10.7747 12.8961C9.68558 13.5948 8.39011 14 7 14C3.13401 14 0 10.866 0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 8.39011 13.5948 9.68558 12.8961 10.7747L15.5607 13.4393C16.1464 14.0251 16.1464 14.9749 15.5607 15.5607C14.9749 16.1464 14.0251 16.1464 13.4393 15.5607L10.7747 12.8961ZM7 1.5C10.0376 1.5 12.5 3.96243 12.5 7C12.5 10.0376 10.0376 12.5 7 12.5C3.96243 12.5 1.5 10.0376 1.5 7C1.5 3.96243 3.96243 1.5 7 1.5Z\\\"></path>\\n </symbol>\\n <symbol id=\\\"diffs-editor-icon-close\\\" viewBox=\\\"0 0 16 16\\\">\\n <path fill=\\\"currentColor\\\" d=\\\"M3.21967 3.21967C3.51256 2.92678 3.98744 2.92678 4.28033 3.21967L8 6.93934L11.7197 3.21967C12.0126 2.92678 12.4874 2.92678 12.7803 3.21967C13.0732 3.51256 13.0732 3.98744 12.7803 4.28033L9.06066 8L12.7803 11.7197C13.0732 12.0126 13.0732 12.4874 12.7803 12.7803C12.4874 13.0732 12.0126 13.0732 11.7197 12.7803L8 9.06066L4.28033 12.7803C3.98744 13.0732 3.51256 13.0732 3.21967 12.7803C2.92678 12.4874 2.92678 12.0126 3.21967 11.7197L6.93934 8L3.21967 4.28033C2.92678 3.98744 2.92678 3.51256 3.21967 3.21967Z\\\"></path>\\n </symbol>\\n <symbol id=\\\"diffs-editor-icon-arrow-up\\\" viewBox=\\\"0 0 16 16\\\">\\n <path fill=\\\"currentColor\\\" transform=\\\"rotate(-90 8 8)\\\" d=\\\"M8.46967 4.21967C8.17678 4.51256 8.17678 4.98744 8.46967 5.28033L10.4393 7.25H3.75C3.33579 7.25 3 7.58579 3 8C3 8.41421 3.33579 8.75 3.75 8.75H10.4393L8.46967 10.7197C8.17678 11.0126 8.17678 11.4874 8.46967 11.7803C8.76256 12.0732 9.23744 12.0732 9.53033 11.7803L12.7803 8.53033C13.0732 8.23744 13.0732 7.76256 12.7803 7.46967L9.53033 4.21967C9.23744 3.92678 8.76256 3.92678 8.46967 4.21967Z\\\"></path>\\n </symbol>\\n <symbol id=\\\"diffs-editor-icon-arrow-down\\\" viewBox=\\\"0 0 16 16\\\">\\n <path fill=\\\"currentColor\\\" transform=\\\"rotate(90 8 8)\\\" d=\\\"M8.46967 4.21967C8.17678 4.51256 8.17678 4.98744 8.46967 5.28033L10.4393 7.25H3.75C3.33579 7.25 3 7.58579 3 8C3 8.41421 3.33579 8.75 3.75 8.75H10.4393L8.46967 10.7197C8.17678 11.0126 8.17678 11.4874 8.46967 11.7803C8.76256 12.0732 9.23744 12.0732 9.53033 11.7803L12.7803 8.53033C13.0732 8.23744 13.0732 7.76256 12.7803 7.46967L9.53033 4.21967C9.23744 3.92678 8.76256 3.92678 8.46967 4.21967Z\\\"></path>\\n </symbol>\\n <symbol id=\\\"diffs-editor-icon-case\\\" viewBox=\\\"0 0 16 16\\\">\\n <path fill=\\\"currentColor\\\" d=\\\"M12.2969 12.9969C10.7109 12.9969 9.61719 12.0125 9.61719 10.5047C9.61719 9.06719 10.6172 8.16094 12.5 8.15312H14.6641V7.31719C14.6641 6.23906 14.0391 5.64531 12.9297 5.64531C11.875 5.64531 11.2734 6.18437 11.1953 7.00469H9.92969C10.0156 5.56719 10.9922 4.52031 12.9766 4.52031C14.7266 4.52031 16 5.47344 16 7.2V12.8641H14.7109V11.8406H14.6719C14.2578 12.5047 13.5078 12.9969 12.2969 12.9969ZM12.6562 11.8797C13.8047 11.8797 14.6641 11.1609 14.6641 10.1375V9.18437H12.6016C11.4766 9.18437 10.9922 9.71562 10.9922 10.4578C10.9922 11.4266 11.7969 11.8797 12.6562 11.8797Z\\\"></path>\\n <path fill=\\\"currentColor\\\" d=\\\"M1.42188 12.8641H0L3.79688 2H5.1875L8.98438 12.8641H7.54688L6.46875 9.66094H2.5L1.42188 12.8641ZM4.50781 3.60938H4.46875L2.86719 8.55937H6.10156L4.50781 3.60938Z\\\"></path>\\n </symbol>\\n <symbol id=\\\"diffs-editor-icon-whole-word\\\" viewBox=\\\"0 0 16 16\\\">\\n <path fill=\\\"currentColor\\\" d=\\\"M11.4089 9.99449C11.1417 9.99449 10.8961 9.95595 10.6722 9.87887C10.4519 9.80179 10.2605 9.69167 10.098 9.54852C9.93551 9.40537 9.81453 9.23469 9.73508 9.03648H9.67007V9.91191H8.5V2H9.70258V5.01721H9.76758C9.81092 4.86671 9.88314 4.7309 9.98426 4.60977C10.089 4.48497 10.2136 4.37853 10.358 4.29043C10.5025 4.19867 10.6668 4.13076 10.851 4.08672C11.0352 4.039 11.2302 4.01514 11.436 4.01514C11.8802 4.01514 12.2648 4.11792 12.5898 4.32347C12.9149 4.52535 13.164 4.81532 13.3374 5.19339C13.5107 5.57146 13.5974 6.02478 13.5974 6.55334V7.45079C13.5974 7.97568 13.5089 8.429 13.332 8.81074C13.1586 9.1888 12.9076 9.48061 12.579 9.68617C12.2504 9.89172 11.8604 9.99449 11.4089 9.99449ZM11.0785 8.99243C11.353 8.99243 11.5859 8.92636 11.7773 8.79422C11.9723 8.66208 12.1204 8.46937 12.2215 8.2161C12.3226 7.95916 12.3732 7.65267 12.3732 7.29663V6.73503C12.3732 6.37164 12.3208 6.06332 12.2161 5.81005C12.115 5.55311 11.9669 5.35673 11.7719 5.22092C11.5769 5.08511 11.3385 5.01721 11.0568 5.01721C10.7824 5.01721 10.5422 5.08328 10.3364 5.21542C10.1341 5.34389 9.97704 5.52925 9.86509 5.77151C9.75675 6.01009 9.70258 6.2964 9.70258 6.63042V7.47281C9.70258 7.77013 9.76036 8.03441 9.87592 8.26566C9.99509 8.49323 10.1576 8.67125 10.3635 8.79972C10.5729 8.92819 10.8113 8.99243 11.0785 8.99243Z\\\"></path>\\n <path fill=\\\"currentColor\\\" d=\\\"M4.70482 9.99449C4.15229 9.99449 3.70087 9.83482 3.35057 9.51548C3.00388 9.19247 2.83054 8.75935 2.83054 8.2161C2.83054 7.70223 3.00207 7.28745 3.34515 6.97178C3.69184 6.65244 4.19562 6.49277 4.8565 6.49277H6.30284V5.94769C6.30284 5.61367 6.20533 5.36774 6.01032 5.20991C5.81531 5.04841 5.55349 4.96765 5.22485 4.96765C5.00817 4.96765 4.82941 4.99702 4.68857 5.05575C4.54773 5.11081 4.43758 5.18789 4.35813 5.28699C4.27868 5.38243 4.22271 5.49621 4.19021 5.62835H3.04722C3.06527 5.3861 3.12305 5.16586 3.22056 4.96765C3.32168 4.76577 3.46252 4.59326 3.64309 4.4501C3.82727 4.30328 4.05297 4.19133 4.32021 4.11425C4.59106 4.03716 4.90525 3.99862 5.26277 3.99862C5.67086 3.99862 6.04463 4.06286 6.38409 4.19133C6.72356 4.31613 6.99441 4.52168 7.19665 4.80798C7.39888 5.09429 7.5 5.4797 7.5 5.96421V9.9064H6.35701V9.1521H6.30284C6.21978 9.29892 6.10783 9.43657 5.96698 9.56504C5.82614 9.69351 5.65099 9.79812 5.44153 9.87887C5.23569 9.95595 4.99012 9.99449 4.70482 9.99449ZM5.07318 9.04749C5.3043 9.04749 5.51196 8.99977 5.69613 8.90434C5.88031 8.80523 6.02657 8.67309 6.13491 8.50791C6.24686 8.34274 6.30284 8.1537 6.30284 7.94081V7.31314H5.04609C4.69579 7.31314 4.43939 7.39206 4.27688 7.5499C4.11798 7.70773 4.03853 7.90961 4.03853 8.15554C4.03853 8.4602 4.14326 8.68594 4.35272 8.83276C4.56578 8.97591 4.80594 9.04749 5.07318 9.04749Z\\\"></path>\\n <path fill=\\\"currentColor\\\" d=\\\"M2.5 12.5L13.5 12.5C14.3284 12.5 15 11.8284 15 11V9.5C15 9.22386 15.2239 9 15.5 9C15.7761 9 16 9.22386 16 9.5V11C16 12.3807 14.8807 13.5 13.5 13.5L2.5 13.5C1.11929 13.5 -7.56324e-07 12.3807 0 11L6.55675e-08 9.5C3.58362e-07 9.22386 0.223858 9 0.5 9C0.776142 9 1 9.22386 1 9.5L1 11C0.999999 11.8284 1.67157 12.5 2.5 12.5Z\\\"></path>\\n </symbol>\\n <symbol id=\\\"diffs-editor-icon-regex\\\" viewBox=\\\"0 0 16 16\\\">\\n <path fill=\\\"currentColor\\\" d=\\\"M8.60788 6.59074C8.78227 6.46701 9.02141 6.60508 9.00146 6.81797L8.77564 9.22666C8.76189 9.37331 8.87726 9.5 9.02455 9.5H9.97548C10.1228 9.5 10.2381 9.37331 10.2244 9.22667L9.99858 6.81801C9.97862 6.60513 10.2178 6.46706 10.3922 6.59079L12.3652 7.99066C12.4853 8.07589 12.6527 8.03932 12.7264 7.91177L13.2018 7.08823C13.2755 6.96068 13.2234 6.79742 13.0896 6.73601L10.8907 5.72723C10.6963 5.63807 10.6963 5.36193 10.8907 5.27277L13.0896 4.264C13.2234 4.20258 13.2755 4.03932 13.2018 3.91177L12.7263 3.08824C12.6527 2.96068 12.4853 2.92411 12.3652 3.00934L10.3922 4.40921C10.2178 4.53294 9.97862 4.39486 9.99858 4.18198L10.2244 1.77334C10.2381 1.62669 10.1228 1.5 9.97548 1.5H9.02455C8.87726 1.5 8.76189 1.62669 8.77564 1.77334L9.00146 4.18203C9.02141 4.39491 8.78227 4.53298 8.60788 4.40926L6.63479 3.00934C6.51466 2.92411 6.34726 2.96068 6.27362 3.08823L5.79815 3.91177C5.72451 4.03932 5.77654 4.20258 5.91041 4.26399L8.10929 5.27277C8.30363 5.36193 8.30363 5.63807 8.10929 5.72723L5.91041 6.73601C5.77653 6.79742 5.7245 6.96068 5.79814 7.08824L6.27361 7.91177C6.34725 8.03932 6.51466 8.07589 6.63478 7.99066L8.60788 6.59074Z\\\"></path>\\n <path fill=\\\"currentColor\\\" d=\\\"M4 11C3.44772 11 3 11.4477 3 12V13C3 13.5523 3.44772 14 4 14H5C5.55228 14 6 13.5523 6 13V12C6 11.4477 5.55228 11 5 11H4Z\\\"></path>\\n </symbol>\\n <symbol id=\\\"diffs-editor-icon-quick\\\" viewBox=\\\"0 0 20 20\\\">\\n <polygon points=\\\"11 3 9 9 16 9 9 17 11 11 4 11 11 3\\\" fill=\\\"currentColor\\\" stroke=\\\"currentColor\\\" stroke-linecap=\\\"round\\\" stroke-linejoin=\\\"round\\\" stroke-width=\\\"2\\\"></polygon>\\n </symbol>\\n</svg>\";\nexport declare const getEditorIconSvg: (name: SVGSpriteNames, size?: number) => string;\n//# sourceMappingURL=sprite.d.ts.map"],"mappings":";KAAYA,cAAAA;AAAAA,cACSC,cAAAA,GADK,w+PAAA;AACLA,cACAC,gBADc,EAAA,CAAA,IAAA,EACWF,cADX,EAAA,IAAA,CAAA,EAAA,MAAA,EAAA,GAAA,MAAA"}
@@ -0,0 +1,38 @@
1
+ //#region src/editor/sprite.ts
2
+ const SVGSpriteSheet = `<svg data-editor-icon-sprite aria-hidden="true" width="0" height="0">
3
+ <symbol id="diffs-editor-icon-search" viewBox="0 0 16 16">
4
+ <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M10.7747 12.8961C9.68558 13.5948 8.39011 14 7 14C3.13401 14 0 10.866 0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 8.39011 13.5948 9.68558 12.8961 10.7747L15.5607 13.4393C16.1464 14.0251 16.1464 14.9749 15.5607 15.5607C14.9749 16.1464 14.0251 16.1464 13.4393 15.5607L10.7747 12.8961ZM7 1.5C10.0376 1.5 12.5 3.96243 12.5 7C12.5 10.0376 10.0376 12.5 7 12.5C3.96243 12.5 1.5 10.0376 1.5 7C1.5 3.96243 3.96243 1.5 7 1.5Z"></path>
5
+ </symbol>
6
+ <symbol id="diffs-editor-icon-close" viewBox="0 0 16 16">
7
+ <path fill="currentColor" d="M3.21967 3.21967C3.51256 2.92678 3.98744 2.92678 4.28033 3.21967L8 6.93934L11.7197 3.21967C12.0126 2.92678 12.4874 2.92678 12.7803 3.21967C13.0732 3.51256 13.0732 3.98744 12.7803 4.28033L9.06066 8L12.7803 11.7197C13.0732 12.0126 13.0732 12.4874 12.7803 12.7803C12.4874 13.0732 12.0126 13.0732 11.7197 12.7803L8 9.06066L4.28033 12.7803C3.98744 13.0732 3.51256 13.0732 3.21967 12.7803C2.92678 12.4874 2.92678 12.0126 3.21967 11.7197L6.93934 8L3.21967 4.28033C2.92678 3.98744 2.92678 3.51256 3.21967 3.21967Z"></path>
8
+ </symbol>
9
+ <symbol id="diffs-editor-icon-arrow-up" viewBox="0 0 16 16">
10
+ <path fill="currentColor" transform="rotate(-90 8 8)" d="M8.46967 4.21967C8.17678 4.51256 8.17678 4.98744 8.46967 5.28033L10.4393 7.25H3.75C3.33579 7.25 3 7.58579 3 8C3 8.41421 3.33579 8.75 3.75 8.75H10.4393L8.46967 10.7197C8.17678 11.0126 8.17678 11.4874 8.46967 11.7803C8.76256 12.0732 9.23744 12.0732 9.53033 11.7803L12.7803 8.53033C13.0732 8.23744 13.0732 7.76256 12.7803 7.46967L9.53033 4.21967C9.23744 3.92678 8.76256 3.92678 8.46967 4.21967Z"></path>
11
+ </symbol>
12
+ <symbol id="diffs-editor-icon-arrow-down" viewBox="0 0 16 16">
13
+ <path fill="currentColor" transform="rotate(90 8 8)" d="M8.46967 4.21967C8.17678 4.51256 8.17678 4.98744 8.46967 5.28033L10.4393 7.25H3.75C3.33579 7.25 3 7.58579 3 8C3 8.41421 3.33579 8.75 3.75 8.75H10.4393L8.46967 10.7197C8.17678 11.0126 8.17678 11.4874 8.46967 11.7803C8.76256 12.0732 9.23744 12.0732 9.53033 11.7803L12.7803 8.53033C13.0732 8.23744 13.0732 7.76256 12.7803 7.46967L9.53033 4.21967C9.23744 3.92678 8.76256 3.92678 8.46967 4.21967Z"></path>
14
+ </symbol>
15
+ <symbol id="diffs-editor-icon-case" viewBox="0 0 16 16">
16
+ <path fill="currentColor" d="M12.2969 12.9969C10.7109 12.9969 9.61719 12.0125 9.61719 10.5047C9.61719 9.06719 10.6172 8.16094 12.5 8.15312H14.6641V7.31719C14.6641 6.23906 14.0391 5.64531 12.9297 5.64531C11.875 5.64531 11.2734 6.18437 11.1953 7.00469H9.92969C10.0156 5.56719 10.9922 4.52031 12.9766 4.52031C14.7266 4.52031 16 5.47344 16 7.2V12.8641H14.7109V11.8406H14.6719C14.2578 12.5047 13.5078 12.9969 12.2969 12.9969ZM12.6562 11.8797C13.8047 11.8797 14.6641 11.1609 14.6641 10.1375V9.18437H12.6016C11.4766 9.18437 10.9922 9.71562 10.9922 10.4578C10.9922 11.4266 11.7969 11.8797 12.6562 11.8797Z"></path>
17
+ <path fill="currentColor" d="M1.42188 12.8641H0L3.79688 2H5.1875L8.98438 12.8641H7.54688L6.46875 9.66094H2.5L1.42188 12.8641ZM4.50781 3.60938H4.46875L2.86719 8.55937H6.10156L4.50781 3.60938Z"></path>
18
+ </symbol>
19
+ <symbol id="diffs-editor-icon-whole-word" viewBox="0 0 16 16">
20
+ <path fill="currentColor" d="M11.4089 9.99449C11.1417 9.99449 10.8961 9.95595 10.6722 9.87887C10.4519 9.80179 10.2605 9.69167 10.098 9.54852C9.93551 9.40537 9.81453 9.23469 9.73508 9.03648H9.67007V9.91191H8.5V2H9.70258V5.01721H9.76758C9.81092 4.86671 9.88314 4.7309 9.98426 4.60977C10.089 4.48497 10.2136 4.37853 10.358 4.29043C10.5025 4.19867 10.6668 4.13076 10.851 4.08672C11.0352 4.039 11.2302 4.01514 11.436 4.01514C11.8802 4.01514 12.2648 4.11792 12.5898 4.32347C12.9149 4.52535 13.164 4.81532 13.3374 5.19339C13.5107 5.57146 13.5974 6.02478 13.5974 6.55334V7.45079C13.5974 7.97568 13.5089 8.429 13.332 8.81074C13.1586 9.1888 12.9076 9.48061 12.579 9.68617C12.2504 9.89172 11.8604 9.99449 11.4089 9.99449ZM11.0785 8.99243C11.353 8.99243 11.5859 8.92636 11.7773 8.79422C11.9723 8.66208 12.1204 8.46937 12.2215 8.2161C12.3226 7.95916 12.3732 7.65267 12.3732 7.29663V6.73503C12.3732 6.37164 12.3208 6.06332 12.2161 5.81005C12.115 5.55311 11.9669 5.35673 11.7719 5.22092C11.5769 5.08511 11.3385 5.01721 11.0568 5.01721C10.7824 5.01721 10.5422 5.08328 10.3364 5.21542C10.1341 5.34389 9.97704 5.52925 9.86509 5.77151C9.75675 6.01009 9.70258 6.2964 9.70258 6.63042V7.47281C9.70258 7.77013 9.76036 8.03441 9.87592 8.26566C9.99509 8.49323 10.1576 8.67125 10.3635 8.79972C10.5729 8.92819 10.8113 8.99243 11.0785 8.99243Z"></path>
21
+ <path fill="currentColor" d="M4.70482 9.99449C4.15229 9.99449 3.70087 9.83482 3.35057 9.51548C3.00388 9.19247 2.83054 8.75935 2.83054 8.2161C2.83054 7.70223 3.00207 7.28745 3.34515 6.97178C3.69184 6.65244 4.19562 6.49277 4.8565 6.49277H6.30284V5.94769C6.30284 5.61367 6.20533 5.36774 6.01032 5.20991C5.81531 5.04841 5.55349 4.96765 5.22485 4.96765C5.00817 4.96765 4.82941 4.99702 4.68857 5.05575C4.54773 5.11081 4.43758 5.18789 4.35813 5.28699C4.27868 5.38243 4.22271 5.49621 4.19021 5.62835H3.04722C3.06527 5.3861 3.12305 5.16586 3.22056 4.96765C3.32168 4.76577 3.46252 4.59326 3.64309 4.4501C3.82727 4.30328 4.05297 4.19133 4.32021 4.11425C4.59106 4.03716 4.90525 3.99862 5.26277 3.99862C5.67086 3.99862 6.04463 4.06286 6.38409 4.19133C6.72356 4.31613 6.99441 4.52168 7.19665 4.80798C7.39888 5.09429 7.5 5.4797 7.5 5.96421V9.9064H6.35701V9.1521H6.30284C6.21978 9.29892 6.10783 9.43657 5.96698 9.56504C5.82614 9.69351 5.65099 9.79812 5.44153 9.87887C5.23569 9.95595 4.99012 9.99449 4.70482 9.99449ZM5.07318 9.04749C5.3043 9.04749 5.51196 8.99977 5.69613 8.90434C5.88031 8.80523 6.02657 8.67309 6.13491 8.50791C6.24686 8.34274 6.30284 8.1537 6.30284 7.94081V7.31314H5.04609C4.69579 7.31314 4.43939 7.39206 4.27688 7.5499C4.11798 7.70773 4.03853 7.90961 4.03853 8.15554C4.03853 8.4602 4.14326 8.68594 4.35272 8.83276C4.56578 8.97591 4.80594 9.04749 5.07318 9.04749Z"></path>
22
+ <path fill="currentColor" d="M2.5 12.5L13.5 12.5C14.3284 12.5 15 11.8284 15 11V9.5C15 9.22386 15.2239 9 15.5 9C15.7761 9 16 9.22386 16 9.5V11C16 12.3807 14.8807 13.5 13.5 13.5L2.5 13.5C1.11929 13.5 -7.56324e-07 12.3807 0 11L6.55675e-08 9.5C3.58362e-07 9.22386 0.223858 9 0.5 9C0.776142 9 1 9.22386 1 9.5L1 11C0.999999 11.8284 1.67157 12.5 2.5 12.5Z"></path>
23
+ </symbol>
24
+ <symbol id="diffs-editor-icon-regex" viewBox="0 0 16 16">
25
+ <path fill="currentColor" d="M8.60788 6.59074C8.78227 6.46701 9.02141 6.60508 9.00146 6.81797L8.77564 9.22666C8.76189 9.37331 8.87726 9.5 9.02455 9.5H9.97548C10.1228 9.5 10.2381 9.37331 10.2244 9.22667L9.99858 6.81801C9.97862 6.60513 10.2178 6.46706 10.3922 6.59079L12.3652 7.99066C12.4853 8.07589 12.6527 8.03932 12.7264 7.91177L13.2018 7.08823C13.2755 6.96068 13.2234 6.79742 13.0896 6.73601L10.8907 5.72723C10.6963 5.63807 10.6963 5.36193 10.8907 5.27277L13.0896 4.264C13.2234 4.20258 13.2755 4.03932 13.2018 3.91177L12.7263 3.08824C12.6527 2.96068 12.4853 2.92411 12.3652 3.00934L10.3922 4.40921C10.2178 4.53294 9.97862 4.39486 9.99858 4.18198L10.2244 1.77334C10.2381 1.62669 10.1228 1.5 9.97548 1.5H9.02455C8.87726 1.5 8.76189 1.62669 8.77564 1.77334L9.00146 4.18203C9.02141 4.39491 8.78227 4.53298 8.60788 4.40926L6.63479 3.00934C6.51466 2.92411 6.34726 2.96068 6.27362 3.08823L5.79815 3.91177C5.72451 4.03932 5.77654 4.20258 5.91041 4.26399L8.10929 5.27277C8.30363 5.36193 8.30363 5.63807 8.10929 5.72723L5.91041 6.73601C5.77653 6.79742 5.7245 6.96068 5.79814 7.08824L6.27361 7.91177C6.34725 8.03932 6.51466 8.07589 6.63478 7.99066L8.60788 6.59074Z"></path>
26
+ <path fill="currentColor" d="M4 11C3.44772 11 3 11.4477 3 12V13C3 13.5523 3.44772 14 4 14H5C5.55228 14 6 13.5523 6 13V12C6 11.4477 5.55228 11 5 11H4Z"></path>
27
+ </symbol>
28
+ <symbol id="diffs-editor-icon-quick" viewBox="0 0 20 20">
29
+ <polygon points="11 3 9 9 16 9 9 17 11 11 4 11 11 3" fill="currentColor" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></polygon>
30
+ </symbol>
31
+ </svg>`;
32
+ const getEditorIconSvg = (name, size = 16) => `<svg width="${size}" height="${size}" aria-hidden="true" focusable="false">
33
+ <use href="#diffs-editor-icon-${name}"></use>
34
+ </svg>`;
35
+
36
+ //#endregion
37
+ export { SVGSpriteSheet, getEditorIconSvg };
38
+ //# sourceMappingURL=sprite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sprite.js","names":[],"sources":["../../src/editor/sprite.ts"],"sourcesContent":["export type SVGSpriteNames =\n | 'arrow-down'\n | 'arrow-up'\n | 'case'\n | 'close'\n | 'quick'\n | 'regex'\n | 'search'\n | 'whole-word';\n\n// Icon artwork is sourced from `@pierre/icons` (IconSearch, IconX,\n// IconArrowRightShort, IconType, IconTypeWord, IconRegex) so the editor matches\n// the rest of the product. The arrow glyph is the short right arrow rotated to\n// point up/down for the search \"previous\"/\"next\" controls. `quick` is the only\n// hand-authored glyph and uses its own 0 0 20 20 viewBox; `getEditorIconSvg`\n// omits an outer viewBox so each symbol scales to fill the requested size\n// regardless of its intrinsic coordinate system.\nexport const SVGSpriteSheet = `<svg data-editor-icon-sprite aria-hidden=\"true\" width=\"0\" height=\"0\">\n <symbol id=\"diffs-editor-icon-search\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M10.7747 12.8961C9.68558 13.5948 8.39011 14 7 14C3.13401 14 0 10.866 0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 8.39011 13.5948 9.68558 12.8961 10.7747L15.5607 13.4393C16.1464 14.0251 16.1464 14.9749 15.5607 15.5607C14.9749 16.1464 14.0251 16.1464 13.4393 15.5607L10.7747 12.8961ZM7 1.5C10.0376 1.5 12.5 3.96243 12.5 7C12.5 10.0376 10.0376 12.5 7 12.5C3.96243 12.5 1.5 10.0376 1.5 7C1.5 3.96243 3.96243 1.5 7 1.5Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-close\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" d=\"M3.21967 3.21967C3.51256 2.92678 3.98744 2.92678 4.28033 3.21967L8 6.93934L11.7197 3.21967C12.0126 2.92678 12.4874 2.92678 12.7803 3.21967C13.0732 3.51256 13.0732 3.98744 12.7803 4.28033L9.06066 8L12.7803 11.7197C13.0732 12.0126 13.0732 12.4874 12.7803 12.7803C12.4874 13.0732 12.0126 13.0732 11.7197 12.7803L8 9.06066L4.28033 12.7803C3.98744 13.0732 3.51256 13.0732 3.21967 12.7803C2.92678 12.4874 2.92678 12.0126 3.21967 11.7197L6.93934 8L3.21967 4.28033C2.92678 3.98744 2.92678 3.51256 3.21967 3.21967Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-arrow-up\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" transform=\"rotate(-90 8 8)\" d=\"M8.46967 4.21967C8.17678 4.51256 8.17678 4.98744 8.46967 5.28033L10.4393 7.25H3.75C3.33579 7.25 3 7.58579 3 8C3 8.41421 3.33579 8.75 3.75 8.75H10.4393L8.46967 10.7197C8.17678 11.0126 8.17678 11.4874 8.46967 11.7803C8.76256 12.0732 9.23744 12.0732 9.53033 11.7803L12.7803 8.53033C13.0732 8.23744 13.0732 7.76256 12.7803 7.46967L9.53033 4.21967C9.23744 3.92678 8.76256 3.92678 8.46967 4.21967Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-arrow-down\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" transform=\"rotate(90 8 8)\" d=\"M8.46967 4.21967C8.17678 4.51256 8.17678 4.98744 8.46967 5.28033L10.4393 7.25H3.75C3.33579 7.25 3 7.58579 3 8C3 8.41421 3.33579 8.75 3.75 8.75H10.4393L8.46967 10.7197C8.17678 11.0126 8.17678 11.4874 8.46967 11.7803C8.76256 12.0732 9.23744 12.0732 9.53033 11.7803L12.7803 8.53033C13.0732 8.23744 13.0732 7.76256 12.7803 7.46967L9.53033 4.21967C9.23744 3.92678 8.76256 3.92678 8.46967 4.21967Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-case\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" d=\"M12.2969 12.9969C10.7109 12.9969 9.61719 12.0125 9.61719 10.5047C9.61719 9.06719 10.6172 8.16094 12.5 8.15312H14.6641V7.31719C14.6641 6.23906 14.0391 5.64531 12.9297 5.64531C11.875 5.64531 11.2734 6.18437 11.1953 7.00469H9.92969C10.0156 5.56719 10.9922 4.52031 12.9766 4.52031C14.7266 4.52031 16 5.47344 16 7.2V12.8641H14.7109V11.8406H14.6719C14.2578 12.5047 13.5078 12.9969 12.2969 12.9969ZM12.6562 11.8797C13.8047 11.8797 14.6641 11.1609 14.6641 10.1375V9.18437H12.6016C11.4766 9.18437 10.9922 9.71562 10.9922 10.4578C10.9922 11.4266 11.7969 11.8797 12.6562 11.8797Z\"></path>\n <path fill=\"currentColor\" d=\"M1.42188 12.8641H0L3.79688 2H5.1875L8.98438 12.8641H7.54688L6.46875 9.66094H2.5L1.42188 12.8641ZM4.50781 3.60938H4.46875L2.86719 8.55937H6.10156L4.50781 3.60938Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-whole-word\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" d=\"M11.4089 9.99449C11.1417 9.99449 10.8961 9.95595 10.6722 9.87887C10.4519 9.80179 10.2605 9.69167 10.098 9.54852C9.93551 9.40537 9.81453 9.23469 9.73508 9.03648H9.67007V9.91191H8.5V2H9.70258V5.01721H9.76758C9.81092 4.86671 9.88314 4.7309 9.98426 4.60977C10.089 4.48497 10.2136 4.37853 10.358 4.29043C10.5025 4.19867 10.6668 4.13076 10.851 4.08672C11.0352 4.039 11.2302 4.01514 11.436 4.01514C11.8802 4.01514 12.2648 4.11792 12.5898 4.32347C12.9149 4.52535 13.164 4.81532 13.3374 5.19339C13.5107 5.57146 13.5974 6.02478 13.5974 6.55334V7.45079C13.5974 7.97568 13.5089 8.429 13.332 8.81074C13.1586 9.1888 12.9076 9.48061 12.579 9.68617C12.2504 9.89172 11.8604 9.99449 11.4089 9.99449ZM11.0785 8.99243C11.353 8.99243 11.5859 8.92636 11.7773 8.79422C11.9723 8.66208 12.1204 8.46937 12.2215 8.2161C12.3226 7.95916 12.3732 7.65267 12.3732 7.29663V6.73503C12.3732 6.37164 12.3208 6.06332 12.2161 5.81005C12.115 5.55311 11.9669 5.35673 11.7719 5.22092C11.5769 5.08511 11.3385 5.01721 11.0568 5.01721C10.7824 5.01721 10.5422 5.08328 10.3364 5.21542C10.1341 5.34389 9.97704 5.52925 9.86509 5.77151C9.75675 6.01009 9.70258 6.2964 9.70258 6.63042V7.47281C9.70258 7.77013 9.76036 8.03441 9.87592 8.26566C9.99509 8.49323 10.1576 8.67125 10.3635 8.79972C10.5729 8.92819 10.8113 8.99243 11.0785 8.99243Z\"></path>\n <path fill=\"currentColor\" d=\"M4.70482 9.99449C4.15229 9.99449 3.70087 9.83482 3.35057 9.51548C3.00388 9.19247 2.83054 8.75935 2.83054 8.2161C2.83054 7.70223 3.00207 7.28745 3.34515 6.97178C3.69184 6.65244 4.19562 6.49277 4.8565 6.49277H6.30284V5.94769C6.30284 5.61367 6.20533 5.36774 6.01032 5.20991C5.81531 5.04841 5.55349 4.96765 5.22485 4.96765C5.00817 4.96765 4.82941 4.99702 4.68857 5.05575C4.54773 5.11081 4.43758 5.18789 4.35813 5.28699C4.27868 5.38243 4.22271 5.49621 4.19021 5.62835H3.04722C3.06527 5.3861 3.12305 5.16586 3.22056 4.96765C3.32168 4.76577 3.46252 4.59326 3.64309 4.4501C3.82727 4.30328 4.05297 4.19133 4.32021 4.11425C4.59106 4.03716 4.90525 3.99862 5.26277 3.99862C5.67086 3.99862 6.04463 4.06286 6.38409 4.19133C6.72356 4.31613 6.99441 4.52168 7.19665 4.80798C7.39888 5.09429 7.5 5.4797 7.5 5.96421V9.9064H6.35701V9.1521H6.30284C6.21978 9.29892 6.10783 9.43657 5.96698 9.56504C5.82614 9.69351 5.65099 9.79812 5.44153 9.87887C5.23569 9.95595 4.99012 9.99449 4.70482 9.99449ZM5.07318 9.04749C5.3043 9.04749 5.51196 8.99977 5.69613 8.90434C5.88031 8.80523 6.02657 8.67309 6.13491 8.50791C6.24686 8.34274 6.30284 8.1537 6.30284 7.94081V7.31314H5.04609C4.69579 7.31314 4.43939 7.39206 4.27688 7.5499C4.11798 7.70773 4.03853 7.90961 4.03853 8.15554C4.03853 8.4602 4.14326 8.68594 4.35272 8.83276C4.56578 8.97591 4.80594 9.04749 5.07318 9.04749Z\"></path>\n <path fill=\"currentColor\" d=\"M2.5 12.5L13.5 12.5C14.3284 12.5 15 11.8284 15 11V9.5C15 9.22386 15.2239 9 15.5 9C15.7761 9 16 9.22386 16 9.5V11C16 12.3807 14.8807 13.5 13.5 13.5L2.5 13.5C1.11929 13.5 -7.56324e-07 12.3807 0 11L6.55675e-08 9.5C3.58362e-07 9.22386 0.223858 9 0.5 9C0.776142 9 1 9.22386 1 9.5L1 11C0.999999 11.8284 1.67157 12.5 2.5 12.5Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-regex\" viewBox=\"0 0 16 16\">\n <path fill=\"currentColor\" d=\"M8.60788 6.59074C8.78227 6.46701 9.02141 6.60508 9.00146 6.81797L8.77564 9.22666C8.76189 9.37331 8.87726 9.5 9.02455 9.5H9.97548C10.1228 9.5 10.2381 9.37331 10.2244 9.22667L9.99858 6.81801C9.97862 6.60513 10.2178 6.46706 10.3922 6.59079L12.3652 7.99066C12.4853 8.07589 12.6527 8.03932 12.7264 7.91177L13.2018 7.08823C13.2755 6.96068 13.2234 6.79742 13.0896 6.73601L10.8907 5.72723C10.6963 5.63807 10.6963 5.36193 10.8907 5.27277L13.0896 4.264C13.2234 4.20258 13.2755 4.03932 13.2018 3.91177L12.7263 3.08824C12.6527 2.96068 12.4853 2.92411 12.3652 3.00934L10.3922 4.40921C10.2178 4.53294 9.97862 4.39486 9.99858 4.18198L10.2244 1.77334C10.2381 1.62669 10.1228 1.5 9.97548 1.5H9.02455C8.87726 1.5 8.76189 1.62669 8.77564 1.77334L9.00146 4.18203C9.02141 4.39491 8.78227 4.53298 8.60788 4.40926L6.63479 3.00934C6.51466 2.92411 6.34726 2.96068 6.27362 3.08823L5.79815 3.91177C5.72451 4.03932 5.77654 4.20258 5.91041 4.26399L8.10929 5.27277C8.30363 5.36193 8.30363 5.63807 8.10929 5.72723L5.91041 6.73601C5.77653 6.79742 5.7245 6.96068 5.79814 7.08824L6.27361 7.91177C6.34725 8.03932 6.51466 8.07589 6.63478 7.99066L8.60788 6.59074Z\"></path>\n <path fill=\"currentColor\" d=\"M4 11C3.44772 11 3 11.4477 3 12V13C3 13.5523 3.44772 14 4 14H5C5.55228 14 6 13.5523 6 13V12C6 11.4477 5.55228 11 5 11H4Z\"></path>\n </symbol>\n <symbol id=\"diffs-editor-icon-quick\" viewBox=\"0 0 20 20\">\n <polygon points=\"11 3 9 9 16 9 9 17 11 11 4 11 11 3\" fill=\"currentColor\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"></polygon>\n </symbol>\n</svg>`;\n\nexport const getEditorIconSvg = (name: SVGSpriteNames, size = 16): string =>\n `<svg width=\"${size}\" height=\"${size}\" aria-hidden=\"true\" focusable=\"false\">\n<use href=\"#diffs-editor-icon-${name}\"></use>\n</svg>`;\n"],"mappings":";AAiBA,MAAa,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+B9B,MAAa,oBAAoB,MAAsB,OAAO,OAC5D,eAAe,KAAK,YAAY,KAAK;gCACP,KAAK"}
@@ -125,7 +125,7 @@ declare class TextDocument<LAnnotation> {
125
125
  charAt(position: Position): string;
126
126
  getTextSlice(start: number, end: number): string;
127
127
  findNextNonOverlappingSubstring(needle: string, occupied: readonly [start: number, end: number][]): number | undefined;
128
- search(kind: 'findNext' | 'findPrevious' | 'findAll' | 'replace' | 'replaceAll', searchParams: SearchParams, selection?: Range): [start: number, end: number][];
128
+ search(searchParams: SearchParams): [start: number, end: number][];
129
129
  applyEdits(edits: TextEdit[], updateHistory?: boolean, selectionsBefore?: EditorSelection[], selectionsAfter?: EditorSelection[]): TextDocumentChange | undefined;
130
130
  applyResolvedEdits(edits: ResolvedTextEdit[], updateHistory?: boolean, selectionsBefore?: EditorSelection[], selectionsAfter?: EditorSelection[]): TextDocumentChange | undefined;
131
131
  setLastUndoSelectionsAfter(selections: EditorSelection[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"textDocument.d.ts","names":["DiffLineAnnotation","EditStack","SearchParams","EditorSelection","Position","Range","TextEdit","ResolvedTextEdit","TextDocumentChange","TextDocument","LAnnotation"],"sources":["../../src/editor/textDocument.d.ts"],"sourcesContent":["import type { DiffLineAnnotation } from '../types';\nimport { EditStack } from './editStack';\nimport type { SearchParams } from './searchPanel';\nimport { type EditorSelection } from './selection';\n/**\n * Position in a text document expressed as zero-based line and character offset.\n * The offsets are based on a UTF-16 string representation. So a string of the form\n * `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`\n * is 1 and the character offset of b is 3 since `𐐀` is represented using two code\n * units in UTF-16.\n *\n * Positions are line end character agnostic. So you can not specify a position that\n * denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n */\nexport interface Position {\n /**\n * Line position in a document (zero-based).\n *\n * If a line number is greater than the number of lines in a document, it\n * defaults back to the number of lines in the document.\n * If a line number is negative, it defaults to 0.\n *\n * The above two properties are implementation specific.\n */\n readonly line: number;\n /**\n * Character offset on a line in a document (zero-based).\n *\n * The meaning of this offset is determined by the negotiated\n * `PositionEncodingKind`.\n *\n * If the character value is greater than the line length it defaults back\n * to the line length. This property is implementation specific.\n */\n readonly character: number;\n}\n/**\n * A range in a text document expressed as (zero-based) start and end positions.\n *\n * If you want to specify a range that contains a line including the line ending\n * character(s) then use an end position denoting the start of the next line.\n * For example:\n * ```ts\n * {\n * start: { line: 5, character: 23 }\n * end : { line 6, character : 0 }\n * }\n * ```\n */\nexport interface Range {\n /**\n * The range's start position.\n */\n readonly start: Position;\n /**\n * The range's end position.\n */\n readonly end: Position;\n}\n/**\n * A text edit applicable to a text document.\n */\nexport interface TextEdit {\n /**\n * The range of the text document to be manipulated. To insert\n * text into a document create a range where start === end.\n */\n readonly range: Range;\n /**\n * The string to be inserted. For delete operations use an\n * empty string.\n */\n readonly newText: string;\n}\n/** Different with `TextEdit`, the range has been resolved to offsets. */\nexport interface ResolvedTextEdit {\n /** The start offset of the text change. */\n readonly start: number;\n /** The end offset of the text change. */\n readonly end: number;\n /**\n * The string to be inserted. For delete operations use an\n * empty string.\n */\n readonly text: string;\n}\nexport interface TextDocumentChange {\n /** First line whose rendered content or tokenizer state may have changed. */\n readonly startLine: number;\n /** Character on the first changed line where the edit began. */\n readonly startCharacter: number;\n /** Last line whose rendered content may have changed after the edit. */\n readonly endLine: number;\n /** Line count before the edit was applied. */\n readonly previousLineCount: number;\n /** Line count after the edit was applied. */\n readonly lineCount: number;\n /** Difference between the old and new line counts. */\n readonly lineDelta: number;\n /** Exact rendered line ranges touched by each edit after the edit was applied. */\n readonly changedLineRanges?: readonly [startLine: number, endLine: number][];\n}\n/**\n * A vscode-languageserver-textdocument compatible text document.\n */\nexport declare class TextDocument<LAnnotation> {\n #private;\n constructor(uri: string, text: string, languageId?: string, version?: number, editStack?: EditStack<LAnnotation>);\n get uri(): string;\n get languageId(): string;\n get version(): number;\n get lineCount(): number;\n get canUndo(): boolean;\n get canRedo(): boolean;\n positionAt(offset: number): Position;\n positionsAt(offsets: readonly number[]): Position[];\n offsetAt(position: Position): number;\n offsetsAt(positions: readonly Position[]): number[];\n getText(range?: Range): string;\n getLineText(line: number, trimEOF?: boolean): string;\n charAt(offset: number): string;\n charAt(position: Position): string;\n getTextSlice(start: number, end: number): string;\n findNextNonOverlappingSubstring(needle: string, occupied: readonly [start: number, end: number][]): number | undefined;\n search(kind: 'findNext' | 'findPrevious' | 'findAll' | 'replace' | 'replaceAll', searchParams: SearchParams, selection?: Range): [start: number, end: number][];\n applyEdits(edits: TextEdit[], updateHistory?: boolean, selectionsBefore?: EditorSelection[], selectionsAfter?: EditorSelection[]): TextDocumentChange | undefined;\n applyResolvedEdits(edits: ResolvedTextEdit[], updateHistory?: boolean, selectionsBefore?: EditorSelection[], selectionsAfter?: EditorSelection[]): TextDocumentChange | undefined;\n setLastUndoSelectionsAfter(selections: EditorSelection[]): void;\n setLastUndoLineAnnotations(lineAnnotationsBefore: DiffLineAnnotation<LAnnotation>[], lineAnnotationsAfter: DiffLineAnnotation<LAnnotation>[]): void;\n undo(): [\n change: TextDocumentChange,\n selections?: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n ] | undefined;\n redo(): [\n change: TextDocumentChange,\n selections?: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n ] | undefined;\n normalizePosition(position: Position): Position;\n}\n//# sourceMappingURL=textDocument.d.ts.map"],"mappings":";;;;;;;;;AAcA;AAmCA;AAaA;AAaA;AAWA;AAmBA;;;AASgCI,UApGfA,QAAAA,CAoGeA;EACaA;;;;;;;;;EAUsED,SAAAA,IAAAA,EAAAA,MAAAA;EAAoBK;;;;;;;;;EAGxBR,SAAAA,SAAAA,EAAAA,MAAAA;;;;;;;;;;;;;;;UA/E9FK,KAAAA;;;;kBAIGD;;;;gBAIFA;;;;;UAKDE,QAAAA;;;;;kBAKGD;;;;;;;;UAQHE,gBAAAA;;;;;;;;;;;UAWAC,kBAAAA;;;;;;;;;;;;;;;;;;;cAmBIC;;4FAEyER,UAAUS;;;;;;;8BAOxEN;2CACaA;qBACtBA;gCACWA;kBACdC;;;mBAGCD;;;iGAG8EF,0BAA0BG;oBACvGC,wDAAwDH,qCAAqCA,oBAAoBK;4BACzGD,gEAAgEJ,qCAAqCA,oBAAoBK;yCAC5GL;oDACWH,mBAAmBU,sCAAsCV,mBAAmBU;mBAElHF,iCACKL,qCACKH,mBAAmBU;mBAG7BF,iCACKL,qCACKH,mBAAmBU;8BAEbN,WAAWA"}
1
+ {"version":3,"file":"textDocument.d.ts","names":["DiffLineAnnotation","EditStack","SearchParams","EditorSelection","Position","Range","TextEdit","ResolvedTextEdit","TextDocumentChange","TextDocument","LAnnotation"],"sources":["../../src/editor/textDocument.d.ts"],"sourcesContent":["import type { DiffLineAnnotation } from '../types';\nimport { EditStack } from './editStack';\nimport type { SearchParams } from './searchPanel';\nimport { type EditorSelection } from './selection';\n/**\n * Position in a text document expressed as zero-based line and character offset.\n * The offsets are based on a UTF-16 string representation. So a string of the form\n * `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`\n * is 1 and the character offset of b is 3 since `𐐀` is represented using two code\n * units in UTF-16.\n *\n * Positions are line end character agnostic. So you can not specify a position that\n * denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n */\nexport interface Position {\n /**\n * Line position in a document (zero-based).\n *\n * If a line number is greater than the number of lines in a document, it\n * defaults back to the number of lines in the document.\n * If a line number is negative, it defaults to 0.\n *\n * The above two properties are implementation specific.\n */\n readonly line: number;\n /**\n * Character offset on a line in a document (zero-based).\n *\n * The meaning of this offset is determined by the negotiated\n * `PositionEncodingKind`.\n *\n * If the character value is greater than the line length it defaults back\n * to the line length. This property is implementation specific.\n */\n readonly character: number;\n}\n/**\n * A range in a text document expressed as (zero-based) start and end positions.\n *\n * If you want to specify a range that contains a line including the line ending\n * character(s) then use an end position denoting the start of the next line.\n * For example:\n * ```ts\n * {\n * start: { line: 5, character: 23 }\n * end : { line 6, character : 0 }\n * }\n * ```\n */\nexport interface Range {\n /**\n * The range's start position.\n */\n readonly start: Position;\n /**\n * The range's end position.\n */\n readonly end: Position;\n}\n/**\n * A text edit applicable to a text document.\n */\nexport interface TextEdit {\n /**\n * The range of the text document to be manipulated. To insert\n * text into a document create a range where start === end.\n */\n readonly range: Range;\n /**\n * The string to be inserted. For delete operations use an\n * empty string.\n */\n readonly newText: string;\n}\n/** Different with `TextEdit`, the range has been resolved to offsets. */\nexport interface ResolvedTextEdit {\n /** The start offset of the text change. */\n readonly start: number;\n /** The end offset of the text change. */\n readonly end: number;\n /**\n * The string to be inserted. For delete operations use an\n * empty string.\n */\n readonly text: string;\n}\nexport interface TextDocumentChange {\n /** First line whose rendered content or tokenizer state may have changed. */\n readonly startLine: number;\n /** Character on the first changed line where the edit began. */\n readonly startCharacter: number;\n /** Last line whose rendered content may have changed after the edit. */\n readonly endLine: number;\n /** Line count before the edit was applied. */\n readonly previousLineCount: number;\n /** Line count after the edit was applied. */\n readonly lineCount: number;\n /** Difference between the old and new line counts. */\n readonly lineDelta: number;\n /** Exact rendered line ranges touched by each edit after the edit was applied. */\n readonly changedLineRanges?: readonly [startLine: number, endLine: number][];\n}\n/**\n * A vscode-languageserver-textdocument compatible text document.\n */\nexport declare class TextDocument<LAnnotation> {\n #private;\n constructor(uri: string, text: string, languageId?: string, version?: number, editStack?: EditStack<LAnnotation>);\n get uri(): string;\n get languageId(): string;\n get version(): number;\n get lineCount(): number;\n get canUndo(): boolean;\n get canRedo(): boolean;\n positionAt(offset: number): Position;\n positionsAt(offsets: readonly number[]): Position[];\n offsetAt(position: Position): number;\n offsetsAt(positions: readonly Position[]): number[];\n getText(range?: Range): string;\n getLineText(line: number, trimEOF?: boolean): string;\n charAt(offset: number): string;\n charAt(position: Position): string;\n getTextSlice(start: number, end: number): string;\n findNextNonOverlappingSubstring(needle: string, occupied: readonly [start: number, end: number][]): number | undefined;\n search(searchParams: SearchParams): [start: number, end: number][];\n applyEdits(edits: TextEdit[], updateHistory?: boolean, selectionsBefore?: EditorSelection[], selectionsAfter?: EditorSelection[]): TextDocumentChange | undefined;\n applyResolvedEdits(edits: ResolvedTextEdit[], updateHistory?: boolean, selectionsBefore?: EditorSelection[], selectionsAfter?: EditorSelection[]): TextDocumentChange | undefined;\n setLastUndoSelectionsAfter(selections: EditorSelection[]): void;\n setLastUndoLineAnnotations(lineAnnotationsBefore: DiffLineAnnotation<LAnnotation>[], lineAnnotationsAfter: DiffLineAnnotation<LAnnotation>[]): void;\n undo(): [\n change: TextDocumentChange,\n selections?: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n ] | undefined;\n redo(): [\n change: TextDocumentChange,\n selections?: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n ] | undefined;\n normalizePosition(position: Position): Position;\n}\n//# sourceMappingURL=textDocument.d.ts.map"],"mappings":";;;;;;;;;AAcA;AAmCA;AAaA;AAaA;AAWA;AAmBA;;;AASgCI,UApGfA,QAAAA,CAoGeA;EACaA;;;;;;;;;EAU0FI,SAAAA,IAAAA,EAAAA,MAAAA;EACzGD;;;;;;;;;EAIdC,SAAAA,SAAAA,EAAAA,MAAAA;;;;;;;;;;;;;;;UAjFCH,KAAAA;;;;kBAIGD;;;;gBAIFA;;;;;UAKDE,QAAAA;;;;;kBAKGD;;;;;;;;UAQHE,gBAAAA;;;;;;;;;;;UAWAC,kBAAAA;;;;;;;;;;;;;;;;;;;cAmBIC;;4FAEyER,UAAUS;;;;;;;8BAOxEN;2CACaA;qBACtBA;gCACWA;kBACdC;;;mBAGCD;;;uBAGIF;oBACHI,wDAAwDH,qCAAqCA,oBAAoBK;4BACzGD,gEAAgEJ,qCAAqCA,oBAAoBK;yCAC5GL;oDACWH,mBAAmBU,sCAAsCV,mBAAmBU;mBAElHF,iCACKL,qCACKH,mBAAmBU;mBAG7BF,iCACKL,qCACKH,mBAAmBU;8BAEbN,WAAWA"}
@@ -64,8 +64,8 @@ var TextDocument = class {
64
64
  findNextNonOverlappingSubstring(needle, occupied) {
65
65
  return this.#pieceTable.findNextNonOverlappingSubstring(needle, occupied);
66
66
  }
67
- search(kind, searchParams, selection) {
68
- return this.#pieceTable.search(kind, searchParams, selection);
67
+ search(searchParams) {
68
+ return this.#pieceTable.search(searchParams);
69
69
  }
70
70
  applyEdits(edits, updateHistory = false, selectionsBefore, selectionsAfter) {
71
71
  if (edits.length === 0) return;
@@ -1 +1 @@
1
- {"version":3,"file":"textDocument.js","names":["#uri","#languageId","#version","#pieceTable","#editStack","#resolveEdit","#sortAndValidateResolvedEdits","change","#applyResolvedEditsToBuffer","#computeChangedLineRange","ranges: [number, number][]"],"sources":["../../src/editor/textDocument.ts"],"sourcesContent":["import type { DiffLineAnnotation } from '../types';\nimport {\n coalesceEditStackEntries,\n createEditStackEntry,\n EditStack,\n shouldCoalesceEditStackEntry,\n} from './editStack';\nimport { PieceTable } from './pieceTable';\nimport type { SearchParams } from './searchPanel';\nimport { type EditorSelection } from './selection';\n\n/**\n * Position in a text document expressed as zero-based line and character offset.\n * The offsets are based on a UTF-16 string representation. So a string of the form\n * `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`\n * is 1 and the character offset of b is 3 since `𐐀` is represented using two code\n * units in UTF-16.\n *\n * Positions are line end character agnostic. So you can not specify a position that\n * denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n */\nexport interface Position {\n /**\n * Line position in a document (zero-based).\n *\n * If a line number is greater than the number of lines in a document, it\n * defaults back to the number of lines in the document.\n * If a line number is negative, it defaults to 0.\n *\n * The above two properties are implementation specific.\n */\n readonly line: number;\n /**\n * Character offset on a line in a document (zero-based).\n *\n * The meaning of this offset is determined by the negotiated\n * `PositionEncodingKind`.\n *\n * If the character value is greater than the line length it defaults back\n * to the line length. This property is implementation specific.\n */\n readonly character: number;\n}\n\n/**\n * A range in a text document expressed as (zero-based) start and end positions.\n *\n * If you want to specify a range that contains a line including the line ending\n * character(s) then use an end position denoting the start of the next line.\n * For example:\n * ```ts\n * {\n * start: { line: 5, character: 23 }\n * end : { line 6, character : 0 }\n * }\n * ```\n */\nexport interface Range {\n /**\n * The range's start position.\n */\n readonly start: Position;\n /**\n * The range's end position.\n */\n readonly end: Position;\n}\n\n/**\n * A text edit applicable to a text document.\n */\nexport interface TextEdit {\n /**\n * The range of the text document to be manipulated. To insert\n * text into a document create a range where start === end.\n */\n readonly range: Range;\n /**\n * The string to be inserted. For delete operations use an\n * empty string.\n */\n readonly newText: string;\n}\n\n/** Different with `TextEdit`, the range has been resolved to offsets. */\nexport interface ResolvedTextEdit {\n /** The start offset of the text change. */\n readonly start: number;\n /** The end offset of the text change. */\n readonly end: number;\n /**\n * The string to be inserted. For delete operations use an\n * empty string.\n */\n readonly text: string;\n}\n\nexport interface TextDocumentChange {\n /** First line whose rendered content or tokenizer state may have changed. */\n readonly startLine: number;\n /** Character on the first changed line where the edit began. */\n readonly startCharacter: number;\n /** Last line whose rendered content may have changed after the edit. */\n readonly endLine: number;\n /** Line count before the edit was applied. */\n readonly previousLineCount: number;\n /** Line count after the edit was applied. */\n readonly lineCount: number;\n /** Difference between the old and new line counts. */\n readonly lineDelta: number;\n /** Exact rendered line ranges touched by each edit after the edit was applied. */\n readonly changedLineRanges?: readonly [startLine: number, endLine: number][];\n}\n\n/**\n * A vscode-languageserver-textdocument compatible text document.\n */\nexport class TextDocument<LAnnotation> {\n #uri: string;\n #languageId: string;\n #version: number;\n #pieceTable: PieceTable;\n #editStack: EditStack<LAnnotation>;\n\n constructor(\n uri: string,\n text: string,\n languageId = 'plaintext',\n version = 0,\n editStack: EditStack<LAnnotation> = new EditStack()\n ) {\n this.#uri = new URL(uri, 'file://').toString();\n this.#languageId = languageId;\n this.#version = version;\n this.#pieceTable = new PieceTable(text);\n this.#editStack = editStack;\n }\n\n get uri(): string {\n return this.#uri;\n }\n\n get languageId(): string {\n return this.#languageId;\n }\n\n get version(): number {\n return this.#version;\n }\n\n get lineCount(): number {\n return this.#pieceTable.lineCount;\n }\n\n get canUndo(): boolean {\n return this.#editStack.canUndo;\n }\n\n get canRedo(): boolean {\n return this.#editStack.canRedo;\n }\n\n positionAt(offset: number): Position {\n return this.#pieceTable.positionAt(offset);\n }\n\n positionsAt(offsets: readonly number[]): Position[] {\n return this.#pieceTable.positionsAt(offsets);\n }\n\n offsetAt(position: Position): number {\n return this.#pieceTable.offsetAt(position);\n }\n\n offsetsAt(positions: readonly Position[]): number[] {\n return this.#pieceTable.offsetsAt(positions);\n }\n\n getText(range?: Range): string {\n return this.#pieceTable.getText(range);\n }\n\n getLineText(line: number, trimEOF = true): string {\n return this.#pieceTable.getLineText(line, trimEOF);\n }\n\n charAt(offset: number): string;\n charAt(position: Position): string;\n charAt(positionOrOffset: Position | number): string {\n if (typeof positionOrOffset === 'number') {\n return this.#pieceTable.charAt(positionOrOffset);\n }\n return this.#pieceTable.charAt(this.offsetAt(positionOrOffset));\n }\n\n getTextSlice(start: number, end: number): string {\n return this.#pieceTable.getTextSlice(start, end);\n }\n\n findNextNonOverlappingSubstring(\n needle: string,\n occupied: readonly [start: number, end: number][]\n ): number | undefined {\n return this.#pieceTable.findNextNonOverlappingSubstring(needle, occupied);\n }\n\n search(\n kind: 'findNext' | 'findPrevious' | 'findAll' | 'replace' | 'replaceAll',\n searchParams: SearchParams,\n selection?: Range\n ): [start: number, end: number][] {\n return this.#pieceTable.search(kind, searchParams, selection);\n }\n\n applyEdits(\n edits: TextEdit[],\n updateHistory = false,\n selectionsBefore?: EditorSelection[],\n selectionsAfter?: EditorSelection[]\n ): TextDocumentChange | undefined {\n if (edits.length === 0) {\n return;\n }\n return this.applyResolvedEdits(\n edits.map((edit) => this.#resolveEdit(edit)),\n updateHistory,\n selectionsBefore,\n selectionsAfter\n );\n }\n\n applyResolvedEdits(\n edits: ResolvedTextEdit[],\n updateHistory = false,\n selectionsBefore?: EditorSelection[],\n selectionsAfter?: EditorSelection[]\n ): TextDocumentChange | undefined {\n if (edits.length === 0) {\n return undefined;\n }\n const resolvedEdits = this.#sortAndValidateResolvedEdits(edits);\n if (updateHistory) {\n const entry = createEditStackEntry(\n this,\n resolvedEdits,\n this.#version,\n this.#version + 1,\n selectionsBefore,\n selectionsAfter\n );\n const previousEntry = this.#editStack.peekUndo();\n const change = this.#applyResolvedEditsToBuffer(resolvedEdits);\n this.#version++;\n if (\n change.lineDelta === 0 &&\n shouldCoalesceEditStackEntry(previousEntry, entry)\n ) {\n this.#editStack.replaceLastUndo(\n coalesceEditStackEntries(previousEntry!, entry)\n );\n } else {\n this.#editStack.push(entry);\n }\n return change;\n }\n const change = this.#applyResolvedEditsToBuffer(resolvedEdits);\n this.#version++;\n return change;\n }\n\n setLastUndoSelectionsAfter(selections: EditorSelection[]): void {\n this.#editStack.setLastUndoSelectionsAfter(selections);\n }\n\n setLastUndoLineAnnotations(\n lineAnnotationsBefore: DiffLineAnnotation<LAnnotation>[],\n lineAnnotationsAfter: DiffLineAnnotation<LAnnotation>[]\n ): void {\n this.#editStack.setLastUndoLineAnnotations(\n lineAnnotationsBefore,\n lineAnnotationsAfter\n );\n }\n\n undo():\n | [\n change: TextDocumentChange,\n selections?: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[],\n ]\n | undefined {\n const entry = this.#editStack.popUndoToRedo();\n if (entry === undefined) {\n return undefined;\n }\n const change = this.#applyResolvedEditsToBuffer(entry.inverseEdits);\n if (change === undefined) {\n return undefined;\n }\n this.#version = entry.versionBefore;\n return [\n change,\n entry.selectionsBefore?.slice(),\n entry.lineAnnotationsBefore?.slice(),\n ];\n }\n\n redo():\n | [\n change: TextDocumentChange,\n selections?: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[],\n ]\n | undefined {\n const entry = this.#editStack.popRedoToUndo();\n if (entry === undefined) {\n return undefined;\n }\n const change = this.#applyResolvedEditsToBuffer(entry.forwardEdits);\n if (change === undefined) {\n return undefined;\n }\n this.#version = entry.versionAfter;\n return [\n change,\n entry.selectionsAfter?.slice(),\n entry.lineAnnotationsAfter?.slice(),\n ];\n }\n\n normalizePosition(position: Position): Position {\n const line = Math.max(0, Math.min(position.line, this.lineCount - 1));\n return {\n line,\n character: Math.max(\n 0,\n Math.min(position.character, this.getLineText(line).length)\n ),\n };\n }\n\n #resolveEdit(edit: TextEdit): ResolvedTextEdit {\n let start = this.offsetAt(edit.range.start);\n let end = this.offsetAt(edit.range.end);\n if (start > end) {\n const t = start;\n start = end;\n end = t;\n }\n return { start, end, text: edit.newText };\n }\n\n #sortAndValidateResolvedEdits(edits: ResolvedTextEdit[]): ResolvedTextEdit[] {\n const sortedEdits = [...edits].sort((a, b) => a.start - b.start);\n for (let i = 0; i < sortedEdits.length - 1; i++) {\n if (sortedEdits[i].end > sortedEdits[i + 1].start) {\n throw new Error('Overlapping text edits are not supported');\n }\n }\n return sortedEdits;\n }\n\n #applyResolvedEditsToBuffer(edits: ResolvedTextEdit[]): TextDocumentChange {\n const previousLineCount = this.#pieceTable.lineCount;\n const editPositions = this.positionsAt(\n edits.flatMap((edit) => [edit.start, edit.end])\n );\n const changedLineRange = this.#computeChangedLineRange(\n edits,\n editPositions\n );\n const startPosition = editPositions[0];\n this.#pieceTable.applyEdits(edits);\n const lineCount = this.#pieceTable.lineCount;\n const change: TextDocumentChange = {\n startLine: changedLineRange.startLine,\n startCharacter: startPosition.character,\n endLine: Math.min(changedLineRange.endLine, Math.max(0, lineCount - 1)),\n previousLineCount,\n lineCount,\n lineDelta: lineCount - previousLineCount,\n changedLineRanges: changedLineRange.ranges,\n };\n return change;\n }\n\n #computeChangedLineRange(\n edits: ResolvedTextEdit[],\n editPositions: Position[]\n ): {\n startLine: number;\n endLine: number;\n ranges: [number, number][];\n } {\n let startLine = Infinity;\n let endLine = 0;\n let lineDeltaBeforeEdit = 0;\n const ranges: [number, number][] = [];\n for (let i = 0; i < edits.length; i++) {\n const edit = edits[i];\n const editStartLine = editPositions[i * 2].line;\n const editEndLine = editPositions[i * 2 + 1].line;\n const insertedLineSpan = lineFeedCount(edit.text);\n const changedStartLine = editStartLine + lineDeltaBeforeEdit;\n const changedEndLine = changedStartLine + insertedLineSpan;\n startLine = Math.min(startLine, editStartLine);\n endLine = Math.max(endLine, changedEndLine);\n const lastRange = ranges[ranges.length - 1];\n if (lastRange !== undefined && changedStartLine <= lastRange[1] + 1) {\n ranges[ranges.length - 1] = [\n lastRange[0],\n Math.max(lastRange[1], changedEndLine),\n ];\n } else {\n ranges.push([changedStartLine, changedEndLine]);\n }\n lineDeltaBeforeEdit += insertedLineSpan - (editEndLine - editStartLine);\n }\n if (startLine === Infinity) {\n return {\n startLine: 0,\n endLine: 0,\n ranges: [[0, 0]],\n };\n }\n return { startLine, endLine, ranges };\n }\n}\n\nfunction lineFeedCount(text: string): number {\n let count = 0;\n for (let i = 0; i < text.length; i++) {\n if (text.charCodeAt(i) === /* \\n */ 10) {\n count++;\n }\n }\n return count;\n}\n"],"mappings":";;;;;;;AAqHA,IAAa,eAAb,MAAuC;CACrC;CACA;CACA;CACA;CACA;CAEA,YACE,KACA,MACA,aAAa,aACb,UAAU,GACV,YAAoC,IAAI,WAAW,EACnD;AACA,QAAKA,MAAO,IAAI,IAAI,KAAK,UAAU,CAAC,UAAU;AAC9C,QAAKC,aAAc;AACnB,QAAKC,UAAW;AAChB,QAAKC,aAAc,IAAI,WAAW,KAAK;AACvC,QAAKC,YAAa;;CAGpB,IAAI,MAAc;AAChB,SAAO,MAAKJ;;CAGd,IAAI,aAAqB;AACvB,SAAO,MAAKC;;CAGd,IAAI,UAAkB;AACpB,SAAO,MAAKC;;CAGd,IAAI,YAAoB;AACtB,SAAO,MAAKC,WAAY;;CAG1B,IAAI,UAAmB;AACrB,SAAO,MAAKC,UAAW;;CAGzB,IAAI,UAAmB;AACrB,SAAO,MAAKA,UAAW;;CAGzB,WAAW,QAA0B;AACnC,SAAO,MAAKD,WAAY,WAAW,OAAO;;CAG5C,YAAY,SAAwC;AAClD,SAA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AC1B,UAAU,IACV,KAAK,IAAI,UAAU,IAAI,eAAe,CACvC;OAED,QAAO,KAAK,CAAC,kBAAkB,eAAe,CAAC;AAEjD,0BAAuB,oBAAoB,cAAc;;AAE3D,MAAI,cAAc,SAChB,QAAO;GACL,WAAW;GACX,SAAS;GACT,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;GACjB;AAEH,SAAO;GAAE;GAAW;GAAS;GAAQ;;;AAIzC,SAAS,cAAc,MAAsB;CAC3C,IAAI,QAAQ;AACZ,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,IAC/B,KAAI,KAAK,WAAW,EAAE,KAAc,GAClC;AAGJ,QAAO"}
1
+ {"version":3,"file":"textDocument.js","names":["#uri","#languageId","#version","#pieceTable","#editStack","#resolveEdit","#sortAndValidateResolvedEdits","change","#applyResolvedEditsToBuffer","#computeChangedLineRange","ranges: [number, number][]"],"sources":["../../src/editor/textDocument.ts"],"sourcesContent":["import type { DiffLineAnnotation } from '../types';\nimport {\n coalesceEditStackEntries,\n createEditStackEntry,\n EditStack,\n shouldCoalesceEditStackEntry,\n} from './editStack';\nimport { PieceTable } from './pieceTable';\nimport type { SearchParams } from './searchPanel';\nimport { type EditorSelection } from './selection';\n\n/**\n * Position in a text document expressed as zero-based line and character offset.\n * The offsets are based on a UTF-16 string representation. So a string of the form\n * `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`\n * is 1 and the character offset of b is 3 since `𐐀` is represented using two code\n * units in UTF-16.\n *\n * Positions are line end character agnostic. So you can not specify a position that\n * denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n */\nexport interface Position {\n /**\n * Line position in a document (zero-based).\n *\n * If a line number is greater than the number of lines in a document, it\n * defaults back to the number of lines in the document.\n * If a line number is negative, it defaults to 0.\n *\n * The above two properties are implementation specific.\n */\n readonly line: number;\n /**\n * Character offset on a line in a document (zero-based).\n *\n * The meaning of this offset is determined by the negotiated\n * `PositionEncodingKind`.\n *\n * If the character value is greater than the line length it defaults back\n * to the line length. This property is implementation specific.\n */\n readonly character: number;\n}\n\n/**\n * A range in a text document expressed as (zero-based) start and end positions.\n *\n * If you want to specify a range that contains a line including the line ending\n * character(s) then use an end position denoting the start of the next line.\n * For example:\n * ```ts\n * {\n * start: { line: 5, character: 23 }\n * end : { line 6, character : 0 }\n * }\n * ```\n */\nexport interface Range {\n /**\n * The range's start position.\n */\n readonly start: Position;\n /**\n * The range's end position.\n */\n readonly end: Position;\n}\n\n/**\n * A text edit applicable to a text document.\n */\nexport interface TextEdit {\n /**\n * The range of the text document to be manipulated. To insert\n * text into a document create a range where start === end.\n */\n readonly range: Range;\n /**\n * The string to be inserted. For delete operations use an\n * empty string.\n */\n readonly newText: string;\n}\n\n/** Different with `TextEdit`, the range has been resolved to offsets. */\nexport interface ResolvedTextEdit {\n /** The start offset of the text change. */\n readonly start: number;\n /** The end offset of the text change. */\n readonly end: number;\n /**\n * The string to be inserted. For delete operations use an\n * empty string.\n */\n readonly text: string;\n}\n\nexport interface TextDocumentChange {\n /** First line whose rendered content or tokenizer state may have changed. */\n readonly startLine: number;\n /** Character on the first changed line where the edit began. */\n readonly startCharacter: number;\n /** Last line whose rendered content may have changed after the edit. */\n readonly endLine: number;\n /** Line count before the edit was applied. */\n readonly previousLineCount: number;\n /** Line count after the edit was applied. */\n readonly lineCount: number;\n /** Difference between the old and new line counts. */\n readonly lineDelta: number;\n /** Exact rendered line ranges touched by each edit after the edit was applied. */\n readonly changedLineRanges?: readonly [startLine: number, endLine: number][];\n}\n\n/**\n * A vscode-languageserver-textdocument compatible text document.\n */\nexport class TextDocument<LAnnotation> {\n #uri: string;\n #languageId: string;\n #version: number;\n #pieceTable: PieceTable;\n #editStack: EditStack<LAnnotation>;\n\n constructor(\n uri: string,\n text: string,\n languageId = 'plaintext',\n version = 0,\n editStack: EditStack<LAnnotation> = new EditStack()\n ) {\n this.#uri = new URL(uri, 'file://').toString();\n this.#languageId = languageId;\n this.#version = version;\n this.#pieceTable = new PieceTable(text);\n this.#editStack = editStack;\n }\n\n get uri(): string {\n return this.#uri;\n }\n\n get languageId(): string {\n return this.#languageId;\n }\n\n get version(): number {\n return this.#version;\n }\n\n get lineCount(): number {\n return this.#pieceTable.lineCount;\n }\n\n get canUndo(): boolean {\n return this.#editStack.canUndo;\n }\n\n get canRedo(): boolean {\n return this.#editStack.canRedo;\n }\n\n positionAt(offset: number): Position {\n return this.#pieceTable.positionAt(offset);\n }\n\n positionsAt(offsets: readonly number[]): Position[] {\n return this.#pieceTable.positionsAt(offsets);\n }\n\n offsetAt(position: Position): number {\n return this.#pieceTable.offsetAt(position);\n }\n\n offsetsAt(positions: readonly Position[]): number[] {\n return this.#pieceTable.offsetsAt(positions);\n }\n\n getText(range?: Range): string {\n return this.#pieceTable.getText(range);\n }\n\n getLineText(line: number, trimEOF = true): string {\n return this.#pieceTable.getLineText(line, trimEOF);\n }\n\n charAt(offset: number): string;\n charAt(position: Position): string;\n charAt(positionOrOffset: Position | number): string {\n if (typeof positionOrOffset === 'number') {\n return this.#pieceTable.charAt(positionOrOffset);\n }\n return this.#pieceTable.charAt(this.offsetAt(positionOrOffset));\n }\n\n getTextSlice(start: number, end: number): string {\n return this.#pieceTable.getTextSlice(start, end);\n }\n\n findNextNonOverlappingSubstring(\n needle: string,\n occupied: readonly [start: number, end: number][]\n ): number | undefined {\n return this.#pieceTable.findNextNonOverlappingSubstring(needle, occupied);\n }\n\n search(searchParams: SearchParams): [start: number, end: number][] {\n return this.#pieceTable.search(searchParams);\n }\n\n applyEdits(\n edits: TextEdit[],\n updateHistory = false,\n selectionsBefore?: EditorSelection[],\n selectionsAfter?: EditorSelection[]\n ): TextDocumentChange | undefined {\n if (edits.length === 0) {\n return;\n }\n return this.applyResolvedEdits(\n edits.map((edit) => this.#resolveEdit(edit)),\n updateHistory,\n selectionsBefore,\n selectionsAfter\n );\n }\n\n applyResolvedEdits(\n edits: ResolvedTextEdit[],\n updateHistory = false,\n selectionsBefore?: EditorSelection[],\n selectionsAfter?: EditorSelection[]\n ): TextDocumentChange | undefined {\n if (edits.length === 0) {\n return undefined;\n }\n const resolvedEdits = this.#sortAndValidateResolvedEdits(edits);\n if (updateHistory) {\n const entry = createEditStackEntry(\n this,\n resolvedEdits,\n this.#version,\n this.#version + 1,\n selectionsBefore,\n selectionsAfter\n );\n const previousEntry = this.#editStack.peekUndo();\n const change = this.#applyResolvedEditsToBuffer(resolvedEdits);\n this.#version++;\n if (\n change.lineDelta === 0 &&\n shouldCoalesceEditStackEntry(previousEntry, entry)\n ) {\n this.#editStack.replaceLastUndo(\n coalesceEditStackEntries(previousEntry!, entry)\n );\n } else {\n this.#editStack.push(entry);\n }\n return change;\n }\n const change = this.#applyResolvedEditsToBuffer(resolvedEdits);\n this.#version++;\n return change;\n }\n\n setLastUndoSelectionsAfter(selections: EditorSelection[]): void {\n this.#editStack.setLastUndoSelectionsAfter(selections);\n }\n\n setLastUndoLineAnnotations(\n lineAnnotationsBefore: DiffLineAnnotation<LAnnotation>[],\n lineAnnotationsAfter: DiffLineAnnotation<LAnnotation>[]\n ): void {\n this.#editStack.setLastUndoLineAnnotations(\n lineAnnotationsBefore,\n lineAnnotationsAfter\n );\n }\n\n undo():\n | [\n change: TextDocumentChange,\n selections?: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[],\n ]\n | undefined {\n const entry = this.#editStack.popUndoToRedo();\n if (entry === undefined) {\n return undefined;\n }\n const change = this.#applyResolvedEditsToBuffer(entry.inverseEdits);\n if (change === undefined) {\n return undefined;\n }\n this.#version = entry.versionBefore;\n return [\n change,\n entry.selectionsBefore?.slice(),\n entry.lineAnnotationsBefore?.slice(),\n ];\n }\n\n redo():\n | [\n change: TextDocumentChange,\n selections?: EditorSelection[],\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[],\n ]\n | undefined {\n const entry = this.#editStack.popRedoToUndo();\n if (entry === undefined) {\n return undefined;\n }\n const change = this.#applyResolvedEditsToBuffer(entry.forwardEdits);\n if (change === undefined) {\n return undefined;\n }\n this.#version = entry.versionAfter;\n return [\n change,\n entry.selectionsAfter?.slice(),\n entry.lineAnnotationsAfter?.slice(),\n ];\n }\n\n normalizePosition(position: Position): Position {\n const line = Math.max(0, Math.min(position.line, this.lineCount - 1));\n return {\n line,\n character: Math.max(\n 0,\n Math.min(position.character, this.getLineText(line).length)\n ),\n };\n }\n\n #resolveEdit(edit: TextEdit): ResolvedTextEdit {\n let start = this.offsetAt(edit.range.start);\n let end = this.offsetAt(edit.range.end);\n if (start > end) {\n const t = start;\n start = end;\n end = t;\n }\n return { start, end, text: edit.newText };\n }\n\n #sortAndValidateResolvedEdits(edits: ResolvedTextEdit[]): ResolvedTextEdit[] {\n const sortedEdits = [...edits].sort((a, b) => a.start - b.start);\n for (let i = 0; i < sortedEdits.length - 1; i++) {\n if (sortedEdits[i].end > sortedEdits[i + 1].start) {\n throw new Error('Overlapping text edits are not supported');\n }\n }\n return sortedEdits;\n }\n\n #applyResolvedEditsToBuffer(edits: ResolvedTextEdit[]): TextDocumentChange {\n const previousLineCount = this.#pieceTable.lineCount;\n const editPositions = this.positionsAt(\n edits.flatMap((edit) => [edit.start, edit.end])\n );\n const changedLineRange = this.#computeChangedLineRange(\n edits,\n editPositions\n );\n const startPosition = editPositions[0];\n this.#pieceTable.applyEdits(edits);\n const lineCount = this.#pieceTable.lineCount;\n const change: TextDocumentChange = {\n startLine: changedLineRange.startLine,\n startCharacter: startPosition.character,\n endLine: Math.min(changedLineRange.endLine, Math.max(0, lineCount - 1)),\n previousLineCount,\n lineCount,\n lineDelta: lineCount - previousLineCount,\n changedLineRanges: changedLineRange.ranges,\n };\n return change;\n }\n\n #computeChangedLineRange(\n edits: ResolvedTextEdit[],\n editPositions: Position[]\n ): {\n startLine: number;\n endLine: number;\n ranges: [number, number][];\n } {\n let startLine = Infinity;\n let endLine = 0;\n let lineDeltaBeforeEdit = 0;\n const ranges: [number, number][] = [];\n for (let i = 0; i < edits.length; i++) {\n const edit = edits[i];\n const editStartLine = editPositions[i * 2].line;\n const editEndLine = editPositions[i * 2 + 1].line;\n const insertedLineSpan = lineFeedCount(edit.text);\n const changedStartLine = editStartLine + lineDeltaBeforeEdit;\n const changedEndLine = changedStartLine + insertedLineSpan;\n startLine = Math.min(startLine, editStartLine);\n endLine = Math.max(endLine, changedEndLine);\n const lastRange = ranges[ranges.length - 1];\n if (lastRange !== undefined && changedStartLine <= lastRange[1] + 1) {\n ranges[ranges.length - 1] = [\n lastRange[0],\n Math.max(lastRange[1], changedEndLine),\n ];\n } else {\n ranges.push([changedStartLine, changedEndLine]);\n }\n lineDeltaBeforeEdit += insertedLineSpan - (editEndLine - editStartLine);\n }\n if (startLine === Infinity) {\n return {\n startLine: 0,\n endLine: 0,\n ranges: [[0, 0]],\n };\n }\n return { startLine, endLine, ranges };\n }\n}\n\nfunction lineFeedCount(text: string): number {\n let count = 0;\n for (let i = 0; i < text.length; i++) {\n if (text.charCodeAt(i) === /* \\n */ 10) {\n count++;\n }\n }\n return count;\n}\n"],"mappings":";;;;;;;AAqHA,IAAa,eAAb,MAAuC;CACrC;CACA;CACA;CACA;CACA;CAEA,YACE,KACA,MACA,aAAa,aACb,UAAU,GACV,YAAoC,IAAI,WAAW,EACnD;AACA,QAAKA,MAAO,IAAI,IAAI,KAAK,UAAU,CAAC,UAAU;AAC9C,QAAKC,aAAc;AACnB,QAAKC,UAAW;AAChB,QAAKC,aAAc,IAAI,WAAW,KAAK;AACvC,QAAKC,YAAa;;CAGpB,IAAI,MAAc;AAChB,SAAO,MAAKJ;;CAGd,IAAI,aAAqB;AACvB,SAAO,MAAKC;;CAGd,IAAI,UAAkB;AACpB,SAAO,MAAKC;;CAGd,IAAI,YAAoB;AACtB,SAAO,MAAKC,WAAY;;CAG1B,IAAI,UAAmB;AACrB,SAAO,MAAKC,UAAW;;CAGzB,IAAI,UAAmB;AACrB,SAAO,MAAKA,UAAW;;CAGzB,WAAW,QAA0B;AACnC,SAAO,MAAKD,WAAY,WAAW,OAAO;;CAG5C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