@pierre/diffs 1.3.0-beta.8 → 1.3.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CodeView.d.ts +12 -12
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +51 -43
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +7 -2
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +36 -8
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +34 -6
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +198 -17
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.d.ts.map +1 -1
- package/dist/components/FileStream.js +2 -1
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +2 -1
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +9 -5
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +14 -0
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +61 -3
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +14 -2
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +29 -3
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/edit/index.d.ts +5 -0
- package/dist/edit/index.js +3 -0
- package/dist/editor/command.d.ts +1 -1
- package/dist/editor/command.d.ts.map +1 -1
- package/dist/editor/command.js +11 -0
- package/dist/editor/command.js.map +1 -1
- package/dist/editor/editStack.d.ts +6 -2
- package/dist/editor/editStack.d.ts.map +1 -1
- package/dist/editor/editStack.js +54 -13
- package/dist/editor/editStack.js.map +1 -1
- package/dist/editor/editor.d.ts +51 -23
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +995 -242
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +1 -1
- package/dist/editor/languages.d.ts +26 -0
- package/dist/editor/languages.d.ts.map +1 -0
- package/dist/editor/languages.js +363 -0
- package/dist/editor/languages.js.map +1 -0
- package/dist/editor/lineAnnotations.d.ts.map +1 -1
- package/dist/editor/lineAnnotations.js +25 -26
- package/dist/editor/lineAnnotations.js.map +1 -1
- package/dist/editor/marker.d.ts +5 -3
- package/dist/editor/marker.d.ts.map +1 -1
- package/dist/editor/marker.js +111 -91
- package/dist/editor/marker.js.map +1 -1
- package/dist/editor/matchBrackets.d.ts +3 -2
- package/dist/editor/matchBrackets.d.ts.map +1 -1
- package/dist/editor/matchBrackets.js +2 -10
- package/dist/editor/matchBrackets.js.map +1 -1
- package/dist/editor/pieceTable.d.ts +2 -1
- package/dist/editor/pieceTable.d.ts.map +1 -1
- package/dist/editor/pieceTable.js +103 -39
- package/dist/editor/pieceTable.js.map +1 -1
- package/dist/editor/platform.js +2 -0
- package/dist/editor/platform.js.map +1 -1
- package/dist/editor/popover.d.ts +25 -5
- package/dist/editor/popover.d.ts.map +1 -1
- package/dist/editor/popover.js +60 -14
- package/dist/editor/popover.js.map +1 -1
- package/dist/editor/searchPanel.d.ts +1 -0
- package/dist/editor/searchPanel.d.ts.map +1 -1
- package/dist/editor/searchPanel.js +15 -8
- package/dist/editor/searchPanel.js.map +1 -1
- package/dist/editor/selection.d.ts +31 -11
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/selection.js +198 -70
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/selectionAction.d.ts +4 -3
- package/dist/editor/selectionAction.d.ts.map +1 -1
- package/dist/editor/selectionAction.js +9 -5
- package/dist/editor/selectionAction.js.map +1 -1
- package/dist/editor/stateStorage.d.ts +15 -0
- package/dist/editor/stateStorage.d.ts.map +1 -0
- package/dist/editor/stateStorage.js +65 -0
- package/dist/editor/stateStorage.js.map +1 -0
- package/dist/editor/textDocument.d.ts +12 -77
- package/dist/editor/textDocument.d.ts.map +1 -1
- package/dist/editor/textDocument.js +76 -34
- package/dist/editor/textDocument.js.map +1 -1
- package/dist/editor/textMeasure.d.ts +7 -12
- package/dist/editor/textMeasure.d.ts.map +1 -1
- package/dist/editor/textMeasure.js +40 -32
- package/dist/editor/textMeasure.js.map +1 -1
- package/dist/editor/{tokenzier.d.ts → tokenizer.d.ts} +3 -3
- package/dist/editor/tokenizer.d.ts.map +1 -0
- package/dist/editor/{tokenzier.js → tokenizer.js} +91 -26
- package/dist/editor/tokenizer.js.map +1 -0
- package/dist/editor/utils.js +1 -1
- package/dist/editor/utils.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +7 -6
- package/dist/managers/InteractionManager.d.ts +18 -7
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +154 -99
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/UniversalRenderingManager.d.ts +2 -1
- package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
- package/dist/managers/UniversalRenderingManager.js +7 -3
- package/dist/managers/UniversalRenderingManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +13 -13
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +38 -29
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/EditContext.d.ts +20 -0
- package/dist/react/EditContext.d.ts.map +1 -0
- package/dist/react/EditContext.js +20 -0
- package/dist/react/EditContext.js.map +1 -0
- package/dist/react/File.d.ts +2 -1
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +3 -2
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +2 -2
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +3 -2
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +2 -2
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +3 -2
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +2 -2
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +3 -2
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +1 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +3 -3
- package/dist/react/types.d.ts +9 -1
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +5 -3
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +28 -27
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +5 -3
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +29 -25
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +3 -3
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +33 -1
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +134 -21
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +2 -0
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +33 -11
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/FileDiffReact.js +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.js +1 -1
- package/dist/style.js +1 -1
- package/dist/types.d.ts +185 -42
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/annotationHelpers.d.ts +20 -0
- package/dist/utils/annotationHelpers.d.ts.map +1 -0
- package/dist/utils/annotationHelpers.js +29 -0
- package/dist/utils/annotationHelpers.js.map +1 -0
- package/dist/utils/computeFileOffsets.d.ts.map +1 -1
- package/dist/utils/computeFileOffsets.js +34 -5
- package/dist/utils/computeFileOffsets.js.map +1 -1
- package/dist/utils/editSessionHunks.d.ts +66 -0
- package/dist/utils/editSessionHunks.d.ts.map +1 -0
- package/dist/utils/editSessionHunks.js +437 -0
- package/dist/utils/editSessionHunks.js.map +1 -0
- package/dist/utils/getHunkSideBoundaries.d.ts +7 -0
- package/dist/utils/getHunkSideBoundaries.d.ts.map +1 -0
- package/dist/utils/getHunkSideBoundaries.js +12 -0
- package/dist/utils/getHunkSideBoundaries.js.map +1 -0
- package/dist/utils/getTotalLineCountFromHunks.d.ts.map +1 -1
- package/dist/utils/getTotalLineCountFromHunks.js +2 -1
- package/dist/utils/getTotalLineCountFromHunks.js.map +1 -1
- package/dist/utils/hydratePartialDiff.d.ts.map +1 -1
- package/dist/utils/hydratePartialDiff.js +4 -3
- package/dist/utils/hydratePartialDiff.js.map +1 -1
- package/dist/utils/isGutterUtilityPath.d.ts +5 -0
- package/dist/utils/isGutterUtilityPath.d.ts.map +1 -0
- package/dist/utils/isGutterUtilityPath.js +12 -0
- package/dist/utils/isGutterUtilityPath.js.map +1 -0
- package/dist/utils/iterateOverDiff.d.ts.map +1 -1
- package/dist/utils/iterateOverDiff.js +17 -12
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.js +9 -6
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +6 -3
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/realignChangeContent.d.ts +33 -0
- package/dist/utils/realignChangeContent.d.ts.map +1 -0
- package/dist/utils/realignChangeContent.js +148 -0
- package/dist/utils/realignChangeContent.js.map +1 -0
- package/dist/utils/renderDiffWithHighlighter.js +1 -1
- package/dist/utils/resolveRegion.d.ts.map +1 -1
- package/dist/utils/resolveRegion.js +18 -2
- package/dist/utils/resolveRegion.js.map +1 -1
- package/dist/utils/updateDiffHunks.d.ts +8 -2
- package/dist/utils/updateDiffHunks.d.ts.map +1 -1
- package/dist/utils/updateDiffHunks.js +9 -7
- package/dist/utils/updateDiffHunks.js.map +1 -1
- package/dist/utils/virtualDiffLayout.d.ts +42 -2
- package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
- package/dist/utils/virtualDiffLayout.js +101 -7
- package/dist/utils/virtualDiffLayout.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +4 -2
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/types.d.ts +4 -0
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +60 -20
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +61 -19
- package/dist/worker/worker.js.map +1 -1
- package/package.json +13 -8
- package/dist/editor/index.d.ts +0 -3
- package/dist/editor/index.js +0 -3
- package/dist/editor/tokenzier.d.ts.map +0 -1
- package/dist/editor/tokenzier.js.map +0 -1
- package/dist/react/EditorContext.d.ts +0 -15
- package/dist/react/EditorContext.d.ts.map +0 -1
- package/dist/react/EditorContext.js +0 -23
- package/dist/react/EditorContext.js.map +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -19,9 +19,11 @@ interface FileContents {
|
|
|
19
19
|
lang?: SupportedLanguages;
|
|
20
20
|
/** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */
|
|
21
21
|
header?: string;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
/**
|
|
23
|
+
* Identifies a file for caching. Optional for read-only rendering, but
|
|
24
|
+
* required and expected to be unique and stable when Editor `persistState`
|
|
25
|
+
* is enabled.
|
|
26
|
+
*/
|
|
25
27
|
cacheKey?: string;
|
|
26
28
|
}
|
|
27
29
|
interface FileDiffLoadedChangedFiles {
|
|
@@ -288,6 +290,16 @@ interface FileDiffMetadata {
|
|
|
288
290
|
* the patch.
|
|
289
291
|
*/
|
|
290
292
|
additionLines: string[];
|
|
293
|
+
/**
|
|
294
|
+
* Set while an attached editor's session-scoped hunk updates have reshaped
|
|
295
|
+
* `hunks` away from a plain recompute (regions stay frozen during an edit
|
|
296
|
+
* session). Consumed by the session-exit recompute, which restores
|
|
297
|
+
* recompute-shaped hunks and clears the flag. It lives on the metadata so
|
|
298
|
+
* it survives instance recycling and pooling.
|
|
299
|
+
*
|
|
300
|
+
* @internal
|
|
301
|
+
*/
|
|
302
|
+
editSessionDirty?: boolean;
|
|
291
303
|
/**
|
|
292
304
|
* This unique key is only used for Worker Pools to avoid subsequent requests
|
|
293
305
|
* to highlight if we've already highlighted the diff. Please note that if
|
|
@@ -411,9 +423,9 @@ type CodeViewFileItem<T = undefined> = {
|
|
|
411
423
|
version?: number;
|
|
412
424
|
collapsed?: boolean;
|
|
413
425
|
/**
|
|
414
|
-
* Put this item into edit mode. Requires
|
|
415
|
-
*
|
|
416
|
-
* also changing the value.
|
|
426
|
+
* Put this item into edit mode. Requires `EditProvider` in React or the
|
|
427
|
+
* CodeView `createEditor` option in vanilla; ignored while `collapsed` is
|
|
428
|
+
* true. Make sure you bump the version when also changing the value.
|
|
417
429
|
*/
|
|
418
430
|
edit?: boolean;
|
|
419
431
|
};
|
|
@@ -425,9 +437,9 @@ type CodeViewDiffItem<T = undefined> = {
|
|
|
425
437
|
version?: number;
|
|
426
438
|
collapsed?: boolean;
|
|
427
439
|
/**
|
|
428
|
-
* Put this item into edit mode. Requires
|
|
429
|
-
*
|
|
430
|
-
* also changing the value.
|
|
440
|
+
* Put this item into edit mode. Requires `EditProvider` in React or the
|
|
441
|
+
* CodeView `createEditor` option in vanilla; ignored while `collapsed` is
|
|
442
|
+
* true. Make sure you bump the version when also changing the value.
|
|
431
443
|
*/
|
|
432
444
|
edit?: boolean;
|
|
433
445
|
};
|
|
@@ -630,7 +642,19 @@ interface RenderedDiffASTCache {
|
|
|
630
642
|
result: ThemedDiffResult | undefined;
|
|
631
643
|
renderRange: RenderRange | undefined;
|
|
632
644
|
isDirty?: boolean;
|
|
645
|
+
highlightPending?: boolean;
|
|
633
646
|
}
|
|
647
|
+
/**
|
|
648
|
+
* A window of rendered content. Two unit interpretations exist:
|
|
649
|
+
*
|
|
650
|
+
* - Renderer consumers (`iterateOverDiff` window predicates, windowed AST
|
|
651
|
+
* requests, buffers, sticky specs) read `startingLine`/`totalLines` as
|
|
652
|
+
* dense rendered-row indexes for the active diff style.
|
|
653
|
+
* - The editor reads them as zero-based document-line indexes of the new
|
|
654
|
+
* file. `FileDiff.computeEditorRenderRange` converts the renderer range on
|
|
655
|
+
* the editor-bound copy; the two coincide only while every line renders
|
|
656
|
+
* (`expandUnchanged`).
|
|
657
|
+
*/
|
|
634
658
|
interface RenderRange {
|
|
635
659
|
startingLine: number;
|
|
636
660
|
totalLines: number;
|
|
@@ -753,6 +777,10 @@ interface DiffsComponentOptions extends BaseCodeOptions {
|
|
|
753
777
|
diffStyle?: 'unified' | 'split';
|
|
754
778
|
lineHoverHighlight?: 'disabled' | 'both' | 'number' | 'line';
|
|
755
779
|
}
|
|
780
|
+
interface EditorActiveLineOptions {
|
|
781
|
+
lineNumberOnly?: boolean;
|
|
782
|
+
side?: SelectionSide;
|
|
783
|
+
}
|
|
756
784
|
interface DiffsBaseComponent {
|
|
757
785
|
readonly type: 'file' | 'file-diff' | 'unresolved-file';
|
|
758
786
|
readonly top?: number;
|
|
@@ -776,6 +804,14 @@ interface DiffsBaseComponent {
|
|
|
776
804
|
cleanUp(): void;
|
|
777
805
|
}
|
|
778
806
|
interface DiffsEditableComponent<LAnnotation> extends DiffsBaseComponent {
|
|
807
|
+
/** @internal Return the current file when this component renders one. */
|
|
808
|
+
__getCurrentFile?: () => FileContents | undefined;
|
|
809
|
+
/** @internal Keep the editor caret decoration separate from line selection. */
|
|
810
|
+
setEditorActiveLine: (lineNumber: number | null, options?: EditorActiveLineOptions) => void;
|
|
811
|
+
/** Return the horizontal code scroll position (`scrollLeft`). */
|
|
812
|
+
getCodeScrollLeft: () => number;
|
|
813
|
+
/** Set the horizontal code scroll position (`scrollLeft`). */
|
|
814
|
+
setCodeScrollLeft: (position: number) => void;
|
|
779
815
|
/**
|
|
780
816
|
* Return the position and height of a one-based line relative to this component.
|
|
781
817
|
* The host uses it to scroll to virtualized lines before their DOM nodes exist.
|
|
@@ -786,58 +822,165 @@ interface DiffsEditableComponent<LAnnotation> extends DiffsBaseComponent {
|
|
|
786
822
|
top: number;
|
|
787
823
|
height: number;
|
|
788
824
|
} | undefined;
|
|
789
|
-
|
|
825
|
+
/**
|
|
826
|
+
* Return an explicit viewport that bounds visible editor rows. Components
|
|
827
|
+
* without one fall back to their nearest scrollable ancestor or document.
|
|
828
|
+
*/
|
|
829
|
+
getEditorViewport?: () => HTMLElement | Document | undefined;
|
|
830
|
+
/**
|
|
831
|
+
* Whether the given one-based new-file line currently has (or will have on
|
|
832
|
+
* scroll) a rendered row. False only for lines hidden inside a collapsed
|
|
833
|
+
* unchanged region. Components without collapsible regions leave this
|
|
834
|
+
* unimplemented and the editor treats every line as renderable.
|
|
835
|
+
*/
|
|
836
|
+
isLineRenderable?: (lineNumber: number) => boolean;
|
|
837
|
+
/**
|
|
838
|
+
* The nearest renderable one-based new-file line at or beyond `lineNumber`
|
|
839
|
+
* in the given direction, or undefined when every line that way is hidden
|
|
840
|
+
* inside collapsed regions. Sequential caret motion uses this to skip
|
|
841
|
+
* collapsed regions like code folds.
|
|
842
|
+
*/
|
|
843
|
+
getNearestRenderableLine?: (lineNumber: number, direction: 'up' | 'down') => number | undefined;
|
|
844
|
+
/**
|
|
845
|
+
* Expand collapsed context so the given one-based new-file line can
|
|
846
|
+
* render. Returns true when an expansion was performed (a re-render will
|
|
847
|
+
* follow, possibly deferred).
|
|
848
|
+
*/
|
|
849
|
+
revealLine?: (lineNumber: number) => boolean;
|
|
850
|
+
/**
|
|
851
|
+
* Attach an editor to this component. The returned detach closure receives
|
|
852
|
+
* `recycle: true` when the editor is only being released by a virtualized
|
|
853
|
+
* unmount (the session continues on remount) and no argument/false on a
|
|
854
|
+
* genuine session end.
|
|
855
|
+
*/
|
|
856
|
+
attachEditor: (editor: DiffsEditor<LAnnotation>) => (recycle?: boolean) => void;
|
|
790
857
|
applyDocumentChange: (textDocument: DiffsTextDocument, newLineAnnotations?: DiffLineAnnotation<LAnnotation>[], shouldUpdateBuffer?: boolean) => void;
|
|
791
|
-
|
|
858
|
+
/**
|
|
859
|
+
* `lineCountChangeInFlight` is true only during an edit pass whose line
|
|
860
|
+
* count changed, where an authoritative `applyDocumentChange` follows in
|
|
861
|
+
* the same pass; deferred background-tokenize passes always pass false.
|
|
862
|
+
*/
|
|
863
|
+
updateRenderCache: (lines: Map<number, Array<HighlightedToken>>, themeType: 'dark' | 'light', shouldRefreshView: boolean, lineCountChangeInFlight?: boolean) => void;
|
|
792
864
|
}
|
|
865
|
+
type EditableInstance<T extends {
|
|
866
|
+
type: string;
|
|
867
|
+
}> = T extends {
|
|
868
|
+
type: 'unresolved-file';
|
|
869
|
+
} ? never : T;
|
|
793
870
|
interface DiffsEditor<LAnnotation> {
|
|
871
|
+
/** @internal */
|
|
872
|
+
__prepareFile?(file: FileContents): FileContents;
|
|
794
873
|
__postponeBgTokenizeToNextFrame(): void;
|
|
874
|
+
/** @internal Capture focus intent before replacing the editable view. */
|
|
875
|
+
__captureFocusForDOMReplacement(): void;
|
|
795
876
|
__syncRenderView(highlighter: DiffsHighlighter, fileContainer: HTMLElement, fileOrDiff: FileContents | FileDiffMetadata, lineAnnotations: LineAnnotation<LAnnotation>[] | DiffLineAnnotation<LAnnotation>[] | undefined, renderRange: RenderRange | undefined): void;
|
|
877
|
+
edit<T extends DiffsEditableComponent<LAnnotation>>(fileInstance: EditableInstance<T>): () => void;
|
|
878
|
+
cleanUp(recycle?: boolean): void;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Position in a text document expressed as zero-based line and character offset.
|
|
882
|
+
* The offsets are based on a UTF-16 string representation. So a string of the form
|
|
883
|
+
* `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`
|
|
884
|
+
* is 1 and the character offset of b is 3 since `𐐀` is represented using two code
|
|
885
|
+
* units in UTF-16.
|
|
886
|
+
*
|
|
887
|
+
* Positions are line end character agnostic. So you can not specify a position that
|
|
888
|
+
* denotes `\r|\n` or `\n|` where `|` represents the character offset.
|
|
889
|
+
*/
|
|
890
|
+
interface Position {
|
|
796
891
|
/**
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
892
|
+
* Line position in a document (zero-based).
|
|
893
|
+
*
|
|
894
|
+
* If a line number is greater than the number of lines in a document, it
|
|
895
|
+
* defaults back to the number of lines in the document.
|
|
896
|
+
* If a line number is negative, it defaults to 0.
|
|
897
|
+
*
|
|
898
|
+
* The above two properties are implementation specific.
|
|
802
899
|
*/
|
|
803
|
-
|
|
900
|
+
readonly line: number;
|
|
901
|
+
/**
|
|
902
|
+
* Character offset on a line in a document (zero-based).
|
|
903
|
+
*
|
|
904
|
+
* The meaning of this offset is determined by the negotiated
|
|
905
|
+
* `PositionEncodingKind`.
|
|
906
|
+
*
|
|
907
|
+
* If the character value is greater than the line length it defaults back
|
|
908
|
+
* to the line length. This property is implementation specific.
|
|
909
|
+
*/
|
|
910
|
+
readonly character: number;
|
|
804
911
|
}
|
|
805
912
|
/**
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
*
|
|
809
|
-
*
|
|
913
|
+
* A range in a text document expressed as (zero-based) start and end positions.
|
|
914
|
+
*
|
|
915
|
+
* If you want to specify a range that contains a line including the line ending
|
|
916
|
+
* character(s) then use an end position denoting the start of the next line.
|
|
917
|
+
* For example:
|
|
918
|
+
* ```ts
|
|
919
|
+
* {
|
|
920
|
+
* start: { line: 5, character: 23 }
|
|
921
|
+
* end : { line 6, character : 0 }
|
|
922
|
+
* }
|
|
923
|
+
* ```
|
|
810
924
|
*/
|
|
811
|
-
interface
|
|
812
|
-
|
|
925
|
+
interface Range {
|
|
926
|
+
/**
|
|
927
|
+
* The range's start position.
|
|
928
|
+
*/
|
|
929
|
+
readonly start: Position;
|
|
930
|
+
/**
|
|
931
|
+
* The range's end position.
|
|
932
|
+
*/
|
|
933
|
+
readonly end: Position;
|
|
813
934
|
}
|
|
814
935
|
/**
|
|
815
|
-
*
|
|
816
|
-
* of `EditorOptions` from `@pierre/diffs/editor`, so factories can spread
|
|
817
|
-
* them straight into the constructor — `new Editor({ ...options })` — and
|
|
818
|
-
* layer any editor configuration of their own on top. Forwarding `onChange`
|
|
819
|
-
* is what lets CodeView resolve document changes back to the owning item and
|
|
820
|
-
* emit them through its own `onItemEditChange` option.
|
|
936
|
+
* A text edit applicable to a text document.
|
|
821
937
|
*/
|
|
822
|
-
interface
|
|
823
|
-
|
|
938
|
+
interface TextEdit {
|
|
939
|
+
/**
|
|
940
|
+
* The range of the text document to be manipulated. To insert
|
|
941
|
+
* text into a document create a range where start === end.
|
|
942
|
+
*/
|
|
943
|
+
readonly range: Range;
|
|
944
|
+
/**
|
|
945
|
+
* The string to be inserted. For delete operations use an
|
|
946
|
+
* empty string.
|
|
947
|
+
*/
|
|
948
|
+
readonly newText: string;
|
|
824
949
|
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
950
|
+
/**
|
|
951
|
+
* The direction of a selection.
|
|
952
|
+
* -1: backward
|
|
953
|
+
* 0: none
|
|
954
|
+
* 1: forward
|
|
955
|
+
*/
|
|
956
|
+
type SelectionDirection = -1 | 0 | 1;
|
|
957
|
+
interface EditorSelection extends Range {
|
|
958
|
+
direction: SelectionDirection;
|
|
959
|
+
}
|
|
960
|
+
interface EditorViewState {
|
|
961
|
+
/** Horizontal position owned by the current editable code scroller. */
|
|
962
|
+
scrollLeft: number;
|
|
963
|
+
}
|
|
964
|
+
interface EditorState {
|
|
965
|
+
selections?: EditorSelection[];
|
|
966
|
+
view?: EditorViewState;
|
|
835
967
|
}
|
|
836
968
|
interface DiffsTextDocument {
|
|
837
969
|
readonly lineCount: number;
|
|
838
970
|
getLineText: (lineNumber: number, includeLineBreak?: boolean) => string;
|
|
839
971
|
getText: () => string;
|
|
840
972
|
}
|
|
973
|
+
/**
|
|
974
|
+
* Options CodeView passes to its `createEditor` factory. A structural subset
|
|
975
|
+
* of `EditorOptions` from `@pierre/diffs/edit`, so factories can spread
|
|
976
|
+
* them straight into the constructor — `new Editor({ ...options })` — and
|
|
977
|
+
* layer any editor configuration of their own on top. Forwarding `onChange`
|
|
978
|
+
* is what lets CodeView resolve document changes back to the owning item and
|
|
979
|
+
* emit them through its own `onItemEditChange` option.
|
|
980
|
+
*/
|
|
981
|
+
interface CodeViewCreateEditorOptions<LAnnotation> {
|
|
982
|
+
onChange: (file: FileContents, lineAnnotations?: LineAnnotation<LAnnotation>[] | DiffLineAnnotation<LAnnotation>[]) => void;
|
|
983
|
+
}
|
|
841
984
|
//#endregion
|
|
842
|
-
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewCreateEditorOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor,
|
|
985
|
+
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewCreateEditorOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, EditableInstance, EditorActiveLineOptions, EditorSelection, EditorState, EditorViewState, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffContentsLoader, FileDiffLoadedChangedFiles, FileDiffLoadedFiles, FileDiffLoadedPureRenamedFile, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MaybeDiffFileInput, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, Position, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, Range, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionDirection, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, TextEdit, type ThemeRegistration, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs };
|
|
843
986
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;KAiBY,sBAAA;AAAZ;;;;AAAA,UAMiB,YAAA;EAAA;;EAGf,IAAA;EAKyB;EAHzB,QAAA;EAAA;;EAGA,IAAA,GAAO,kBAAkB;EAEzB;EAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;KAiBY,sBAAA;AAAZ;;;;AAAA,UAMiB,YAAA;EAAA;;EAGf,IAAA;EAKyB;EAHzB,QAAA;EAAA;;EAGA,IAAA,GAAO,kBAAkB;EAEzB;EAAA,MAAA;EAMQ;AAAA;AAGV;;;EAHE,QAAA;AAAA;AAAA,UAGe,0BAAA;EACf,OAAA,EAAS,YAAA;EACT,OAAA,EAAS,YAAY;AAAA;AAAA,UAGN,6BAAA;EACf,OAAA;EACA,OAAA,EAAS,YAAY;AAAA;AAAA,KAGX,mBAAA,GACR,0BAAA,GACA,6BAA6B;AAAA,KAErB,aAAA;EACN,OAAA,EAAS,YAAA;EAAc,OAAA,EAAS,YAAA;AAAA;EAChC,OAAA;EAAe,OAAA,EAAS,YAAA;AAAA;EACxB,OAAA,EAAS,YAAA;EAAc,OAAA;AAAA;AAAA,KAEjB,kBAAA,GACR,aAAa;EACX,OAAA;EAAqB,OAAA;AAAA;AAAA,KAEf,sBAAA,IAC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B,CAAA;EAEjC,OAAA,CAAQ,OAAA;AAAA;;;;;;;;AA3Ua;AAGvB;;UAqViB,QAAA;EApVR;;;;;;;;;EAAA,SA8VE,IAAA;EA7VT;;;;;;AAGiB;AAGnB;;EANE,SAuWS,SAAS;AAAA;;;;;;AA/VQ;AAG5B;;;;;;;UA4WiB,KAAA;EA1WW;AAAA;AAG5B;EAH4B,SA8WjB,KAAA,EAAO,QAAA;;;;WAIP,GAAA,EAAK,QAAQ;AAAA;;;;UAMP,QAAA;EAnXf;;;;EAAA,SAwXS,KAAA,EAAO,KAAK;EArXrB;;;;EAAA,SA0XS,OAAA;AAAA;;;;;;;KASC,kBAAA;AAAA,UAEK,eAAA,SAAwB,KAAK;EAC5C,SAAA,EAAW,kBAAA;AAAA;AAAA,UAGI,eAAA;EAlYf;EAoYA,UAAU;AAAA;AAAA,UAGK,WAAA;EACf,UAAA,GAAa,eAAA;EACb,IAAA,GAAO,eAAe;AAAA;AAAA,UAGP,iBAAA;EAAA,SACN,SAAA;EACT,WAAA,GAAc,UAAA,UAAoB,gBAAA;EAClC,OAAA;AAAA;;;;;;;;AAvXW;UAkYI,2BAAA;EACf,QAAA,GACE,IAAA,EAAM,YAAA,EACN,eAAA,GACI,cAAA,CAAe,WAAA,MACf,kBAAA,CAAmB,WAAA;AAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DiffLineAnnotation, LineAnnotation } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/annotationHelpers.d.ts
|
|
4
|
+
/** Narrow an annotation to the side-tagged diff shape. */
|
|
5
|
+
declare function isDiffAnnotation<LAnnotation = undefined>(annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>): annotation is DiffLineAnnotation<LAnnotation>;
|
|
6
|
+
/** Narrow an annotation to the side-less file shape. */
|
|
7
|
+
declare function isFileAnnotation<LAnnotation = undefined>(annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>): annotation is LineAnnotation<LAnnotation>;
|
|
8
|
+
/**
|
|
9
|
+
* Narrow a homogeneous editor annotation collection to diff annotations.
|
|
10
|
+
* Empty collections return true because they are valid for either shape.
|
|
11
|
+
*/
|
|
12
|
+
declare function isDiffAnnotationCollection<LAnnotation = undefined>(annotations: LineAnnotation<LAnnotation>[] | DiffLineAnnotation<LAnnotation>[]): annotations is DiffLineAnnotation<LAnnotation>[];
|
|
13
|
+
/**
|
|
14
|
+
* Narrow a homogeneous editor annotation collection to file annotations.
|
|
15
|
+
* Empty collections return true because they are valid for either shape.
|
|
16
|
+
*/
|
|
17
|
+
declare function isFileAnnotationCollection<LAnnotation = undefined>(annotations: LineAnnotation<LAnnotation>[] | DiffLineAnnotation<LAnnotation>[]): annotations is LineAnnotation<LAnnotation>[];
|
|
18
|
+
//#endregion
|
|
19
|
+
export { isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection };
|
|
20
|
+
//# sourceMappingURL=annotationHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotationHelpers.d.ts","names":[],"sources":["../../src/utils/annotationHelpers.ts"],"mappings":";;;;iBAGgB,gBAAA,0BACd,UAAA,EAAY,cAAA,CAAe,WAAA,IAAe,kBAAA,CAAmB,WAAA,IAC5D,UAAA,IAAc,kBAAA,CAAmB,WAAA;AAFpC;AAAA,iBAOgB,gBAAA,0BACd,UAAA,EAAY,cAAA,CAAe,WAAA,IAAe,kBAAA,CAAmB,WAAA,IAC5D,UAAA,IAAc,cAAA,CAAe,WAAA;;;;;iBAQhB,0BAAA,0BACd,WAAA,EAAa,cAAA,CAAe,WAAA,MAAiB,kBAAA,CAAmB,WAAA,MAC/D,WAAA,IAAe,kBAAA,CAAmB,WAAA;;;;;iBASrB,0BAAA,0BACd,WAAA,EAAa,cAAA,CAAe,WAAA,MAAiB,kBAAA,CAAmB,WAAA,MAC/D,WAAA,IAAe,cAAA,CAAe,WAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/utils/annotationHelpers.ts
|
|
2
|
+
/** Narrow an annotation to the side-tagged diff shape. */
|
|
3
|
+
function isDiffAnnotation(annotation) {
|
|
4
|
+
return "side" in annotation;
|
|
5
|
+
}
|
|
6
|
+
/** Narrow an annotation to the side-less file shape. */
|
|
7
|
+
function isFileAnnotation(annotation) {
|
|
8
|
+
return !isDiffAnnotation(annotation);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Narrow a homogeneous editor annotation collection to diff annotations.
|
|
12
|
+
* Empty collections return true because they are valid for either shape.
|
|
13
|
+
*/
|
|
14
|
+
function isDiffAnnotationCollection(annotations) {
|
|
15
|
+
const first = annotations[0];
|
|
16
|
+
return first == null || isDiffAnnotation(first);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Narrow a homogeneous editor annotation collection to file annotations.
|
|
20
|
+
* Empty collections return true because they are valid for either shape.
|
|
21
|
+
*/
|
|
22
|
+
function isFileAnnotationCollection(annotations) {
|
|
23
|
+
const first = annotations[0];
|
|
24
|
+
return first == null || isFileAnnotation(first);
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=annotationHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotationHelpers.js","names":[],"sources":["../../src/utils/annotationHelpers.ts"],"sourcesContent":["import type { DiffLineAnnotation, LineAnnotation } from '../types';\n\n/** Narrow an annotation to the side-tagged diff shape. */\nexport function isDiffAnnotation<LAnnotation = undefined>(\n annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>\n): annotation is DiffLineAnnotation<LAnnotation> {\n return 'side' in annotation;\n}\n\n/** Narrow an annotation to the side-less file shape. */\nexport function isFileAnnotation<LAnnotation = undefined>(\n annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>\n): annotation is LineAnnotation<LAnnotation> {\n return !isDiffAnnotation(annotation);\n}\n\n/**\n * Narrow a homogeneous editor annotation collection to diff annotations.\n * Empty collections return true because they are valid for either shape.\n */\nexport function isDiffAnnotationCollection<LAnnotation = undefined>(\n annotations: LineAnnotation<LAnnotation>[] | DiffLineAnnotation<LAnnotation>[]\n): annotations is DiffLineAnnotation<LAnnotation>[] {\n const first = annotations[0];\n return first == null || isDiffAnnotation(first);\n}\n\n/**\n * Narrow a homogeneous editor annotation collection to file annotations.\n * Empty collections return true because they are valid for either shape.\n */\nexport function isFileAnnotationCollection<LAnnotation = undefined>(\n annotations: LineAnnotation<LAnnotation>[] | DiffLineAnnotation<LAnnotation>[]\n): annotations is LineAnnotation<LAnnotation>[] {\n const first = annotations[0];\n return first == null || isFileAnnotation(first);\n}\n"],"mappings":";;AAGA,SAAgB,iBACd,YAC+C;CAC/C,OAAO,UAAU;AACnB;;AAGA,SAAgB,iBACd,YAC2C;CAC3C,OAAO,CAAC,iBAAiB,UAAU;AACrC;;;;;AAMA,SAAgB,2BACd,aACkD;CAClD,MAAM,QAAQ,YAAY;CAC1B,OAAO,SAAS,QAAQ,iBAAiB,KAAK;AAChD;;;;;AAMA,SAAgB,2BACd,aAC8C;CAC9C,MAAM,QAAQ,YAAY;CAC1B,OAAO,SAAS,QAAQ,iBAAiB,KAAK;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeFileOffsets.d.ts","names":[],"sources":["../../src/utils/computeFileOffsets.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"computeFileOffsets.d.ts","names":[],"sources":["../../src/utils/computeFileOffsets.ts"],"mappings":";;AAQA;;iBAAgB,kBAAA,CAAmB,QAAgB;;AAAA;AA2DnD;;;;AAAgD;iBAAhC,eAAA,CAAgB,QAAgB;;;;AAuBM;iBAAtC,qBAAA,CAAsB,QAAgB"}
|
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
//#region src/utils/computeFileOffsets.ts
|
|
2
2
|
const LINE_FEED = 10;
|
|
3
3
|
const CARRIAGE_RETURN = 13;
|
|
4
|
+
const DENSE_LINE_BREAK_BLOCK_SIZE = 4;
|
|
5
|
+
const DENSE_LINE_BREAK_BLOCK_SPAN = 40;
|
|
4
6
|
/**
|
|
5
7
|
* Computes line start offsets for a string.
|
|
6
8
|
*/
|
|
7
9
|
function computeLineOffsets(contents) {
|
|
8
10
|
const offsets = [0];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
let carriageReturn = contents.indexOf("\r");
|
|
12
|
+
let lineFeed = contents.indexOf("\n");
|
|
13
|
+
let blockStart = 0;
|
|
14
|
+
let blockBreaks = 0;
|
|
15
|
+
while (carriageReturn !== -1 || lineFeed !== -1) {
|
|
16
|
+
let nextOffset;
|
|
17
|
+
if (carriageReturn !== -1 && (lineFeed === -1 || carriageReturn < lineFeed)) if (lineFeed === carriageReturn + 1) {
|
|
18
|
+
nextOffset = lineFeed + 1;
|
|
19
|
+
carriageReturn = contents.indexOf("\r", nextOffset);
|
|
20
|
+
lineFeed = contents.indexOf("\n", nextOffset);
|
|
21
|
+
} else {
|
|
22
|
+
nextOffset = carriageReturn + 1;
|
|
23
|
+
carriageReturn = contents.indexOf("\r", nextOffset);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
nextOffset = lineFeed + 1;
|
|
27
|
+
lineFeed = contents.indexOf("\n", nextOffset);
|
|
28
|
+
}
|
|
29
|
+
offsets.push(nextOffset);
|
|
30
|
+
if (++blockBreaks === DENSE_LINE_BREAK_BLOCK_SIZE) {
|
|
31
|
+
if (nextOffset - blockStart <= DENSE_LINE_BREAK_BLOCK_SPAN) {
|
|
32
|
+
for (let i = nextOffset; i < contents.length; i++) {
|
|
33
|
+
const char = contents.charCodeAt(i);
|
|
34
|
+
if (char === LINE_FEED || char === CARRIAGE_RETURN) {
|
|
35
|
+
if (char === CARRIAGE_RETURN && i + 1 < contents.length && contents.charCodeAt(i + 1) === LINE_FEED) i++;
|
|
36
|
+
offsets.push(i + 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return offsets;
|
|
40
|
+
}
|
|
41
|
+
blockStart = nextOffset;
|
|
42
|
+
blockBreaks = 0;
|
|
14
43
|
}
|
|
15
44
|
}
|
|
16
45
|
return offsets;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeFileOffsets.js","names":[],"sources":["../../src/utils/computeFileOffsets.ts"],"sourcesContent":["const LINE_FEED = 10; // \\n\nconst CARRIAGE_RETURN = 13; // \\r\n\n/**\n * Computes line start offsets for a string.\n */\nexport function computeLineOffsets(contents: string): number[] {\n const offsets: number[] = [0];\n for (let i =
|
|
1
|
+
{"version":3,"file":"computeFileOffsets.js","names":[],"sources":["../../src/utils/computeFileOffsets.ts"],"sourcesContent":["const LINE_FEED = 10; // \\n\nconst CARRIAGE_RETURN = 13; // \\r\nconst DENSE_LINE_BREAK_BLOCK_SIZE = 4;\nconst DENSE_LINE_BREAK_BLOCK_SPAN = 40;\n\n/**\n * Computes line start offsets for a string.\n */\nexport function computeLineOffsets(contents: string): number[] {\n const offsets: number[] = [0];\n let carriageReturn = contents.indexOf('\\r');\n let lineFeed = contents.indexOf('\\n');\n let blockStart = 0;\n let blockBreaks = 0;\n while (carriageReturn !== -1 || lineFeed !== -1) {\n let nextOffset: number;\n if (\n carriageReturn !== -1 &&\n (lineFeed === -1 || carriageReturn < lineFeed)\n ) {\n if (lineFeed === carriageReturn + 1) {\n nextOffset = lineFeed + 1;\n carriageReturn = contents.indexOf('\\r', nextOffset);\n lineFeed = contents.indexOf('\\n', nextOffset);\n } else {\n nextOffset = carriageReturn + 1;\n carriageReturn = contents.indexOf('\\r', nextOffset);\n }\n } else {\n nextOffset = lineFeed + 1;\n lineFeed = contents.indexOf('\\n', nextOffset);\n }\n offsets.push(nextOffset);\n\n if (++blockBreaks === DENSE_LINE_BREAK_BLOCK_SIZE) {\n if (nextOffset - blockStart <= DENSE_LINE_BREAK_BLOCK_SPAN) {\n // Native searches win on source-like lines; a character scan is faster\n // once line breaks become unusually dense.\n for (let i = nextOffset; i < contents.length; i++) {\n const char = contents.charCodeAt(i);\n if (char === LINE_FEED || char === CARRIAGE_RETURN) {\n if (\n char === CARRIAGE_RETURN &&\n i + 1 < contents.length &&\n contents.charCodeAt(i + 1) === LINE_FEED\n ) {\n i++;\n }\n offsets.push(i + 1);\n }\n }\n return offsets;\n }\n blockStart = nextOffset;\n blockBreaks = 0;\n }\n }\n return offsets;\n}\n\n/**\n * Counts line breaks in a string, treating `\\n`, `\\r`, and `\\r\\n` the same way\n * {@link computeLineOffsets} does (a `\\r\\n` pair is one break). Mirrors that\n * scan but counts in a single pass instead of building and discarding an\n * offsets array, so sizing the changed-line range for large edits stays cheap.\n * A unit test asserts it stays in lockstep with `computeLineOffsets`.\n */\nexport function countLineBreaks(contents: string): number {\n let count = 0;\n for (let i = 0; i < contents.length; i++) {\n const char = contents.charCodeAt(i);\n if (char === LINE_FEED || char === CARRIAGE_RETURN) {\n // Skip the `\\n` of a `\\r\\n` pair so it counts as one break, not two.\n if (\n char === CARRIAGE_RETURN &&\n i + 1 < contents.length &&\n contents.charCodeAt(i + 1) === LINE_FEED\n ) {\n i++;\n }\n count++;\n }\n }\n return count;\n}\n\n/**\n * Splits file contents into lines aligned with {@link computeLineOffsets}.\n * Unlike splitFileContents, a trailing newline produces a final empty line.\n */\nexport function linesFromFileContents(contents: string): string[] {\n const offsets = computeLineOffsets(contents);\n const lines = Array.from({ length: offsets.length }, (_, i) => {\n const start = offsets[i];\n const end = offsets[i + 1] ?? contents.length;\n return contents.slice(start, end);\n });\n return lines;\n}\n"],"mappings":";AAAA,MAAM,YAAY;AAClB,MAAM,kBAAkB;AACxB,MAAM,8BAA8B;AACpC,MAAM,8BAA8B;;;;AAKpC,SAAgB,mBAAmB,UAA4B;CAC7D,MAAM,UAAoB,CAAC,CAAC;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B;CAChE,MAAM,UAAU,mBAAmB,QAAQ;CAM3C,OALc,MAAM,KAAK,EAAE,QAAQ,QAAQ,OAAO,IAAI,GAAG,MAAM;EAC7D,MAAM,QAAQ,QAAQ;EACtB,MAAM,MAAM,QAAQ,IAAI,MAAM,SAAS;EACvC,OAAO,SAAS,MAAM,OAAO,GAAG;CAClC,CACW;AACb"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { FileDiffMetadata, HunkExpansionRegion } from "../types.js";
|
|
2
|
+
import { CreatePatchOptionsNonabortable } from "diff";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/editSessionHunks.d.ts
|
|
5
|
+
interface DivergenceCore {
|
|
6
|
+
start: number;
|
|
7
|
+
deletionEnd: number;
|
|
8
|
+
additionEnd: number;
|
|
9
|
+
}
|
|
10
|
+
interface PreviousRegionSpan {
|
|
11
|
+
firstIndex: number;
|
|
12
|
+
lastIndex: number;
|
|
13
|
+
}
|
|
14
|
+
/** Maps rebuilt regions back to the previous skeleton for expansion remapping. */
|
|
15
|
+
interface SessionRegionChange {
|
|
16
|
+
regions: Array<PreviousRegionSpan | undefined>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Drops the editor document's phantom trailing empty line (a document ending
|
|
20
|
+
* in a newline exposes one extra empty line the parsed diff never contains)
|
|
21
|
+
* so session line arrays compare like parse-derived ones.
|
|
22
|
+
*/
|
|
23
|
+
declare function normalizeEditorLines(lines: string[]): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Find the complete old/current divergence core. The old side is immutable
|
|
26
|
+
* during an edit session, so this result needs no prior-pass snapshot.
|
|
27
|
+
*/
|
|
28
|
+
declare function findDivergenceCore(deletionLines: string[], additionLines: string[]): DivergenceCore | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Rebuild the session skeleton as a pure function of the immutable old lines,
|
|
31
|
+
* current new lines, and old-side ranges of the previous regions. One
|
|
32
|
+
* canonical parse supplies the same change blocks that session exit will use.
|
|
33
|
+
*/
|
|
34
|
+
declare function rebuildSessionHunks(diff: FileDiffMetadata, parseDiffOptions?: CreatePatchOptionsNonabortable): SessionRegionChange | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Keep a cheap content-only path when a same-line-count pass cannot alter the
|
|
37
|
+
* canonical blocks. Gap, ambiguous, or multi-region edits rebuild statelessly.
|
|
38
|
+
*/
|
|
39
|
+
declare function applySessionChangedLines(diff: FileDiffMetadata, changedAdditionLineIndexes: Iterable<number>, parseDiffOptions?: CreatePatchOptionsNonabortable, previousAdditionLines?: ReadonlyMap<number, string>): SessionRegionChange | undefined;
|
|
40
|
+
/** Preserve expansion at the surviving outer edges of rebuilt old-side gaps. */
|
|
41
|
+
declare function remapExpandedHunksForRegionChange(expandedHunks: Map<number, HunkExpansionRegion>, change: SessionRegionChange): Map<number, HunkExpansionRegion>;
|
|
42
|
+
/**
|
|
43
|
+
* An expanded gap-edge slice in old-side (deletion-line) coordinates as a
|
|
44
|
+
* `[start, end)` range. Old-side coordinates survive the exit recompute
|
|
45
|
+
* unchanged — edits only touch the new side — so these anchor best-effort
|
|
46
|
+
* expansion preservation across the recompute.
|
|
47
|
+
*/
|
|
48
|
+
type ExpansionAnchorRange = [start: number, end: number];
|
|
49
|
+
/** Snapshot the expanded gap-edge slices before the exit recompute. */
|
|
50
|
+
declare function captureExpansionAnchors(diff: FileDiffMetadata, expandedHunks: Map<number, HunkExpansionRegion>, collapsedContextThreshold: number): ExpansionAnchorRange[];
|
|
51
|
+
/**
|
|
52
|
+
* Rebuild gap expansion state against the recomputed hunks: for each new
|
|
53
|
+
* gap, an anchor touching the gap's start edge restores `fromStart`, one
|
|
54
|
+
* touching its end edge restores `fromEnd`, and anchors for gaps that no
|
|
55
|
+
* longer exist drop.
|
|
56
|
+
*/
|
|
57
|
+
declare function rebuildExpansionFromAnchors(diff: FileDiffMetadata, anchors: ExpansionAnchorRange[]): Map<number, HunkExpansionRegion>;
|
|
58
|
+
/**
|
|
59
|
+
* Genuine session exit: when session passes reshaped the hunks, run the real
|
|
60
|
+
* full recompute so exit state matches a non-session edit pipeline, and clear
|
|
61
|
+
* the marker. Returns true when a recompute ran.
|
|
62
|
+
*/
|
|
63
|
+
declare function finishEditSessionForDiff(diff: FileDiffMetadata, parseDiffOptions?: CreatePatchOptionsNonabortable): boolean;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { DivergenceCore, ExpansionAnchorRange, SessionRegionChange, applySessionChangedLines, captureExpansionAnchors, findDivergenceCore, finishEditSessionForDiff, normalizeEditorLines, rebuildExpansionFromAnchors, rebuildSessionHunks, remapExpandedHunksForRegionChange };
|
|
66
|
+
//# sourceMappingURL=editSessionHunks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editSessionHunks.d.ts","names":[],"sources":["../../src/utils/editSessionHunks.ts"],"mappings":";;;;UA6BiB,cAAA;EACf,KAAA;EACA,WAAA;EACA,WAAA;AAAA;AAAA,UAGQ,kBAAA;EACR,UAAA;EACA,SAAS;AAAA;;UAIM,mBAAA;EACf,OAAA,EAAS,KAAK,CAAC,kBAAA;AAAA;;;AALN;AAIX;;iBA4BgB,oBAAA,CAAqB,KAAe;;;;;iBAWpC,kBAAA,CACd,aAAA,YACA,aAAA,aACC,cAAc;AAzCkB;AA2BnC;;;;AA3BmC,iBAoEnB,mBAAA,CACd,IAAA,EAAM,gBAAA,EACN,gBAAA,GAAmB,8BAAA,GAClB,mBAAA;AAjCH;;;;AAAA,iBAoEgB,wBAAA,CACd,IAAA,EAAM,gBAAA,EACN,0BAAA,EAA4B,QAAA,UAC5B,gBAAA,GAAmB,8BAAA,EACnB,qBAAA,GAAwB,WAAA,mBACvB,mBAAA;;iBAwHa,iCAAA,CACd,aAAA,EAAe,GAAA,SAAY,mBAAA,GAC3B,MAAA,EAAQ,mBAAA,GACP,GAAA,SAAY,mBAAA;;AAjME;AA2BjB;;;;KAmMY,oBAAA,IAAwB,KAAA,UAAe,GAAG;;iBAGtC,uBAAA,CACd,IAAA,EAAM,gBAAA,EACN,aAAA,EAAe,GAAA,SAAY,mBAAA,GAC3B,yBAAA,WACC,oBAAA;;;;;;;iBAoDa,2BAAA,CACd,IAAA,EAAM,gBAAA,EACN,OAAA,EAAS,oBAAA,KACR,GAAA,SAAY,mBAAA;AA9PO;AAmCtB;;;;AAnCsB,iBA4SN,wBAAA,CACd,IAAA,EAAM,gBAAA,EACN,gBAAA,GAAmB,8BAA8B"}
|