@pierre/diffs 1.3.0-beta.4 → 1.3.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/dist/components/CodeView.d.ts +10 -11
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +14 -14
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +4 -4
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +53 -24
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +19 -18
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +89 -58
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.d.ts +0 -1
- package/dist/components/FileStream.d.ts.map +1 -1
- package/dist/components/FileStream.js +8 -6
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +1 -2
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +3 -3
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +5 -2
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +97 -35
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +8 -4
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +91 -30
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +1 -1
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +23 -24
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/components/web-components.d.ts.map +1 -1
- package/dist/components/web-components.js +2 -3
- package/dist/components/web-components.js.map +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -2
- package/dist/constants.js.map +1 -1
- package/dist/editor/command.d.ts +3 -2
- package/dist/editor/command.d.ts.map +1 -1
- package/dist/editor/command.js +10 -6
- package/dist/editor/command.js.map +1 -1
- package/dist/editor/editStack.d.ts +7 -1
- package/dist/editor/editStack.d.ts.map +1 -1
- package/dist/editor/editStack.js +3 -3
- package/dist/editor/editStack.js.map +1 -1
- package/dist/editor/editor.d.ts +56 -6
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +758 -397
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +3 -3
- package/dist/editor/editor2.js.map +1 -1
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/index.js +1 -2
- package/dist/editor/lineAnnotations.d.ts.map +1 -1
- package/dist/editor/lineAnnotations.js +2 -3
- package/dist/editor/lineAnnotations.js.map +1 -1
- package/dist/editor/marker.d.ts +4 -3
- package/dist/editor/marker.d.ts.map +1 -1
- package/dist/editor/marker.js +30 -13
- package/dist/editor/marker.js.map +1 -1
- package/dist/editor/pieceTable.d.ts +10 -3
- package/dist/editor/pieceTable.d.ts.map +1 -1
- package/dist/editor/pieceTable.js +170 -129
- package/dist/editor/pieceTable.js.map +1 -1
- package/dist/editor/platform.d.ts +8 -1
- package/dist/editor/platform.d.ts.map +1 -1
- package/dist/editor/platform.js +16 -5
- package/dist/editor/platform.js.map +1 -1
- package/dist/editor/searchPanel.d.ts +13 -3
- package/dist/editor/searchPanel.d.ts.map +1 -1
- package/dist/editor/searchPanel.js +194 -67
- package/dist/editor/searchPanel.js.map +1 -1
- package/dist/editor/selection.d.ts +41 -4
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/selection.js +423 -83
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/selectionAction.d.ts +4 -5
- package/dist/editor/selectionAction.d.ts.map +1 -1
- package/dist/editor/selectionAction.js +14 -64
- package/dist/editor/selectionAction.js.map +1 -1
- package/dist/editor/sprite.d.ts +2 -2
- package/dist/editor/sprite.d.ts.map +1 -1
- package/dist/editor/sprite.js +8 -8
- package/dist/editor/sprite.js.map +1 -1
- package/dist/editor/textDocument.d.ts +5 -4
- package/dist/editor/textDocument.d.ts.map +1 -1
- package/dist/editor/textDocument.js +26 -15
- package/dist/editor/textDocument.js.map +1 -1
- package/dist/editor/textMeasure.d.ts +37 -3
- package/dist/editor/textMeasure.d.ts.map +1 -1
- package/dist/editor/textMeasure.js +85 -10
- package/dist/editor/textMeasure.js.map +1 -1
- package/dist/editor/tokenzier.d.ts +1 -0
- package/dist/editor/tokenzier.d.ts.map +1 -1
- package/dist/editor/tokenzier.js +25 -19
- package/dist/editor/tokenzier.js.map +1 -1
- package/dist/editor/utils.d.ts +2 -1
- package/dist/editor/utils.d.ts.map +1 -1
- package/dist/editor/utils.js +6 -3
- package/dist/editor/utils.js.map +1 -1
- package/dist/highlighter/languages/areLanguagesAttached.d.ts.map +1 -1
- package/dist/highlighter/languages/areLanguagesAttached.js +1 -2
- package/dist/highlighter/languages/areLanguagesAttached.js.map +1 -1
- package/dist/highlighter/languages/attachResolvedLanguages.d.ts +0 -2
- package/dist/highlighter/languages/attachResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/attachResolvedLanguages.js +1 -2
- package/dist/highlighter/languages/attachResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/cleanUpResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/cleanUpResolvedLanguages.js +1 -2
- package/dist/highlighter/languages/cleanUpResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/constants.d.ts +0 -1
- package/dist/highlighter/languages/constants.d.ts.map +1 -1
- package/dist/highlighter/languages/constants.js +1 -1
- package/dist/highlighter/languages/constants.js.map +1 -1
- package/dist/highlighter/languages/getResolvedLanguages.d.ts +0 -2
- package/dist/highlighter/languages/getResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/getResolvedLanguages.js +1 -2
- package/dist/highlighter/languages/getResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts +0 -2
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.js +1 -2
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.js.map +1 -1
- package/dist/highlighter/languages/hasResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/hasResolvedLanguages.js +1 -2
- package/dist/highlighter/languages/hasResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/registerCustomLanguage.d.ts +0 -1
- package/dist/highlighter/languages/registerCustomLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/registerCustomLanguage.js +1 -2
- package/dist/highlighter/languages/registerCustomLanguage.js.map +1 -1
- package/dist/highlighter/languages/resolveLanguage.d.ts +0 -2
- package/dist/highlighter/languages/resolveLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/resolveLanguage.js +4 -5
- package/dist/highlighter/languages/resolveLanguage.js.map +1 -1
- package/dist/highlighter/languages/resolveLanguages.d.ts +0 -2
- package/dist/highlighter/languages/resolveLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/resolveLanguages.js +1 -2
- package/dist/highlighter/languages/resolveLanguages.js.map +1 -1
- package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
- package/dist/highlighter/shared_highlighter.js +3 -4
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/highlighter/themes/areThemesAttached.d.ts.map +1 -1
- package/dist/highlighter/themes/areThemesAttached.js +1 -2
- package/dist/highlighter/themes/areThemesAttached.js.map +1 -1
- package/dist/highlighter/themes/attachResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/attachResolvedThemes.js +1 -2
- package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.js +1 -2
- package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/constants.d.ts.map +1 -1
- package/dist/highlighter/themes/constants.js +1 -1
- package/dist/highlighter/themes/constants.js.map +1 -1
- package/dist/highlighter/themes/getResolvedOrResolveTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/getResolvedOrResolveTheme.js +1 -2
- package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
- package/dist/highlighter/themes/getResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/getResolvedThemes.js +1 -2
- package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/hasResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/hasResolvedThemes.js +1 -2
- package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +1 -2
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.js.map +1 -1
- package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomTheme.js +1 -2
- package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
- package/dist/highlighter/themes/resolveTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/resolveTheme.js +1 -2
- package/dist/highlighter/themes/resolveTheme.js.map +1 -1
- package/dist/highlighter/themes/resolveThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/resolveThemes.js +1 -2
- package/dist/highlighter/themes/resolveThemes.js.map +1 -1
- package/dist/highlighter/themes/themeResolution.d.ts.map +1 -1
- package/dist/highlighter/themes/themeResolution.js +1 -2
- package/dist/highlighter/themes/themeResolution.js.map +1 -1
- package/dist/highlighter/themes/themeResolver.d.ts +2 -2
- package/dist/highlighter/themes/themeResolver.d.ts.map +1 -1
- package/dist/highlighter/themes/themeResolver.js +1 -2
- package/dist/highlighter/themes/themeResolver.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +2 -3
- package/dist/managers/InteractionManager.d.ts +7 -0
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +26 -4
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +2 -2
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/managers/ScrollSyncManager.d.ts.map +1 -1
- package/dist/managers/ScrollSyncManager.js +1 -1
- package/dist/managers/ScrollSyncManager.js.map +1 -1
- package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
- package/dist/managers/UniversalRenderingManager.js +2 -2
- package/dist/managers/UniversalRenderingManager.js.map +1 -1
- package/dist/node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.d.ts +228 -0
- package/dist/node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +84 -0
- package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts.map +1 -0
- package/dist/react/CodeView.d.ts +1 -1
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +16 -15
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/EditorContext.d.ts +0 -1
- package/dist/react/EditorContext.d.ts.map +1 -1
- package/dist/react/EditorContext.js +2 -5
- package/dist/react/EditorContext.js.map +1 -1
- package/dist/react/File.d.ts +1 -0
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +4 -6
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +1 -0
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +4 -6
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +1 -0
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +4 -6
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +1 -0
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +4 -6
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +2 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js +4 -6
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/Virtualizer.d.ts.map +1 -1
- package/dist/react/Virtualizer.js +2 -5
- package/dist/react/Virtualizer.js.map +1 -1
- package/dist/react/WorkerPoolContext.d.ts +0 -1
- package/dist/react/WorkerPoolContext.d.ts.map +1 -1
- package/dist/react/WorkerPoolContext.js +2 -5
- package/dist/react/WorkerPoolContext.js.map +1 -1
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/constants.js +1 -1
- package/dist/react/constants.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -2
- package/dist/react/jsx.d.ts +0 -2
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/types.d.ts +2 -0
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +2 -0
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +18 -11
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +2 -0
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +18 -11
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/templateRender.d.ts.map +1 -1
- package/dist/react/utils/templateRender.js +1 -2
- package/dist/react/utils/templateRender.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +1 -3
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +1 -2
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useStableCallback.d.ts.map +1 -1
- package/dist/react/utils/useStableCallback.js +1 -2
- package/dist/react/utils/useStableCallback.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +10 -11
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +5 -5
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +73 -20
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +1 -3
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +23 -8
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +1 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +1 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/shiki-stream/index.js +1 -2
- package/dist/shiki-stream/stream.d.ts +0 -1
- package/dist/shiki-stream/stream.d.ts.map +1 -1
- package/dist/shiki-stream/stream.js +1 -2
- package/dist/shiki-stream/stream.js.map +1 -1
- package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
- package/dist/shiki-stream/tokenizer.js +1 -1
- package/dist/shiki-stream/tokenizer.js.map +1 -1
- package/dist/shiki-stream/types.d.ts +0 -1
- package/dist/shiki-stream/types.d.ts.map +1 -1
- package/dist/sprite.d.ts.map +1 -1
- package/dist/sprite.js +1 -1
- package/dist/ssr/FileDiffReact.d.ts.map +1 -1
- package/dist/ssr/FileDiffReact.js +4 -7
- package/dist/ssr/FileDiffReact.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/index.js +1 -2
- package/dist/ssr/preloadDiffs.d.ts +1 -1
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +1 -2
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/ssr/preloadFile.d.ts.map +1 -1
- package/dist/ssr/preloadFile.js +1 -2
- package/dist/ssr/preloadFile.js.map +1 -1
- package/dist/ssr/preloadPatchFile.d.ts.map +1 -1
- package/dist/ssr/preloadPatchFile.js +2 -3
- package/dist/ssr/preloadPatchFile.js.map +1 -1
- package/dist/ssr/renderHTML.d.ts +1 -1
- package/dist/ssr/renderHTML.d.ts.map +1 -1
- package/dist/ssr/renderHTML.js +1 -2
- package/dist/ssr/renderHTML.js.map +1 -1
- package/dist/string-import.d.ts +4 -0
- package/dist/string-import.d.ts.map +1 -1
- package/dist/style.js +3 -3
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +27 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.d.ts.map +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.js +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.js.map +1 -1
- package/dist/utils/areDiffRenderOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areDiffRenderOptionsEqual.js +1 -2
- package/dist/utils/areDiffRenderOptionsEqual.js.map +1 -1
- package/dist/utils/areDiffTargetsEqual.d.ts.map +1 -1
- package/dist/utils/areDiffTargetsEqual.js +1 -1
- package/dist/utils/areDiffTargetsEqual.js.map +1 -1
- package/dist/utils/areFileRenderOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areFileRenderOptionsEqual.js +1 -2
- package/dist/utils/areFileRenderOptionsEqual.js.map +1 -1
- package/dist/utils/areFilesEqual.d.ts.map +1 -1
- package/dist/utils/areFilesEqual.js +1 -1
- package/dist/utils/areFilesEqual.js.map +1 -1
- package/dist/utils/areHunkDataEqual.d.ts.map +1 -1
- package/dist/utils/areHunkDataEqual.js +1 -1
- package/dist/utils/areHunkDataEqual.js.map +1 -1
- package/dist/utils/areLineAnnotationsEqual.d.ts.map +1 -1
- package/dist/utils/areLineAnnotationsEqual.js +1 -1
- package/dist/utils/areLineAnnotationsEqual.js.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.d.ts.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js.map +1 -1
- package/dist/utils/areObjectsEqual.d.ts.map +1 -1
- package/dist/utils/areObjectsEqual.js +1 -1
- package/dist/utils/areObjectsEqual.js.map +1 -1
- package/dist/utils/areOptionsEqual.d.ts +0 -2
- package/dist/utils/areOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areOptionsEqual.js +1 -2
- package/dist/utils/areOptionsEqual.js.map +1 -1
- package/dist/utils/arePrePropertiesEqual.d.ts.map +1 -1
- package/dist/utils/arePrePropertiesEqual.js +1 -1
- package/dist/utils/arePrePropertiesEqual.js.map +1 -1
- package/dist/utils/areRenderRangesEqual.d.ts.map +1 -1
- package/dist/utils/areRenderRangesEqual.js +1 -1
- package/dist/utils/areRenderRangesEqual.js.map +1 -1
- package/dist/utils/areSelectionPointsEqual.d.ts.map +1 -1
- package/dist/utils/areSelectionPointsEqual.js +1 -1
- package/dist/utils/areSelectionPointsEqual.js.map +1 -1
- package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
- package/dist/utils/areSelectionsEqual.js +1 -1
- package/dist/utils/areSelectionsEqual.js.map +1 -1
- package/dist/utils/areThemesEqual.d.ts.map +1 -1
- package/dist/utils/areThemesEqual.js +1 -1
- package/dist/utils/areThemesEqual.js.map +1 -1
- package/dist/utils/areVirtualWindowSpecsEqual.d.ts.map +1 -1
- package/dist/utils/areVirtualWindowSpecsEqual.js +1 -1
- package/dist/utils/areVirtualWindowSpecsEqual.js.map +1 -1
- package/dist/utils/areWorkerStatsEqual.d.ts +0 -2
- package/dist/utils/areWorkerStatsEqual.d.ts.map +1 -1
- package/dist/utils/areWorkerStatsEqual.js +1 -1
- package/dist/utils/areWorkerStatsEqual.js.map +1 -1
- package/dist/utils/cleanLastNewline.d.ts.map +1 -1
- package/dist/utils/cleanLastNewline.js +1 -1
- package/dist/utils/cleanLastNewline.js.map +1 -1
- package/dist/utils/computeEstimatedDiffHeights.d.ts.map +1 -1
- package/dist/utils/computeEstimatedDiffHeights.js +1 -2
- package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
- package/dist/utils/computeFileOffsets.d.ts +9 -1
- package/dist/utils/computeFileOffsets.d.ts.map +1 -1
- package/dist/utils/computeFileOffsets.js +20 -2
- package/dist/utils/computeFileOffsets.js.map +1 -1
- package/dist/utils/computeVirtualFileMetrics.d.ts.map +1 -1
- package/dist/utils/computeVirtualFileMetrics.js +1 -2
- package/dist/utils/computeVirtualFileMetrics.js.map +1 -1
- package/dist/utils/createAnnotationElement.d.ts +1 -1
- package/dist/utils/createAnnotationElement.d.ts.map +1 -1
- package/dist/utils/createAnnotationElement.js +1 -2
- package/dist/utils/createAnnotationElement.js.map +1 -1
- package/dist/utils/createAnnotationWrapperNode.d.ts.map +1 -1
- package/dist/utils/createAnnotationWrapperNode.js +1 -1
- package/dist/utils/createAnnotationWrapperNode.js.map +1 -1
- package/dist/utils/createContentColumn.d.ts +1 -1
- package/dist/utils/createContentColumn.d.ts.map +1 -1
- package/dist/utils/createContentColumn.js +1 -2
- package/dist/utils/createContentColumn.js.map +1 -1
- package/dist/utils/createEmptyRowBuffer.d.ts +1 -1
- package/dist/utils/createEmptyRowBuffer.d.ts.map +1 -1
- package/dist/utils/createEmptyRowBuffer.js +1 -2
- package/dist/utils/createEmptyRowBuffer.js.map +1 -1
- package/dist/utils/createFileHeaderElement.d.ts +1 -1
- package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
- package/dist/utils/createFileHeaderElement.js +6 -3
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createGutterUtilityContentNode.d.ts.map +1 -1
- package/dist/utils/createGutterUtilityContentNode.js +1 -1
- package/dist/utils/createGutterUtilityContentNode.js.map +1 -1
- package/dist/utils/createGutterUtilityElement.d.ts +1 -1
- package/dist/utils/createGutterUtilityElement.d.ts.map +1 -1
- package/dist/utils/createGutterUtilityElement.js +1 -2
- package/dist/utils/createGutterUtilityElement.js.map +1 -1
- package/dist/utils/createNoNewlineElement.d.ts +1 -1
- package/dist/utils/createNoNewlineElement.d.ts.map +1 -1
- package/dist/utils/createNoNewlineElement.js +1 -2
- package/dist/utils/createNoNewlineElement.js.map +1 -1
- package/dist/utils/createPreElement.d.ts +1 -1
- package/dist/utils/createPreElement.d.ts.map +1 -1
- package/dist/utils/createPreElement.js +1 -2
- package/dist/utils/createPreElement.js.map +1 -1
- package/dist/utils/createRowNodes.d.ts.map +1 -1
- package/dist/utils/createRowNodes.js +1 -1
- package/dist/utils/createRowNodes.js.map +1 -1
- package/dist/utils/createSeparator.d.ts +1 -1
- package/dist/utils/createSeparator.d.ts.map +1 -1
- package/dist/utils/createSeparator.js +1 -2
- package/dist/utils/createSeparator.js.map +1 -1
- package/dist/utils/createSpanNodeFromToken.d.ts.map +1 -1
- package/dist/utils/createSpanNodeFromToken.js +1 -2
- package/dist/utils/createSpanNodeFromToken.js.map +1 -1
- package/dist/utils/createStyleElement.d.ts +1 -1
- package/dist/utils/createStyleElement.d.ts.map +1 -1
- package/dist/utils/createStyleElement.js +1 -2
- package/dist/utils/createStyleElement.js.map +1 -1
- package/dist/utils/createTransformerWithState.d.ts.map +1 -1
- package/dist/utils/createTransformerWithState.js +1 -2
- package/dist/utils/createTransformerWithState.js.map +1 -1
- package/dist/utils/createUnsafeCSSStyleNode.d.ts.map +1 -1
- package/dist/utils/createUnsafeCSSStyleNode.js +1 -2
- package/dist/utils/createUnsafeCSSStyleNode.js.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.js +5 -5
- package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
- package/dist/utils/cssWrappers.d.ts.map +1 -1
- package/dist/utils/cssWrappers.js +2 -3
- package/dist/utils/cssWrappers.js.map +1 -1
- package/dist/utils/detachString.d.ts.map +1 -1
- package/dist/utils/detachString.js +1 -1
- package/dist/utils/detachString.js.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.d.ts.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.js +1 -2
- package/dist/utils/diffAcceptRejectHunk.js.map +1 -1
- package/dist/utils/formatCSSVariablePrefix.d.ts.map +1 -1
- package/dist/utils/formatCSSVariablePrefix.js +1 -1
- package/dist/utils/formatCSSVariablePrefix.js.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.d.ts.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.js +1 -1
- package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
- package/dist/utils/getFileRendererOptions.d.ts.map +1 -1
- package/dist/utils/getFileRendererOptions.js +1 -1
- package/dist/utils/getFileRendererOptions.js.map +1 -1
- package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
- package/dist/utils/getFiletypeFromFileName.js +1 -1
- package/dist/utils/getFiletypeFromFileName.js.map +1 -1
- package/dist/utils/getHighlighterOptions.d.ts.map +1 -1
- package/dist/utils/getHighlighterOptions.js +1 -2
- package/dist/utils/getHighlighterOptions.js.map +1 -1
- package/dist/utils/getHighlighterThemeStyles.d.ts.map +1 -1
- package/dist/utils/getHighlighterThemeStyles.js +1 -2
- package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
- package/dist/utils/getHunkSeparatorSlotName.d.ts.map +1 -1
- package/dist/utils/getHunkSeparatorSlotName.js +1 -1
- package/dist/utils/getHunkSeparatorSlotName.js.map +1 -1
- package/dist/utils/getIconForType.d.ts.map +1 -1
- package/dist/utils/getIconForType.js +1 -1
- package/dist/utils/getIconForType.js.map +1 -1
- package/dist/utils/getLineAnnotationName.d.ts.map +1 -1
- package/dist/utils/getLineAnnotationName.js +1 -1
- package/dist/utils/getLineAnnotationName.js.map +1 -1
- package/dist/utils/getLineEndingType.d.ts.map +1 -1
- package/dist/utils/getLineEndingType.js +1 -1
- package/dist/utils/getLineEndingType.js.map +1 -1
- package/dist/utils/getLineNodes.d.ts +1 -1
- package/dist/utils/getLineNodes.d.ts.map +1 -1
- package/dist/utils/getLineNodes.js +1 -1
- package/dist/utils/getLineNodes.js.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.d.ts.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.js +1 -1
- package/dist/utils/getMergeConflictActionSlotName.js.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.d.ts.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.js +1 -2
- package/dist/utils/getMergeConflictLineTypes.js.map +1 -1
- package/dist/utils/getOrCreateCodeNode.d.ts.map +1 -1
- package/dist/utils/getOrCreateCodeNode.js +1 -1
- package/dist/utils/getOrCreateCodeNode.js.map +1 -1
- package/dist/utils/getSingularPatch.d.ts.map +1 -1
- package/dist/utils/getSingularPatch.js +1 -2
- package/dist/utils/getSingularPatch.js.map +1 -1
- package/dist/utils/getThemes.d.ts.map +1 -1
- package/dist/utils/getThemes.js +1 -2
- package/dist/utils/getThemes.js.map +1 -1
- package/dist/utils/getTotalLineCountFromHunks.d.ts.map +1 -1
- package/dist/utils/getTotalLineCountFromHunks.js +1 -1
- package/dist/utils/getTotalLineCountFromHunks.js.map +1 -1
- package/dist/utils/hast_utils.d.ts +1 -1
- package/dist/utils/hast_utils.d.ts.map +1 -1
- package/dist/utils/hast_utils.js +1 -1
- package/dist/utils/hast_utils.js.map +1 -1
- package/dist/utils/hostTheme.d.ts.map +1 -1
- package/dist/utils/hostTheme.js +1 -2
- package/dist/utils/hostTheme.js.map +1 -1
- package/dist/utils/includesFileAnnotations.d.ts +17 -0
- package/dist/utils/includesFileAnnotations.d.ts.map +1 -0
- package/dist/utils/includesFileAnnotations.js +19 -0
- package/dist/utils/includesFileAnnotations.js.map +1 -0
- package/dist/utils/isDefaultRenderRange.d.ts.map +1 -1
- package/dist/utils/isDefaultRenderRange.js +1 -1
- package/dist/utils/isDefaultRenderRange.js.map +1 -1
- package/dist/utils/isDiffPlainText.d.ts.map +1 -1
- package/dist/utils/isDiffPlainText.js +1 -2
- package/dist/utils/isDiffPlainText.js.map +1 -1
- package/dist/utils/isFilePlainText.d.ts.map +1 -1
- package/dist/utils/isFilePlainText.js +1 -2
- package/dist/utils/isFilePlainText.js.map +1 -1
- package/dist/utils/isStyleNode.d.ts.map +1 -1
- package/dist/utils/isStyleNode.js +1 -1
- package/dist/utils/isStyleNode.js.map +1 -1
- package/dist/utils/isWorkerContext.d.ts.map +1 -1
- package/dist/utils/isWorkerContext.js +1 -1
- package/dist/utils/isWorkerContext.js.map +1 -1
- package/dist/utils/iterateOverDiff.d.ts.map +1 -1
- package/dist/utils/iterateOverDiff.js +44 -45
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/normalizeDiffResolution.d.ts.map +1 -1
- package/dist/utils/normalizeDiffResolution.js +1 -1
- package/dist/utils/normalizeDiffResolution.js.map +1 -1
- package/dist/utils/parseDiffDecorations.d.ts.map +1 -1
- package/dist/utils/parseDiffDecorations.js +1 -2
- package/dist/utils/parseDiffDecorations.js.map +1 -1
- package/dist/utils/parseDiffFromFile.d.ts +0 -1
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +1 -2
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/parseLineType.d.ts.map +1 -1
- package/dist/utils/parseLineType.js +1 -1
- package/dist/utils/parseLineType.js.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.js +5 -5
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +6 -7
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/prefersReducedMotion.d.ts.map +1 -1
- package/dist/utils/prefersReducedMotion.js +1 -1
- package/dist/utils/prefersReducedMotion.js.map +1 -1
- package/dist/utils/prerenderHTMLIfNecessary.d.ts.map +1 -1
- package/dist/utils/prerenderHTMLIfNecessary.js +1 -1
- package/dist/utils/prerenderHTMLIfNecessary.js.map +1 -1
- package/dist/utils/processLine.d.ts +1 -1
- package/dist/utils/processLine.d.ts.map +1 -1
- package/dist/utils/processLine.js +1 -2
- package/dist/utils/processLine.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +8 -7
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +5 -4
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/resolveConflict.d.ts.map +1 -1
- package/dist/utils/resolveConflict.js +1 -2
- package/dist/utils/resolveConflict.js.map +1 -1
- package/dist/utils/resolveRegion.d.ts.map +1 -1
- package/dist/utils/resolveRegion.js +1 -1
- package/dist/utils/resolveRegion.js.map +1 -1
- package/dist/utils/roundToDevicePixel.d.ts.map +1 -1
- package/dist/utils/roundToDevicePixel.js +1 -1
- package/dist/utils/roundToDevicePixel.js.map +1 -1
- package/dist/utils/scrollbarGutter.d.ts.map +1 -1
- package/dist/utils/scrollbarGutter.js +1 -2
- package/dist/utils/scrollbarGutter.js.map +1 -1
- package/dist/utils/setLanguageOverride.d.ts.map +1 -1
- package/dist/utils/setLanguageOverride.js +1 -1
- package/dist/utils/setLanguageOverride.js.map +1 -1
- package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +1 -1
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/utils/shouldUseTokenTransformer.d.ts.map +1 -1
- package/dist/utils/shouldUseTokenTransformer.js +1 -1
- package/dist/utils/shouldUseTokenTransformer.js.map +1 -1
- package/dist/utils/splitFileContents.d.ts.map +1 -1
- package/dist/utils/splitFileContents.js +1 -2
- package/dist/utils/splitFileContents.js.map +1 -1
- package/dist/utils/trimPatchContext.d.ts.map +1 -1
- package/dist/utils/trimPatchContext.js +1 -2
- package/dist/utils/trimPatchContext.js.map +1 -1
- package/dist/utils/updateDiffHunks.d.ts +2 -1
- package/dist/utils/updateDiffHunks.d.ts.map +1 -1
- package/dist/utils/updateDiffHunks.js +22 -3
- package/dist/utils/updateDiffHunks.js.map +1 -1
- package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
- package/dist/utils/virtualDiffLayout.js +1 -2
- package/dist/utils/virtualDiffLayout.js.map +1 -1
- package/dist/utils/wrapTokenFragments.d.ts +1 -1
- package/dist/utils/wrapTokenFragments.d.ts.map +1 -1
- package/dist/utils/wrapTokenFragments.js +1 -2
- package/dist/utils/wrapTokenFragments.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +5 -5
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/getOrCreateWorkerPoolSingleton.d.ts.map +1 -1
- package/dist/worker/getOrCreateWorkerPoolSingleton.js +1 -2
- package/dist/worker/getOrCreateWorkerPoolSingleton.js.map +1 -1
- package/dist/worker/index.js +1 -2
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/wasm-B9ZqxnKj.js +8 -0
- package/dist/worker/wasm-B9ZqxnKj.js.map +1 -0
- package/dist/worker/worker-portable.js +2989 -6577
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +97 -127
- package/dist/worker/worker.js.map +1 -1
- package/package.json +14 -21
- package/dist/worker/wasm-BaDzIkIn.js +0 -10
- package/dist/worker/wasm-BaDzIkIn.js.map +0 -1
package/dist/editor/editor.js
CHANGED
|
@@ -1,35 +1,30 @@
|
|
|
1
|
+
import { queueRender } from "../managers/UniversalRenderingManager.js";
|
|
1
2
|
import { getFiletypeFromFileName } from "../utils/getFiletypeFromFileName.js";
|
|
2
3
|
import { isMoveCursorShortcut, isPrimaryModifier, isSafari } from "./platform.js";
|
|
3
|
-
import { resolveEditorCommandFromKeyboardEvent } from "./command.js";
|
|
4
|
+
import { resolveEditorCommandFromKeyboardEvent, resolveFindAgainShortcut } from "./command.js";
|
|
5
|
+
import { EditStack } from "./editStack.js";
|
|
4
6
|
import editor_default from "./editor2.js";
|
|
5
7
|
import { addEventListener, clampDomOffset, extend, getLineNumberAttr, h, round } from "./utils.js";
|
|
6
8
|
import { applyDocumentChangeToLineAnnotations, renderLineAnnotations } from "./lineAnnotations.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
+
import { applyDeleteCharacterToSelections, applyDeleteHardLineForwardToSelections, applyDeleteSoftLineBackwardToSelections, applyDeleteWordBackwardToSelections, applyTextChangeToSelections, applyTextReplaceToSelections, applyTransposeToSelections, comparePosition, convertSelection, createSelectionFrom, createSelectionFromAnchorAndFocusOffsets, expandCollapsedSelectionToWord, extendSelection, extendSelections, findNexMatch, getAutoSurroundReplacementTexts, getCaretPosition, getDocumentBoundarySelection, getDocumentFullSelection, getSelectionAnchor, getSelectionText, isCollapsedSelection, isLineEditable, mapCursorMove, mapSelectionShift, mergeOverlappingSelections, remapSelectionsAfterEdits, resolveIndentEdits, resolveSelectionCut, selectionIntersects } from "./selection.js";
|
|
10
|
+
import { MarkerRenderer, markerSeverityDatasetKey } from "./marker.js";
|
|
9
11
|
import { createSpriteElement } from "./sprite.js";
|
|
10
12
|
import { SearchPanelWidget } from "./searchPanel.js";
|
|
11
13
|
import { SelectionActionWidget } from "./selectionAction.js";
|
|
12
14
|
import { TextDocument } from "./textDocument.js";
|
|
13
15
|
import { Metrics, getExpandedAsciiTextColumns, getUnicodeMeasurementOffsets, snapTextOffsetToUnicodeBoundary } from "./textMeasure.js";
|
|
14
16
|
import { EditorTokenizer, renderLineTokens } from "./tokenzier.js";
|
|
15
|
-
|
|
16
17
|
//#region src/editor/editor.ts
|
|
18
|
+
const MAX_EDIT_WIDEN_WINDOW_MULTIPLE = 2;
|
|
17
19
|
var Editor = class {
|
|
18
20
|
#options;
|
|
19
|
-
#wrap = false;
|
|
20
21
|
#metrics = new Metrics();
|
|
21
22
|
#tokenizer;
|
|
22
|
-
#markerManager;
|
|
23
23
|
#editorEventDisposes;
|
|
24
24
|
#globalEventDisposes;
|
|
25
25
|
#selectEventDisposes;
|
|
26
26
|
#detach;
|
|
27
|
-
#
|
|
28
|
-
#fileContents;
|
|
29
|
-
#lineAnnotations;
|
|
30
|
-
#textDocument;
|
|
31
|
-
#renderRange;
|
|
32
|
-
#codePaddingTop = 0;
|
|
27
|
+
#contentOffset;
|
|
33
28
|
#gutterWidthCache;
|
|
34
29
|
#contentWidthCache;
|
|
35
30
|
#lineYCache = /* @__PURE__ */ new Map();
|
|
@@ -44,24 +39,35 @@ var Editor = class {
|
|
|
44
39
|
#gutterElement;
|
|
45
40
|
#contentElement;
|
|
46
41
|
#overlayElement;
|
|
47
|
-
#primaryCaretElement;
|
|
48
42
|
#overlayElements;
|
|
49
|
-
#
|
|
50
|
-
#searchPanel;
|
|
43
|
+
#primaryCaretElement;
|
|
51
44
|
#resizeObserver;
|
|
45
|
+
#fileInstance;
|
|
46
|
+
#fileInfo;
|
|
47
|
+
#lineAnnotations;
|
|
48
|
+
#textDocument;
|
|
49
|
+
#renderRange;
|
|
50
|
+
#viewportWindowLines;
|
|
51
|
+
#markerRenderer;
|
|
52
|
+
#searchPanel;
|
|
53
|
+
#selectionAction;
|
|
52
54
|
#shouldIgnoreSelectionChange = false;
|
|
55
|
+
#contentHasFocus = false;
|
|
56
|
+
#isComposing = false;
|
|
53
57
|
#isGutterMouseDown = false;
|
|
54
58
|
#isContentMouseDown = false;
|
|
55
59
|
#shiftKeyPressed = false;
|
|
56
60
|
#selectionStart;
|
|
61
|
+
#deletedSelectionText = "";
|
|
57
62
|
#reservedSelections;
|
|
58
|
-
#selections;
|
|
59
63
|
#initSelections;
|
|
64
|
+
#selections;
|
|
60
65
|
#matches;
|
|
61
66
|
#scrollingToLine;
|
|
62
67
|
#scrollingToLineChar;
|
|
63
68
|
#scrollingToLineNoFocus = false;
|
|
64
69
|
#retainSearchPanelFocus = false;
|
|
70
|
+
#fontRemeasureScheduled = false;
|
|
65
71
|
#onDeferTokenize = (lines, themeType) => {
|
|
66
72
|
this.#fileInstance?.updateRenderCache(lines, themeType);
|
|
67
73
|
if (this.#renderRange !== void 0 && this.#renderRange.totalLines !== Infinity) {
|
|
@@ -77,15 +83,15 @@ var Editor = class {
|
|
|
77
83
|
this.#options = options;
|
|
78
84
|
}
|
|
79
85
|
edit(component) {
|
|
80
|
-
const { useTokenTransformer, enableGutterUtility, enableLineSelection, expandUnchanged,
|
|
81
|
-
|
|
86
|
+
const { useTokenTransformer, enableGutterUtility, enableLineSelection, expandUnchanged, lineHoverHighlight, ...rest } = component.options;
|
|
87
|
+
const isDiff = component.type === "file-diff";
|
|
88
|
+
if (useTokenTransformer !== true || enableGutterUtility === true || enableLineSelection === true || expandUnchanged !== true && isDiff || lineHoverHighlight !== "disabled") {
|
|
82
89
|
component.setOptions({
|
|
83
90
|
...rest,
|
|
84
91
|
useTokenTransformer: true,
|
|
85
92
|
enableGutterUtility: false,
|
|
86
93
|
enableLineSelection: false,
|
|
87
94
|
expandUnchanged: true,
|
|
88
|
-
diffStyle: "split",
|
|
89
95
|
lineHoverHighlight: "disabled"
|
|
90
96
|
});
|
|
91
97
|
component.rerender();
|
|
@@ -95,7 +101,171 @@ var Editor = class {
|
|
|
95
101
|
this.#detach = component.attachEditor(this);
|
|
96
102
|
return () => this.cleanUp();
|
|
97
103
|
}
|
|
98
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Apply edits to current attached file.
|
|
106
|
+
*/
|
|
107
|
+
applyEdits(edits, updateHistory = false) {
|
|
108
|
+
const textDocument = this.#textDocument;
|
|
109
|
+
if (textDocument == null) throw new Error("Editor is not attached");
|
|
110
|
+
const wasFocused = this.#contentHasFocus;
|
|
111
|
+
const selectionsBefore = this.#selections;
|
|
112
|
+
const selectionOffsetsBefore = selectionsBefore?.map((selection) => [textDocument.offsetAt(selection.start), textDocument.offsetAt(selection.end)]);
|
|
113
|
+
const resolvedEditOffsets = selectionsBefore === void 0 ? void 0 : edits.map((edit) => {
|
|
114
|
+
const a = textDocument.offsetAt(edit.range.start);
|
|
115
|
+
const b = textDocument.offsetAt(edit.range.end);
|
|
116
|
+
return {
|
|
117
|
+
start: Math.min(a, b),
|
|
118
|
+
end: Math.max(a, b),
|
|
119
|
+
text: edit.newText
|
|
120
|
+
};
|
|
121
|
+
}).sort((a, b) => a.start - b.start);
|
|
122
|
+
const change = textDocument.applyEdits(edits, updateHistory, selectionsBefore);
|
|
123
|
+
if (change === void 0) return;
|
|
124
|
+
let nextSelections;
|
|
125
|
+
if (selectionsBefore !== void 0 && selectionOffsetsBefore !== void 0 && resolvedEditOffsets !== void 0) {
|
|
126
|
+
nextSelections = remapSelectionsAfterEdits(textDocument, selectionsBefore, selectionOffsetsBefore, resolvedEditOffsets);
|
|
127
|
+
if (updateHistory) textDocument.setLastUndoSelectionsAfter(nextSelections);
|
|
128
|
+
}
|
|
129
|
+
this.#applyChange(change, nextSelections, this.#applyChangeToLineAnnotations(change), { skipFocus: !wasFocused });
|
|
130
|
+
}
|
|
131
|
+
/** Whether there is an edit to undo. */
|
|
132
|
+
get canUndo() {
|
|
133
|
+
return this.#textDocument?.canUndo ?? false;
|
|
134
|
+
}
|
|
135
|
+
/** Whether there is an undone edit to redo. */
|
|
136
|
+
get canRedo() {
|
|
137
|
+
return this.#textDocument?.canRedo ?? false;
|
|
138
|
+
}
|
|
139
|
+
/** Undo the last edit. Does nothing when there is nothing to undo. */
|
|
140
|
+
undo() {
|
|
141
|
+
this.#runCommand("undo");
|
|
142
|
+
}
|
|
143
|
+
/** Redo the last undone edit. Does nothing when there is nothing to redo. */
|
|
144
|
+
redo() {
|
|
145
|
+
this.#runCommand("redo");
|
|
146
|
+
}
|
|
147
|
+
getState() {
|
|
148
|
+
const fileRef = this.#getFileRef();
|
|
149
|
+
if (fileRef === void 0) throw new Error("Editor is not attached");
|
|
150
|
+
return {
|
|
151
|
+
file: {
|
|
152
|
+
...fileRef,
|
|
153
|
+
cacheKey: "edited-at-" + Date.now()
|
|
154
|
+
},
|
|
155
|
+
selections: this.#selections,
|
|
156
|
+
lineAnnotations: this.#lineAnnotations,
|
|
157
|
+
renderRange: this.#renderRange
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
setState({ file, lineAnnotations, renderRange, selections }) {
|
|
161
|
+
this.#resetCache();
|
|
162
|
+
this.#resetState();
|
|
163
|
+
this.#initSelections = selections;
|
|
164
|
+
this.#fileInstance?.render({
|
|
165
|
+
file: {
|
|
166
|
+
...file,
|
|
167
|
+
cacheKey: "edited-at-" + Date.now()
|
|
168
|
+
},
|
|
169
|
+
lineAnnotations,
|
|
170
|
+
renderRange
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
setSelections(selections) {
|
|
174
|
+
const textDocument = this.#textDocument;
|
|
175
|
+
if (textDocument === void 0) throw new Error("Text document is not initialized");
|
|
176
|
+
const resolvedSelections = selections.map((selection) => {
|
|
177
|
+
const start = textDocument.normalizePosition(selection.start);
|
|
178
|
+
const end = textDocument.normalizePosition(selection.end);
|
|
179
|
+
return {
|
|
180
|
+
direction: selection.direction === "none" ? 0 : selection.direction === "backward" ? -1 : 1,
|
|
181
|
+
start,
|
|
182
|
+
end
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
this.#updateSelections(resolvedSelections);
|
|
186
|
+
this.#scrollToPrimaryCaret(false, "center");
|
|
187
|
+
}
|
|
188
|
+
setMarkers(markers) {
|
|
189
|
+
const textDocument = this.#textDocument;
|
|
190
|
+
if (textDocument === void 0) throw new Error("Text document is not initialized");
|
|
191
|
+
if (markers.length === 0) {
|
|
192
|
+
this.#markerRenderer?.cleanup();
|
|
193
|
+
this.#markerRenderer = void 0;
|
|
194
|
+
this.#updateSelections(this.#selections ?? []);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
this.#markerRenderer ??= new MarkerRenderer({
|
|
198
|
+
getLineHeight: () => this.#metrics.lineHeight,
|
|
199
|
+
getOverlayElement: () => this.#overlayElement,
|
|
200
|
+
getGutterWidth: () => this.#getGutterWidth(),
|
|
201
|
+
getCharX: (line, character) => this.#getCharX(line, character),
|
|
202
|
+
getLineY: (line) => this.#getLineY(line),
|
|
203
|
+
isMouseDown: () => this.#isContentMouseDown || this.#isGutterMouseDown
|
|
204
|
+
});
|
|
205
|
+
this.#markerRenderer.setMarkers(markers, textDocument);
|
|
206
|
+
if (this.#contentElement !== void 0) this.#markerRenderer.listenHover(this.#contentElement);
|
|
207
|
+
this.#updateSelections(this.#selections ?? []);
|
|
208
|
+
}
|
|
209
|
+
focus(options) {
|
|
210
|
+
const preventScroll = options?.preventScroll ?? false;
|
|
211
|
+
const primarySelection = this.#selections?.at(-1);
|
|
212
|
+
if (primarySelection !== void 0) {
|
|
213
|
+
const pos = primarySelection.direction === -1 ? primarySelection.end : primarySelection.start;
|
|
214
|
+
this.#focus(pos, preventScroll);
|
|
215
|
+
} else this.#focus(void 0, preventScroll);
|
|
216
|
+
}
|
|
217
|
+
blur() {
|
|
218
|
+
this.#contentElement?.blur();
|
|
219
|
+
}
|
|
220
|
+
cleanUp() {
|
|
221
|
+
this.#tokenizer?.cleanUp();
|
|
222
|
+
this.#tokenizer = void 0;
|
|
223
|
+
this.#globalEventDisposes?.forEach((dispose) => dispose());
|
|
224
|
+
this.#globalEventDisposes = void 0;
|
|
225
|
+
this.#editorEventDisposes?.forEach((dispose) => dispose());
|
|
226
|
+
this.#editorEventDisposes = void 0;
|
|
227
|
+
this.#selectEventDisposes?.forEach((dispose) => dispose());
|
|
228
|
+
this.#selectEventDisposes = void 0;
|
|
229
|
+
this.#detach?.();
|
|
230
|
+
this.#detach = void 0;
|
|
231
|
+
this.#gutterWidthCache = void 0;
|
|
232
|
+
this.#contentWidthCache = void 0;
|
|
233
|
+
this.#lineYCache.clear();
|
|
234
|
+
this.#wrapLineOffsetsCache.clear();
|
|
235
|
+
this.#lastAccessedLineElement = void 0;
|
|
236
|
+
this.#lastAccessedCharX = void 0;
|
|
237
|
+
this.#globalStyleElement?.remove();
|
|
238
|
+
this.#globalStyleElement = void 0;
|
|
239
|
+
this.#editorStyleElement?.remove();
|
|
240
|
+
this.#editorStyleElement = void 0;
|
|
241
|
+
this.#themeStyleElement?.remove();
|
|
242
|
+
this.#themeStyleElement = void 0;
|
|
243
|
+
this.#spriteElement?.remove();
|
|
244
|
+
this.#spriteElement = void 0;
|
|
245
|
+
this.#fileContainer = void 0;
|
|
246
|
+
this.#gutterElement = void 0;
|
|
247
|
+
this.#contentElement?.removeAttribute("contentEditable");
|
|
248
|
+
this.#contentElement = void 0;
|
|
249
|
+
this.#contentHasFocus = false;
|
|
250
|
+
this.#overlayElement?.remove();
|
|
251
|
+
this.#overlayElement = void 0;
|
|
252
|
+
this.#resizeObserver?.disconnect();
|
|
253
|
+
this.#resizeObserver = void 0;
|
|
254
|
+
this.#fontRemeasureScheduled = false;
|
|
255
|
+
this.#resetState();
|
|
256
|
+
}
|
|
257
|
+
/** @internal */
|
|
258
|
+
__postponeBackgroundTokenizeToNextFrame() {
|
|
259
|
+
const tokenizer = this.#tokenizer;
|
|
260
|
+
if (tokenizer !== void 0) {
|
|
261
|
+
tokenizer.pauseBackgroundTokenize();
|
|
262
|
+
requestAnimationFrame(() => {
|
|
263
|
+
tokenizer.resumeBackgroundTokenize();
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/** @internal */
|
|
268
|
+
__syncRenderView = (highlighter, fileContainer, fileOrDiff, lineAnnotations, renderRange) => {
|
|
99
269
|
const shadowRoot = fileContainer.shadowRoot;
|
|
100
270
|
if (shadowRoot == null) {
|
|
101
271
|
console.error("[editor] Could not find the shadow root.");
|
|
@@ -107,10 +277,10 @@ var Editor = class {
|
|
|
107
277
|
for (const el of shadowRoot.querySelectorAll("[data-code]")) if (el.dataset.deletions === void 0) {
|
|
108
278
|
codeElement = el;
|
|
109
279
|
for (const child of el.children) {
|
|
110
|
-
const el
|
|
111
|
-
const { gutter, content } = el
|
|
112
|
-
if (gutter !== void 0) gutterEl = el
|
|
113
|
-
else if (content !== void 0) contentEl = el
|
|
280
|
+
const el = child;
|
|
281
|
+
const { gutter, content } = el.dataset;
|
|
282
|
+
if (gutter !== void 0) gutterEl = el;
|
|
283
|
+
else if (content !== void 0) contentEl = el;
|
|
114
284
|
}
|
|
115
285
|
break;
|
|
116
286
|
}
|
|
@@ -122,9 +292,19 @@ var Editor = class {
|
|
|
122
292
|
if (this.#themeStyleElement !== void 0) shadowRoot.appendChild(this.#themeStyleElement);
|
|
123
293
|
if (this.#spriteElement !== void 0) shadowRoot.prepend(this.#spriteElement);
|
|
124
294
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
295
|
+
const documentReplaced = this.#textDocument === void 0 || this.#fileInfo === void 0 || this.#fileInfo.name !== fileOrDiff.name || this.#fileInfo.lang !== fileOrDiff.lang || this.#fileInfo.cacheKey !== fileOrDiff.cacheKey;
|
|
296
|
+
if (documentReplaced) {
|
|
297
|
+
let contents = "";
|
|
298
|
+
if ("contents" in fileOrDiff) contents = fileOrDiff.contents;
|
|
299
|
+
else contents = fileOrDiff.additionLines.join("");
|
|
300
|
+
const editStack = new EditStack({ maxEntries: this.#options.historyMaxEntries });
|
|
301
|
+
const textDocument = new TextDocument(fileOrDiff.name, contents, fileOrDiff.lang ?? getFiletypeFromFileName(fileOrDiff.name), 0, editStack);
|
|
302
|
+
const { name, lang, cacheKey } = fileOrDiff;
|
|
303
|
+
this.#fileInfo = {
|
|
304
|
+
name,
|
|
305
|
+
lang,
|
|
306
|
+
cacheKey
|
|
307
|
+
};
|
|
128
308
|
this.#textDocument = textDocument;
|
|
129
309
|
this.#tokenizer?.cleanUp();
|
|
130
310
|
this.#tokenizer = new EditorTokenizer({
|
|
@@ -137,25 +317,16 @@ var Editor = class {
|
|
|
137
317
|
},
|
|
138
318
|
__debug: this.#options.__debug
|
|
139
319
|
});
|
|
140
|
-
this.#
|
|
141
|
-
this.#
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.#
|
|
146
|
-
this.#scrollingToLine = void 0;
|
|
147
|
-
this.#reservedSelections = void 0;
|
|
148
|
-
this.#searchPanel?.cleanup();
|
|
149
|
-
this.#searchPanel = void 0;
|
|
150
|
-
this.#selectionAction?.cleanup();
|
|
151
|
-
this.#selectionAction = void 0;
|
|
320
|
+
this.#resetState();
|
|
321
|
+
this.#selections = this.#initSelections;
|
|
322
|
+
requestAnimationFrame(() => {
|
|
323
|
+
this.#options.onAttach?.(this, this.#fileInstance);
|
|
324
|
+
});
|
|
325
|
+
if (this.#textDocument !== void 0 && this.#options.__debug === true) console.log("[diffs/editor] text document changed !!!");
|
|
152
326
|
}
|
|
327
|
+
let fullRerender = false;
|
|
153
328
|
if (this.#contentElement !== contentEl) {
|
|
154
|
-
|
|
155
|
-
const codePaddingTop = parseInt(getComputedStyle(codeElement).paddingTop.slice(0, -2), 10);
|
|
156
|
-
this.#codePaddingTop = Number.isNaN(codePaddingTop) ? 0 : codePaddingTop;
|
|
157
|
-
this.#gutterWidthCache = void 0;
|
|
158
|
-
this.#contentWidthCache = void 0;
|
|
329
|
+
fullRerender = true;
|
|
159
330
|
this.#gutterElement = gutterEl;
|
|
160
331
|
this.#contentElement = extend(contentEl, {
|
|
161
332
|
contentEditable: "true",
|
|
@@ -169,135 +340,72 @@ var Editor = class {
|
|
|
169
340
|
});
|
|
170
341
|
if (this.#overlayElement !== void 0) contentEl.after(this.#overlayElement);
|
|
171
342
|
this.#metrics.init(contentEl);
|
|
343
|
+
this.#remeasureMetricsOnFontLoad();
|
|
172
344
|
this.#listenContentElement(contentEl, gutterEl);
|
|
345
|
+
if (this.#contentElement !== void 0 && this.#options.__debug === true) console.log("[diffs/editor] full re-render triggered !!!");
|
|
173
346
|
}
|
|
174
|
-
|
|
175
|
-
this.#
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
347
|
+
if (contentEl.ariaLabel !== fileOrDiff.name) contentEl.ariaLabel = fileOrDiff.name;
|
|
348
|
+
if (lineAnnotations !== void 0 && lineAnnotations.length > 0 || this.#isDiff && this.#diffSyle === "unified") for (const child of this.#contentElement.children) {
|
|
349
|
+
const el = child;
|
|
350
|
+
const { lineAnnotation, lineType } = el.dataset;
|
|
351
|
+
if (lineAnnotation !== void 0 || lineType === "change-deletion") el.setAttribute("contenteditable", "false");
|
|
352
|
+
}
|
|
353
|
+
this.#resetCache();
|
|
354
|
+
this.#tokenizer?.syncTheme(this.#fileInstance?.options ?? {});
|
|
179
355
|
this.#lineAnnotations = lineAnnotations;
|
|
180
356
|
this.#renderRange = renderRange;
|
|
357
|
+
this.#viewportWindowLines = renderRange?.totalLines;
|
|
181
358
|
this.#tokenizer?.prebuildStateStack(renderRange);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (this.#options.__debug === true && renderRange !== void 0) {
|
|
188
|
-
const { startingLine, totalLines } = renderRange;
|
|
189
|
-
console.log("[diffs/editor] render file:", fileContents.name, "RenderRange:", startingLine + "-" + (startingLine + totalLines), "of", this.#textDocument.lineCount, "lines");
|
|
359
|
+
const fileInstance = this.#fileInstance;
|
|
360
|
+
const textDocument = this.#textDocument;
|
|
361
|
+
if (!documentReplaced && fullRerender && fileInstance?.rerenderFromDocument !== void 0 && textDocument !== void 0 && this.#shouldRenderDivergeFromDocument(textDocument)) {
|
|
362
|
+
fileInstance.rerenderFromDocument(textDocument);
|
|
363
|
+
return;
|
|
190
364
|
}
|
|
191
|
-
|
|
365
|
+
this.#markerRenderer?.removePopup();
|
|
366
|
+
if (this.#selections !== void 0 || this.#matches !== void 0 || this.#markerRenderer !== void 0) this.#updateSelections(this.#selections ?? []);
|
|
367
|
+
if (this.#initSelections !== void 0 && this.#primaryCaretElement !== void 0) {
|
|
368
|
+
this.#initSelections = void 0;
|
|
369
|
+
this.#scrollToPrimaryCaret(false, "center");
|
|
370
|
+
} else if (this.#scrollingToLine !== void 0) this.#scrollToLine(this.#scrollingToLine, this.#scrollingToLineChar, this.#scrollingToLineNoFocus);
|
|
192
371
|
else if (this.#selections !== void 0 && this.#selections.length > 0 && !this.#retainSearchPanelFocus) this.focus({ preventScroll: true });
|
|
193
372
|
if (this.#retainSearchPanelFocus) this.#searchPanel?.focus();
|
|
194
|
-
if (this.#
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const tokenizer = this.#tokenizer;
|
|
198
|
-
if (tokenizer !== void 0) {
|
|
199
|
-
tokenizer.pauseBackgroundTokenize();
|
|
200
|
-
requestAnimationFrame(() => {
|
|
201
|
-
tokenizer.resumeBackgroundTokenize();
|
|
202
|
-
});
|
|
373
|
+
if (this.#options.__debug === true && renderRange !== void 0) {
|
|
374
|
+
const { startingLine, totalLines } = renderRange;
|
|
375
|
+
console.log("[diffs/editor] render file:", fileOrDiff.name, "RenderRange:", startingLine + "-" + (startingLine + totalLines), "of", this.#textDocument?.lineCount, "lines");
|
|
203
376
|
}
|
|
377
|
+
};
|
|
378
|
+
get #diffSyle() {
|
|
379
|
+
return this.#fileInstance?.options.diffStyle ?? "split";
|
|
204
380
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (textDocument !== void 0) {
|
|
208
|
-
const resolvedSelections = selections.map((selection) => {
|
|
209
|
-
const start = textDocument.normalizePosition(selection.start);
|
|
210
|
-
const end = textDocument.normalizePosition(selection.end);
|
|
211
|
-
return {
|
|
212
|
-
direction: selection.direction === "none" ? DirectionNone : selection.direction === "backward" ? DirectionBackward : DirectionForward,
|
|
213
|
-
start,
|
|
214
|
-
end
|
|
215
|
-
};
|
|
216
|
-
});
|
|
217
|
-
this.#updateSelections(resolvedSelections);
|
|
218
|
-
this.#scrollToPrimaryCaret();
|
|
219
|
-
} else this.#initSelections = selections;
|
|
381
|
+
get #isDiff() {
|
|
382
|
+
return this.#fileInstance?.type === "file-diff";
|
|
220
383
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (textDocument === void 0) throw new Error("Text document is not initialized");
|
|
224
|
-
if (markers.length === 0) {
|
|
225
|
-
this.#markerManager?.cleanup();
|
|
226
|
-
this.#markerManager = void 0;
|
|
227
|
-
this.#updateSelections(this.#selections ?? []);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
this.#markerManager ??= new MarkerManager({
|
|
231
|
-
getLineHeight: () => this.#metrics.lineHeight,
|
|
232
|
-
getFileContainer: () => this.#fileContainer,
|
|
233
|
-
getCharX: (line, character) => this.#getCharX(line, character),
|
|
234
|
-
getLineY: (line) => this.#getLineY(line),
|
|
235
|
-
isMouseDown: () => this.#isContentMouseDown || this.#isGutterMouseDown
|
|
236
|
-
});
|
|
237
|
-
this.#markerManager.setMarkers(markers, textDocument);
|
|
238
|
-
if (this.#contentElement !== void 0) this.#markerManager.listenHover(this.#contentElement);
|
|
239
|
-
this.#updateSelections(this.#selections ?? []);
|
|
384
|
+
get #isWrap() {
|
|
385
|
+
return this.#fileInstance?.options.overflow === "wrap";
|
|
240
386
|
}
|
|
241
|
-
|
|
242
|
-
const preventScroll = options?.preventScroll ?? false;
|
|
243
|
-
const primarySelection = this.#selections?.at(-1);
|
|
244
|
-
if (primarySelection !== void 0) {
|
|
245
|
-
const pos = primarySelection.direction === DirectionBackward ? primarySelection.end : primarySelection.start;
|
|
246
|
-
this.#focus(pos, preventScroll);
|
|
247
|
-
} else this.#focus(void 0, preventScroll);
|
|
248
|
-
}
|
|
249
|
-
cleanUp() {
|
|
250
|
-
this.#tokenizer?.cleanUp();
|
|
251
|
-
this.#tokenizer = void 0;
|
|
252
|
-
this.#globalEventDisposes?.forEach((dispose) => dispose());
|
|
253
|
-
this.#globalEventDisposes = void 0;
|
|
254
|
-
this.#editorEventDisposes?.forEach((dispose) => dispose());
|
|
255
|
-
this.#editorEventDisposes = void 0;
|
|
256
|
-
this.#selectEventDisposes?.forEach((dispose) => dispose());
|
|
257
|
-
this.#selectEventDisposes = void 0;
|
|
258
|
-
this.#markerManager?.cleanup();
|
|
259
|
-
this.#markerManager = void 0;
|
|
260
|
-
this.#detach?.();
|
|
261
|
-
this.#detach = void 0;
|
|
262
|
-
this.#fileInstance?.setSelectedLines(null);
|
|
263
|
-
this.#fileInstance = void 0;
|
|
264
|
-
this.#fileContents = void 0;
|
|
265
|
-
this.#lineAnnotations = void 0;
|
|
266
|
-
this.#textDocument = void 0;
|
|
267
|
-
this.#renderRange = void 0;
|
|
268
|
-
this.#gutterWidthCache = void 0;
|
|
269
|
-
this.#contentWidthCache = void 0;
|
|
387
|
+
#resetCache() {
|
|
270
388
|
this.#lineYCache.clear();
|
|
271
389
|
this.#wrapLineOffsetsCache.clear();
|
|
272
390
|
this.#lastAccessedLineElement = void 0;
|
|
273
391
|
this.#lastAccessedCharX = void 0;
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
this.#
|
|
277
|
-
this.#
|
|
278
|
-
this.#
|
|
279
|
-
this.#
|
|
280
|
-
this.#spriteElement?.remove();
|
|
281
|
-
this.#spriteElement = void 0;
|
|
282
|
-
this.#fileContainer = void 0;
|
|
283
|
-
this.#gutterElement = void 0;
|
|
284
|
-
this.#contentElement?.removeAttribute("contentEditable");
|
|
285
|
-
this.#contentElement = void 0;
|
|
286
|
-
this.#overlayElement?.remove();
|
|
287
|
-
this.#overlayElement = void 0;
|
|
392
|
+
}
|
|
393
|
+
#resetState() {
|
|
394
|
+
this.#setSelectedLinesSafe(null);
|
|
395
|
+
this.#gutterWidthCache = void 0;
|
|
396
|
+
this.#contentWidthCache = void 0;
|
|
397
|
+
this.#shouldIgnoreSelectionChange = false;
|
|
288
398
|
this.#overlayElements?.forEach((el) => el.remove());
|
|
289
399
|
this.#overlayElements = void 0;
|
|
290
|
-
this.#
|
|
400
|
+
this.#selections = void 0;
|
|
401
|
+
this.#reservedSelections = void 0;
|
|
402
|
+
this.#scrollingToLine = void 0;
|
|
403
|
+
this.#markerRenderer?.cleanup();
|
|
404
|
+
this.#markerRenderer = void 0;
|
|
291
405
|
this.#searchPanel?.cleanup();
|
|
292
406
|
this.#searchPanel = void 0;
|
|
293
407
|
this.#selectionAction?.cleanup();
|
|
294
408
|
this.#selectionAction = void 0;
|
|
295
|
-
this.#resizeObserver?.disconnect();
|
|
296
|
-
this.#resizeObserver = void 0;
|
|
297
|
-
this.#shouldIgnoreSelectionChange = false;
|
|
298
|
-
this.#selectionStart = void 0;
|
|
299
|
-
this.#selections = void 0;
|
|
300
|
-
this.#reservedSelections = void 0;
|
|
301
409
|
}
|
|
302
410
|
#initialize() {
|
|
303
411
|
this.#globalStyleElement = h("style", {
|
|
@@ -319,11 +427,13 @@ var Editor = class {
|
|
|
319
427
|
this.#globalEventDisposes = [
|
|
320
428
|
addEventListener(document, "selectionchange", () => {
|
|
321
429
|
const shadowRoot = this.#fileContainer?.shadowRoot;
|
|
322
|
-
if (this.#shouldIgnoreSelectionChange || shadowRoot == null) return;
|
|
430
|
+
if (this.#shouldIgnoreSelectionChange || shadowRoot == null || !this.#contentHasFocus) return;
|
|
323
431
|
if (this.#selections !== void 0 && this.#selections.length > 1 && !this.#isContentMouseDown) return;
|
|
324
|
-
const
|
|
432
|
+
const selectionRaw = document.getSelection();
|
|
433
|
+
if (selectionRaw == null || typeof selectionRaw.getComposedRanges !== "function") return;
|
|
434
|
+
const composedRange = selectionRaw.getComposedRanges({ shadowRoots: [shadowRoot] })?.[0];
|
|
325
435
|
if (composedRange === void 0 || !this.#rangeBelongsToEditor(composedRange)) return;
|
|
326
|
-
let selection = convertSelection(composedRange,
|
|
436
|
+
let selection = convertSelection(composedRange, 0);
|
|
327
437
|
if (selection === void 0) return;
|
|
328
438
|
if (this.#isContentMouseDown && this.#shiftKeyPressed && this.#selections !== void 0 && this.#selections.length > 0) {
|
|
329
439
|
const primarySelection = this.#selections.at(-1);
|
|
@@ -349,9 +459,7 @@ var Editor = class {
|
|
|
349
459
|
this.#shiftKeyPressed = false;
|
|
350
460
|
this.#selectionStart = void 0;
|
|
351
461
|
this.#reservedSelections = void 0;
|
|
352
|
-
this.#
|
|
353
|
-
if (key.startsWith("selectionActionIcon-")) el.dataset.visible = "true";
|
|
354
|
-
});
|
|
462
|
+
if (this.#options.enabledSelectionAction === true && this.#selections !== void 0 && this.#selections.length > 0 && !isCollapsedSelection(this.#selections.at(-1))) this.#updateSelections(this.#selections);
|
|
355
463
|
}, { passive: true }),
|
|
356
464
|
addEventListener(document, "keydown", (e) => {
|
|
357
465
|
if (e.key === "Shift") this.#selectionStart = this.#selections?.at(-1);
|
|
@@ -361,6 +469,10 @@ var Editor = class {
|
|
|
361
469
|
}, { passive: true })
|
|
362
470
|
];
|
|
363
471
|
}
|
|
472
|
+
#replaceSelectEventListeners(disposes) {
|
|
473
|
+
this.#selectEventDisposes?.forEach((dispose) => dispose());
|
|
474
|
+
this.#selectEventDisposes = disposes;
|
|
475
|
+
}
|
|
364
476
|
#listenContentElement(contentEl, gutterEl) {
|
|
365
477
|
const targetIsContentElement = (e) => {
|
|
366
478
|
const target = e.composedPath()[0];
|
|
@@ -368,25 +480,41 @@ var Editor = class {
|
|
|
368
480
|
};
|
|
369
481
|
this.#editorEventDisposes?.forEach((dispose) => dispose());
|
|
370
482
|
this.#editorEventDisposes = [
|
|
483
|
+
addEventListener(contentEl, "focus", () => {
|
|
484
|
+
this.#contentHasFocus = true;
|
|
485
|
+
if (!this.#isContentMouseDown && !this.#shouldIgnoreSelectionChange && this.#selections !== void 0 && this.#selections.length > 0) this.#setWindowSelection(this.#selections.at(-1));
|
|
486
|
+
}, { passive: true }),
|
|
487
|
+
addEventListener(contentEl, "blur", () => {
|
|
488
|
+
this.#contentHasFocus = false;
|
|
489
|
+
}, { passive: true }),
|
|
371
490
|
addEventListener(contentEl, "pointerdown", (e) => {
|
|
372
491
|
if (e.pointerType !== "mouse") return;
|
|
373
|
-
this.#
|
|
374
|
-
|
|
375
|
-
this.#
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
492
|
+
if (this.#isDeletedLineTarget(e)) {
|
|
493
|
+
this.#setDeletedTextSelectionActive(true);
|
|
494
|
+
if (this.#selections !== void 0) this.#updateSelections([]);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
this.#setDeletedTextSelectionActive(false);
|
|
498
|
+
this.#markerRenderer?.removePopup();
|
|
499
|
+
if (isSafari() && this.#lineAnnotations !== void 0 && this.#lineAnnotations.length > 0) {
|
|
500
|
+
const annotationDisposes = [...contentEl.querySelectorAll("[data-line-annotation]")].map((el) => [addEventListener(el, "mouseenter", () => {
|
|
501
|
+
this.#shouldIgnoreSelectionChange = true;
|
|
502
|
+
}), addEventListener(el, "mouseleave", () => {
|
|
503
|
+
this.#shouldIgnoreSelectionChange = false;
|
|
504
|
+
})]).flat();
|
|
505
|
+
this.#replaceSelectEventListeners(annotationDisposes);
|
|
506
|
+
}
|
|
379
507
|
this.#isContentMouseDown = true;
|
|
380
508
|
this.#selectionStart = void 0;
|
|
381
509
|
if (e.button === 0 && isPrimaryModifier(e)) this.#reservedSelections = this.#selections?.map((selection) => ({ ...selection }));
|
|
382
510
|
if (e.shiftKey) {
|
|
383
511
|
const primarySelection = this.#selections?.at(-1);
|
|
384
512
|
if (primarySelection !== void 0) {
|
|
385
|
-
const pos = primarySelection.direction ===
|
|
513
|
+
const pos = primarySelection.direction === -1 ? primarySelection.end : primarySelection.start;
|
|
386
514
|
this.#setWindowSelection({
|
|
387
515
|
start: pos,
|
|
388
516
|
end: pos,
|
|
389
|
-
direction:
|
|
517
|
+
direction: 0
|
|
390
518
|
});
|
|
391
519
|
}
|
|
392
520
|
this.#shiftKeyPressed = true;
|
|
@@ -407,7 +535,7 @@ var Editor = class {
|
|
|
407
535
|
this.#updateSelections([{
|
|
408
536
|
start: pos,
|
|
409
537
|
end: pos,
|
|
410
|
-
direction:
|
|
538
|
+
direction: 0
|
|
411
539
|
}]);
|
|
412
540
|
this.#focus(pos);
|
|
413
541
|
}
|
|
@@ -424,6 +552,19 @@ var Editor = class {
|
|
|
424
552
|
e.preventDefault();
|
|
425
553
|
return;
|
|
426
554
|
}
|
|
555
|
+
if (e.key === "v" && isPrimaryModifier(e) && this.#options.clipboard !== void 0) {
|
|
556
|
+
e.preventDefault();
|
|
557
|
+
queueRender(this.#handleCustomPasteEvent);
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
if (this.#searchPanel !== void 0) {
|
|
561
|
+
const findAgain = resolveFindAgainShortcut(e);
|
|
562
|
+
if (findAgain !== void 0) {
|
|
563
|
+
e.preventDefault();
|
|
564
|
+
this.#searchPanel.navigate(findAgain === "previous");
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
427
568
|
const command = resolveEditorCommandFromKeyboardEvent(e);
|
|
428
569
|
if (command !== void 0) {
|
|
429
570
|
e.preventDefault();
|
|
@@ -433,22 +574,23 @@ var Editor = class {
|
|
|
433
574
|
addEventListener(contentEl, "copy", (e) => {
|
|
434
575
|
if (!targetIsContentElement(e)) return;
|
|
435
576
|
e.preventDefault();
|
|
436
|
-
e.clipboardData?.setData("text", this.#getSelectionText());
|
|
577
|
+
e.clipboardData?.setData("text", this.#isDeletedTextSelectionActive() ? this.#deletedTextForClipboard() : this.#getSelectionText());
|
|
437
578
|
}),
|
|
438
579
|
addEventListener(contentEl, "cut", (e) => {
|
|
439
580
|
if (!targetIsContentElement(e)) return;
|
|
440
581
|
e.preventDefault();
|
|
441
|
-
e.clipboardData?.setData("text", this.#
|
|
442
|
-
this.#replaceSelectionText("");
|
|
582
|
+
e.clipboardData?.setData("text", this.#isDeletedTextSelectionActive() ? this.#deletedTextForClipboard() : this.#cutSelectionText());
|
|
443
583
|
}),
|
|
444
584
|
addEventListener(contentEl, "paste", (e) => {
|
|
445
585
|
if (!targetIsContentElement(e)) return;
|
|
446
586
|
e.preventDefault();
|
|
447
587
|
const text = e.clipboardData?.getData("text");
|
|
448
|
-
|
|
588
|
+
const textDocument = this.#textDocument;
|
|
589
|
+
if (text !== void 0 && textDocument !== void 0) this.#replaceSelectionText(textDocument.normalizeEol(text), void 0, true);
|
|
449
590
|
}),
|
|
450
591
|
addEventListener(contentEl, "beforeinput", (e) => {
|
|
451
592
|
if (!targetIsContentElement(e)) return;
|
|
593
|
+
if (e.inputType === "insertCompositionText") return;
|
|
452
594
|
e.preventDefault();
|
|
453
595
|
this.#handleInput(e.inputType, e.data);
|
|
454
596
|
}),
|
|
@@ -458,14 +600,25 @@ var Editor = class {
|
|
|
458
600
|
}),
|
|
459
601
|
addEventListener(contentEl, "compositionstart", (e) => {
|
|
460
602
|
if (!targetIsContentElement(e)) return;
|
|
603
|
+
this.#isComposing = true;
|
|
461
604
|
this.#shouldIgnoreSelectionChange = true;
|
|
462
605
|
}, { passive: true }),
|
|
463
606
|
addEventListener(contentEl, "compositionend", (e) => {
|
|
464
607
|
if (!targetIsContentElement(e)) return;
|
|
465
608
|
this.#shouldIgnoreSelectionChange = false;
|
|
466
|
-
this.#
|
|
609
|
+
const wasComposing = this.#isComposing;
|
|
610
|
+
this.#isComposing = false;
|
|
611
|
+
if (e.data !== "" || !wasComposing) this.#handleInput("insertText", e.data);
|
|
467
612
|
}, { passive: true })
|
|
468
613
|
];
|
|
614
|
+
const deletionsCode = this.#fileContainer?.shadowRoot?.querySelector("[data-deletions]");
|
|
615
|
+
if (deletionsCode != null) this.#editorEventDisposes.push(addEventListener(deletionsCode, "pointerdown", (e) => {
|
|
616
|
+
const target = e.composedPath()[0];
|
|
617
|
+
const gutterRow = target instanceof HTMLElement ? target.closest("[data-column-number]") : null;
|
|
618
|
+
if (gutterRow instanceof HTMLElement && this.#beginDeletionGutterSelection(gutterRow, deletionsCode, e.pointerType === "mouse")) return;
|
|
619
|
+
this.#setDeletedTextSelectionActive(true);
|
|
620
|
+
if (this.#selections !== void 0) this.#updateSelections([]);
|
|
621
|
+
}, { passive: true }));
|
|
469
622
|
if (gutterEl !== void 0) {
|
|
470
623
|
const resolveGutterTarget = (eventTarget, includeContentLine = false) => {
|
|
471
624
|
let target = eventTarget;
|
|
@@ -481,62 +634,71 @@ var Editor = class {
|
|
|
481
634
|
return lineNumber - 1;
|
|
482
635
|
};
|
|
483
636
|
this.#editorEventDisposes.push(addEventListener(gutterEl, "pointerdown", (e) => {
|
|
637
|
+
const gutterRow = resolveGutterTarget(e.composedPath()[0]);
|
|
638
|
+
if (gutterRow?.dataset.lineType === "change-deletion") {
|
|
639
|
+
const code = gutterRow.closest("[data-code]");
|
|
640
|
+
if (code != null) this.#beginDeletionGutterSelection(gutterRow, code, e.pointerType === "mouse");
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
if (e.pointerType !== "mouse") return;
|
|
484
644
|
const textDocument = this.#textDocument;
|
|
485
|
-
const lineIndex = resolveEditableLine(
|
|
645
|
+
const lineIndex = resolveEditableLine(gutterRow);
|
|
486
646
|
if (lineIndex === void 0 || textDocument === void 0) return;
|
|
487
|
-
this.#
|
|
488
|
-
const selection =
|
|
489
|
-
start: {
|
|
490
|
-
line: lineIndex,
|
|
491
|
-
character: 0
|
|
492
|
-
},
|
|
493
|
-
end: {
|
|
494
|
-
line: lineIndex,
|
|
495
|
-
character: textDocument.getLineText(lineIndex).length
|
|
496
|
-
},
|
|
497
|
-
direction: DirectionForward
|
|
498
|
-
};
|
|
647
|
+
this.#markerRenderer?.removePopup();
|
|
648
|
+
const selection = this.#spanLineSelection(lineIndex, lineIndex, textDocument);
|
|
499
649
|
this.#isGutterMouseDown = true;
|
|
500
650
|
this.#selectionStart = selection;
|
|
501
651
|
this.#updateSelections([selection]);
|
|
502
|
-
this.#
|
|
503
|
-
this.#
|
|
652
|
+
this.#setWindowSelection(selection);
|
|
653
|
+
this.#focus();
|
|
654
|
+
this.#replaceSelectEventListeners([addEventListener(document, "mousemove", (e) => {
|
|
504
655
|
if (!this.#isGutterMouseDown) return;
|
|
505
|
-
const textDocument
|
|
506
|
-
const lineIndex
|
|
507
|
-
if (lineIndex
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
line: lineIndex$1,
|
|
515
|
-
character: textDocument$1.getLineText(lineIndex$1).length
|
|
516
|
-
},
|
|
517
|
-
direction: DirectionForward
|
|
518
|
-
};
|
|
519
|
-
if (this.#selectionStart !== void 0) selection$1 = createSelectionFrom(this.#selectionStart, selection$1);
|
|
520
|
-
else this.#selectionStart = selection$1;
|
|
521
|
-
this.#updateSelections([selection$1]);
|
|
522
|
-
this.#focus(selection$1.end);
|
|
523
|
-
}, { passive: true })];
|
|
656
|
+
const textDocument = this.#textDocument;
|
|
657
|
+
const lineIndex = resolveEditableLine(resolveGutterTarget(e.composedPath()[0], true));
|
|
658
|
+
if (lineIndex === void 0 || textDocument === void 0) return;
|
|
659
|
+
const anchorLine = this.#selectionStart?.start.line ?? lineIndex;
|
|
660
|
+
const selection = this.#spanLineSelection(anchorLine, lineIndex, textDocument);
|
|
661
|
+
this.#selectionStart ??= selection;
|
|
662
|
+
this.#updateSelections([selection]);
|
|
663
|
+
this.#focus(selection.direction === -1 ? selection.start : selection.end);
|
|
664
|
+
}, { passive: true })]);
|
|
524
665
|
}, { passive: true }));
|
|
525
666
|
}
|
|
526
|
-
this.#
|
|
667
|
+
this.#markerRenderer?.listenHover(contentEl);
|
|
527
668
|
this.#resizeObserver?.disconnect();
|
|
528
|
-
this.#resizeObserver = new ResizeObserver(
|
|
529
|
-
this.#handleLayoutResize();
|
|
530
|
-
});
|
|
669
|
+
this.#resizeObserver = new ResizeObserver(this.#handleLayoutResize);
|
|
531
670
|
this.#resizeObserver.observe(contentEl);
|
|
532
671
|
this.#resizeObserver.observe(contentEl.parentElement);
|
|
672
|
+
this.#computeContentOffset(contentEl);
|
|
673
|
+
}
|
|
674
|
+
#handleCustomPasteEvent = async () => {
|
|
675
|
+
const clipboard = this.#options.clipboard;
|
|
676
|
+
if (clipboard !== void 0) {
|
|
677
|
+
const text = await clipboard.readText();
|
|
678
|
+
this.#replaceSelectionText(text, void 0, true);
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
#computeContentOffset(contentEl) {
|
|
682
|
+
if (this.#isDiff && this.#diffSyle === "split" && this.#isWrap) {
|
|
683
|
+
this.#contentOffset = {
|
|
684
|
+
top: contentEl.offsetTop,
|
|
685
|
+
left: contentEl.offsetLeft - this.#getGutterWidth()
|
|
686
|
+
};
|
|
687
|
+
if (this.#options.__debug === true) console.log("[diffs/editor] content offset:", this.#contentOffset);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
get #activeContentOffset() {
|
|
691
|
+
if (this.#isDiff && this.#diffSyle === "split" && this.#isWrap) return this.#contentOffset;
|
|
533
692
|
}
|
|
534
693
|
#runCommand(command) {
|
|
535
694
|
const textDocument = this.#textDocument;
|
|
536
695
|
if (textDocument === void 0) return;
|
|
537
696
|
switch (command) {
|
|
538
697
|
case "openSearchPanel":
|
|
539
|
-
this.#
|
|
698
|
+
this.#openSearchPanel("find");
|
|
699
|
+
break;
|
|
700
|
+
case "openSearchReplacePanel":
|
|
701
|
+
this.#openSearchPanel("replace");
|
|
540
702
|
break;
|
|
541
703
|
case "findNextMatch": {
|
|
542
704
|
const selections = this.#selections;
|
|
@@ -562,6 +724,7 @@ var Editor = class {
|
|
|
562
724
|
if (this.#selections !== void 0) {
|
|
563
725
|
const edits = [];
|
|
564
726
|
const nextSelections = [];
|
|
727
|
+
const sameLineIndents = [];
|
|
565
728
|
for (const selection of this.#selections) {
|
|
566
729
|
const startLine = selection.start.line;
|
|
567
730
|
const outdent = command === "outdent";
|
|
@@ -570,11 +733,45 @@ var Editor = class {
|
|
|
570
733
|
edits.push(...ret[0]);
|
|
571
734
|
nextSelections.push(ret[1]);
|
|
572
735
|
} else {
|
|
573
|
-
const
|
|
736
|
+
const text = textDocument.charAt({
|
|
574
737
|
line: startLine,
|
|
575
738
|
character: 0
|
|
739
|
+
}) === " " ? " " : " ".repeat(this.#metrics.tabSize);
|
|
740
|
+
edits.push({
|
|
741
|
+
range: selection,
|
|
742
|
+
newText: text
|
|
743
|
+
});
|
|
744
|
+
sameLineIndents.push({
|
|
745
|
+
line: startLine,
|
|
746
|
+
startCharacter: selection.start.character,
|
|
747
|
+
addedLength: text.length - (selection.end.character - selection.start.character),
|
|
748
|
+
selectionIndex: nextSelections.length
|
|
576
749
|
});
|
|
577
|
-
|
|
750
|
+
const nextPosition = {
|
|
751
|
+
line: selection.start.line,
|
|
752
|
+
character: selection.start.character + text.length
|
|
753
|
+
};
|
|
754
|
+
nextSelections.push({
|
|
755
|
+
start: nextPosition,
|
|
756
|
+
end: nextPosition,
|
|
757
|
+
direction: 0
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
for (const indent of sameLineIndents) {
|
|
762
|
+
let shift = 0;
|
|
763
|
+
for (const other of sameLineIndents) if (other.line === indent.line && other.startCharacter < indent.startCharacter) shift += other.addedLength;
|
|
764
|
+
if (shift !== 0) {
|
|
765
|
+
const current = nextSelections[indent.selectionIndex];
|
|
766
|
+
const position = {
|
|
767
|
+
line: indent.line,
|
|
768
|
+
character: current.start.character + shift
|
|
769
|
+
};
|
|
770
|
+
nextSelections[indent.selectionIndex] = {
|
|
771
|
+
start: position,
|
|
772
|
+
end: position,
|
|
773
|
+
direction: 0
|
|
774
|
+
};
|
|
578
775
|
}
|
|
579
776
|
}
|
|
580
777
|
const change = textDocument.applyEdits(edits, true, this.#selections, nextSelections);
|
|
@@ -618,7 +815,7 @@ var Editor = class {
|
|
|
618
815
|
break;
|
|
619
816
|
}
|
|
620
817
|
}
|
|
621
|
-
#handleLayoutResize() {
|
|
818
|
+
#handleLayoutResize = () => {
|
|
622
819
|
const lineAnnotations = this.#lineAnnotations?.length ?? 0;
|
|
623
820
|
const prevGutterWidth = this.#gutterWidthCache;
|
|
624
821
|
const prevContentWidth = this.#contentWidthCache;
|
|
@@ -629,24 +826,39 @@ var Editor = class {
|
|
|
629
826
|
if (!gutterWidthChanged && !contentWidthChanged) return;
|
|
630
827
|
this.#lastAccessedLineElement = void 0;
|
|
631
828
|
this.#lastAccessedCharX = void 0;
|
|
632
|
-
|
|
829
|
+
this.#metrics.clearTextWidthCache();
|
|
830
|
+
if (contentWidthChanged && (this.#isWrap || lineAnnotations > 0)) {
|
|
633
831
|
this.#lineYCache.clear();
|
|
634
832
|
this.#wrapLineOffsetsCache.clear();
|
|
635
833
|
}
|
|
636
|
-
if (this.#selections !== void 0 || this.#matches !== void 0 || this.#
|
|
834
|
+
if (this.#selections !== void 0 || this.#matches !== void 0 || this.#markerRenderer !== void 0) {
|
|
637
835
|
this.#updateSelections(this.#selections ?? []);
|
|
638
836
|
if (this.#selections !== void 0) this.focus();
|
|
639
837
|
}
|
|
640
|
-
this.#
|
|
838
|
+
this.#markerRenderer?.removePopup();
|
|
839
|
+
this.#computeContentOffset(this.#contentElement);
|
|
840
|
+
};
|
|
841
|
+
#remeasureMetricsOnFontLoad() {
|
|
842
|
+
if (this.#fontRemeasureScheduled) return;
|
|
843
|
+
const fonts = document.fonts;
|
|
844
|
+
if (fonts === void 0) return;
|
|
845
|
+
this.#fontRemeasureScheduled = true;
|
|
846
|
+
fonts.ready.then(() => {
|
|
847
|
+
if (this.#contentElement === void 0 || !this.#metrics.remeasureCharacterWidth()) return;
|
|
848
|
+
this.#gutterWidthCache = void 0;
|
|
849
|
+
this.#contentWidthCache = void 0;
|
|
850
|
+
this.#resetCache();
|
|
851
|
+
if (this.#selections !== void 0 || this.#matches !== void 0 || this.#markerRenderer !== void 0) this.#updateSelections(this.#selections ?? []);
|
|
852
|
+
this.#markerRenderer?.removePopup();
|
|
853
|
+
});
|
|
641
854
|
}
|
|
642
855
|
#rerender(change, newLineAnnotations, renderRange = this.#renderRange, shouldUpdateBuffer) {
|
|
643
856
|
const tokenizer = this.#tokenizer;
|
|
644
857
|
const fileInstance = this.#fileInstance;
|
|
645
|
-
const fileContents = this.#fileContents;
|
|
646
858
|
const textDocument = this.#textDocument;
|
|
647
859
|
const gutterEl = this.#gutterElement;
|
|
648
860
|
const contentEl = this.#contentElement;
|
|
649
|
-
if (tokenizer === void 0 || fileInstance === void 0 ||
|
|
861
|
+
if (tokenizer === void 0 || fileInstance === void 0 || textDocument === void 0 || contentEl === void 0) return;
|
|
650
862
|
tokenizer.stopBackgroundTokenize();
|
|
651
863
|
const t = performance.now();
|
|
652
864
|
const dirtyLines = tokenizer.tokenize(change, renderRange);
|
|
@@ -659,14 +871,14 @@ var Editor = class {
|
|
|
659
871
|
const child = children[i];
|
|
660
872
|
if (child !== void 0) {
|
|
661
873
|
const lineNumber = getLineNumberAttr(child);
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
874
|
+
const lineType = child.dataset.lineType;
|
|
875
|
+
if (lineNumber === void 0 || lineType === "change-deletion") continue;
|
|
876
|
+
const lineIndex = lineNumber - 1;
|
|
877
|
+
if (dirtyLines.has(lineIndex)) {
|
|
878
|
+
const tokens = dirtyLines.get(lineIndex);
|
|
879
|
+
child.replaceChildren(...renderLineTokens(tokens, tokenizer.themeType));
|
|
880
|
+
dirtyLineIndexes.delete(lineIndex);
|
|
881
|
+
if (dirtyLineIndexes.size === 0) break;
|
|
670
882
|
}
|
|
671
883
|
}
|
|
672
884
|
}
|
|
@@ -697,11 +909,11 @@ var Editor = class {
|
|
|
697
909
|
if (change.lineDelta < 0) for (const children of [contentEl.children, gutterEl?.children ?? []]) for (let i = children.length - 1; i >= 0; i--) {
|
|
698
910
|
const child = children[i];
|
|
699
911
|
const lineNumber = getLineNumberAttr(child) ?? getLineNumberAttr(child, "columnNumber");
|
|
700
|
-
|
|
912
|
+
const lineType = child.dataset.lineType;
|
|
913
|
+
if (lineNumber === void 0 || lineType === "change-deletion") continue;
|
|
701
914
|
if (lineNumber - 1 < change.lineCount) break;
|
|
702
915
|
child.remove();
|
|
703
916
|
}
|
|
704
|
-
const isDiff = Object.hasOwn(fileInstance, "fileDiff");
|
|
705
917
|
const didLineCountChange = change.lineDelta !== 0;
|
|
706
918
|
if (didLineCountChange) {
|
|
707
919
|
let gridRow = contentEl.children.length;
|
|
@@ -712,7 +924,7 @@ var Editor = class {
|
|
|
712
924
|
contentEl.style.gridRow = "span " + gridRow;
|
|
713
925
|
if (gutterEl !== void 0) gutterEl.style.gridRow = "span " + gridRow;
|
|
714
926
|
}
|
|
715
|
-
fileInstance.updateRenderCache(dirtyLines, tokenizer.themeType, isDiff
|
|
927
|
+
fileInstance.updateRenderCache(dirtyLines, tokenizer.themeType, this.#isDiff && !didLineCountChange, didLineCountChange);
|
|
716
928
|
if (didLineCountChange) fileInstance.applyDocumentChange(textDocument, newLineAnnotations, shouldUpdateBuffer);
|
|
717
929
|
if (newLineAnnotations !== void 0) {
|
|
718
930
|
this.#lineAnnotations = newLineAnnotations;
|
|
@@ -720,11 +932,31 @@ var Editor = class {
|
|
|
720
932
|
}
|
|
721
933
|
if (this.#options.__debug === true) console.log(`[diffs/editor] re-render in: ${round(performance.now() - t2)}ms,`, `tokenize in: ${round(t2 - t)}ms (${dirtyLines.size} dirty lines)`);
|
|
722
934
|
}
|
|
935
|
+
#shouldRenderDivergeFromDocument(textDocument) {
|
|
936
|
+
const contentEl = this.#contentElement;
|
|
937
|
+
if (contentEl === void 0) return false;
|
|
938
|
+
for (const child of contentEl.children) {
|
|
939
|
+
const el = child;
|
|
940
|
+
const lineType = el.dataset.lineType;
|
|
941
|
+
const lineNumber = getLineNumberAttr(el);
|
|
942
|
+
if (lineNumber === void 0 || lineType === void 0 || !isLineEditable(lineType)) continue;
|
|
943
|
+
const lineIndex = lineNumber - 1;
|
|
944
|
+
if (lineIndex >= textDocument.lineCount || el.textContent !== textDocument.getLineText(lineIndex)) return true;
|
|
945
|
+
}
|
|
946
|
+
return false;
|
|
947
|
+
}
|
|
723
948
|
#handleInput(inputType, data) {
|
|
724
949
|
switch (inputType) {
|
|
725
|
-
case "insertText":
|
|
726
|
-
|
|
950
|
+
case "insertText": {
|
|
951
|
+
const text = data ?? "";
|
|
952
|
+
const textDocument = this.#textDocument;
|
|
953
|
+
const selections = this.#selections;
|
|
954
|
+
const autoSurroundTexts = textDocument !== void 0 && selections !== void 0 ? getAutoSurroundReplacementTexts(textDocument, selections, text, this.#options.autoSurround) : void 0;
|
|
955
|
+
this.#replaceSelectionText(autoSurroundTexts ?? text);
|
|
727
956
|
break;
|
|
957
|
+
}
|
|
958
|
+
case "insertCompositionText": break;
|
|
959
|
+
case "insertLineBreak":
|
|
728
960
|
case "insertParagraph":
|
|
729
961
|
this.#replaceSelectionText("\n");
|
|
730
962
|
break;
|
|
@@ -752,12 +984,13 @@ var Editor = class {
|
|
|
752
984
|
}
|
|
753
985
|
}
|
|
754
986
|
#focus(position, preventScroll = true) {
|
|
987
|
+
this.#contentHasFocus = true;
|
|
755
988
|
if (position !== void 0) {
|
|
756
989
|
this.#shouldIgnoreSelectionChange = true;
|
|
757
990
|
this.#setWindowSelection({
|
|
758
991
|
start: position,
|
|
759
992
|
end: position,
|
|
760
|
-
direction:
|
|
993
|
+
direction: 0
|
|
761
994
|
});
|
|
762
995
|
requestAnimationFrame(() => {
|
|
763
996
|
this.#contentElement?.focus({ preventScroll });
|
|
@@ -777,7 +1010,7 @@ var Editor = class {
|
|
|
777
1010
|
if (startLineElement === void 0 || endLineElement === void 0) return;
|
|
778
1011
|
let [anchorNode, anchorOffset] = getSelectionAnchor(startLineElement, start.character);
|
|
779
1012
|
let [focusNode, focusOffset] = getSelectionAnchor(endLineElement, end.character);
|
|
780
|
-
if (direction ===
|
|
1013
|
+
if (direction === -1) [anchorNode, anchorOffset, focusNode, focusOffset] = [
|
|
781
1014
|
focusNode,
|
|
782
1015
|
focusOffset,
|
|
783
1016
|
anchorNode,
|
|
@@ -789,16 +1022,16 @@ var Editor = class {
|
|
|
789
1022
|
console.error("[diffs/editor] failed to update window selection:", err);
|
|
790
1023
|
}
|
|
791
1024
|
}
|
|
792
|
-
#scrollToPrimaryCaret(noFocus = false) {
|
|
793
|
-
const primaryCaretElement = this.#primaryCaretElement;
|
|
1025
|
+
#scrollToPrimaryCaret(noFocus = false, scrollPosition = "nearest") {
|
|
794
1026
|
const primarySelection = this.#selections?.at(-1);
|
|
795
1027
|
if (primarySelection === void 0) return;
|
|
1028
|
+
const primaryCaretElement = this.#primaryCaretElement;
|
|
796
1029
|
if (primaryCaretElement !== void 0) {
|
|
797
1030
|
primaryCaretElement.scrollIntoView({
|
|
798
|
-
block:
|
|
1031
|
+
block: scrollPosition,
|
|
799
1032
|
inline: "nearest"
|
|
800
1033
|
});
|
|
801
|
-
if (!noFocus) this.#focus(primarySelection.direction ===
|
|
1034
|
+
if (!noFocus) this.#focus(primarySelection.direction === -1 ? primarySelection.end : primarySelection.start);
|
|
802
1035
|
} else {
|
|
803
1036
|
const pos = getCaretPosition(primarySelection);
|
|
804
1037
|
this.#scrollToLine(pos.line, pos.character, noFocus);
|
|
@@ -812,7 +1045,7 @@ var Editor = class {
|
|
|
812
1045
|
return `${componentTop + top}px ${end}px 0 ${start}px`;
|
|
813
1046
|
}
|
|
814
1047
|
#scrollToLine(line, char = 0, noFocus = false) {
|
|
815
|
-
this.
|
|
1048
|
+
this.__postponeBackgroundTokenizeToNextFrame();
|
|
816
1049
|
const virtualCaret = h("div", { style: {
|
|
817
1050
|
position: "absolute",
|
|
818
1051
|
left: "0",
|
|
@@ -867,15 +1100,109 @@ var Editor = class {
|
|
|
867
1100
|
}
|
|
868
1101
|
virtualCaret.remove();
|
|
869
1102
|
}
|
|
1103
|
+
#spanLineSelection(anchorLine, focusLine, textDocument) {
|
|
1104
|
+
const lineStart = (line) => ({
|
|
1105
|
+
line,
|
|
1106
|
+
character: 0
|
|
1107
|
+
});
|
|
1108
|
+
const lineEnd = (line) => ({
|
|
1109
|
+
line,
|
|
1110
|
+
character: textDocument.getLineText(line).length
|
|
1111
|
+
});
|
|
1112
|
+
if (focusLine < anchorLine) return {
|
|
1113
|
+
start: lineStart(focusLine),
|
|
1114
|
+
end: lineEnd(anchorLine),
|
|
1115
|
+
direction: -1
|
|
1116
|
+
};
|
|
1117
|
+
return {
|
|
1118
|
+
start: lineStart(anchorLine),
|
|
1119
|
+
end: lineEnd(focusLine),
|
|
1120
|
+
direction: 1
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
#isDeletedLineTarget(event) {
|
|
1124
|
+
const target = event.composedPath()[0];
|
|
1125
|
+
return target instanceof HTMLElement && target.closest("[data-line]")?.getAttribute("data-line-type") === "change-deletion";
|
|
1126
|
+
}
|
|
1127
|
+
#selectDeletedLines(anchorContent, focusContent, deletionsCode) {
|
|
1128
|
+
const rows = [...deletionsCode.querySelectorAll("[data-content] > [data-line]")];
|
|
1129
|
+
const anchorIndex = rows.indexOf(anchorContent);
|
|
1130
|
+
const focusIndex = rows.indexOf(focusContent);
|
|
1131
|
+
const [topContent, bottomContent] = focusIndex < anchorIndex ? [focusContent, anchorContent] : [anchorContent, focusContent];
|
|
1132
|
+
const winSelection = window.getSelection();
|
|
1133
|
+
if (winSelection !== null) {
|
|
1134
|
+
const range = document.createRange();
|
|
1135
|
+
range.setStart(topContent, 0);
|
|
1136
|
+
range.setEnd(bottomContent, bottomContent.childNodes.length);
|
|
1137
|
+
winSelection.removeAllRanges();
|
|
1138
|
+
winSelection.addRange(range);
|
|
1139
|
+
}
|
|
1140
|
+
this.#setDeletedTextSelectionActive(true);
|
|
1141
|
+
this.#updateSelections([]);
|
|
1142
|
+
[...deletionsCode.querySelectorAll("[data-gutter] > [data-column-number]")][focusIndex]?.setAttribute("data-selected-line", "single");
|
|
1143
|
+
const lo = Math.min(anchorIndex, focusIndex);
|
|
1144
|
+
const hi = Math.max(anchorIndex, focusIndex);
|
|
1145
|
+
this.#deletedSelectionText = lo < 0 ? "" : rows.slice(lo, hi + 1).filter((row) => row.getAttribute("data-line-type") === "change-deletion").map((row) => row.textContent ?? "").join("\n");
|
|
1146
|
+
}
|
|
1147
|
+
#contentRowForGutterRow(gutterRow, contentColumn) {
|
|
1148
|
+
const gutterColumn = gutterRow.parentElement;
|
|
1149
|
+
if (gutterColumn == null || contentColumn == null) return;
|
|
1150
|
+
const index = [...gutterColumn.children].indexOf(gutterRow);
|
|
1151
|
+
const row = contentColumn.children[index];
|
|
1152
|
+
return row instanceof HTMLElement ? row : void 0;
|
|
1153
|
+
}
|
|
1154
|
+
#beginDeletionGutterSelection(gutterRow, code, isMouse) {
|
|
1155
|
+
const contentColumn = code.querySelector("[data-content]");
|
|
1156
|
+
const anchorContent = this.#contentRowForGutterRow(gutterRow, contentColumn);
|
|
1157
|
+
if (anchorContent === void 0) return false;
|
|
1158
|
+
this.#selectDeletedLines(anchorContent, anchorContent, code);
|
|
1159
|
+
if (isMouse) this.#replaceSelectEventListeners([addEventListener(document, "mousemove", (moveEvent) => {
|
|
1160
|
+
const moveTarget = moveEvent.composedPath()[0];
|
|
1161
|
+
const moveGutter = moveTarget instanceof HTMLElement ? moveTarget.closest("[data-column-number]") : null;
|
|
1162
|
+
if (moveGutter instanceof HTMLElement && code.contains(moveGutter)) {
|
|
1163
|
+
const focusContent = this.#contentRowForGutterRow(moveGutter, contentColumn);
|
|
1164
|
+
if (focusContent !== void 0) this.#selectDeletedLines(anchorContent, focusContent, code);
|
|
1165
|
+
}
|
|
1166
|
+
}, { passive: true })]);
|
|
1167
|
+
return true;
|
|
1168
|
+
}
|
|
1169
|
+
#isDeletedTextSelectionActive() {
|
|
1170
|
+
return this.#fileContainer?.shadowRoot?.querySelector("pre")?.hasAttribute("data-deleted-text-selection") ?? false;
|
|
1171
|
+
}
|
|
1172
|
+
#deletedTextForClipboard() {
|
|
1173
|
+
return this.#deletedSelectionText !== "" ? this.#deletedSelectionText : window.getSelection()?.toString() ?? "";
|
|
1174
|
+
}
|
|
1175
|
+
#setDeletedTextSelectionActive(active) {
|
|
1176
|
+
const pre = this.#fileContainer?.shadowRoot?.querySelector("pre");
|
|
1177
|
+
if (pre == null) return;
|
|
1178
|
+
if (active) {
|
|
1179
|
+
pre.setAttribute("data-deleted-text-selection", "");
|
|
1180
|
+
for (const highlighted of pre.querySelectorAll("[data-selected-line]")) highlighted.removeAttribute("data-selected-line");
|
|
1181
|
+
this.#deletedSelectionText = "";
|
|
1182
|
+
} else {
|
|
1183
|
+
pre.removeAttribute("data-deleted-text-selection");
|
|
1184
|
+
this.#deletedSelectionText = "";
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
#setSelectedLinesSafe(range, lineNumberOnly = false) {
|
|
1188
|
+
try {
|
|
1189
|
+
this.#fileInstance?.setSelectedLines(range, {
|
|
1190
|
+
notify: false,
|
|
1191
|
+
activeLineSide: "additions",
|
|
1192
|
+
lineNumberOnly
|
|
1193
|
+
});
|
|
1194
|
+
} catch {}
|
|
1195
|
+
}
|
|
870
1196
|
#updateSelections(selections) {
|
|
871
|
-
this.
|
|
1197
|
+
this.__postponeBackgroundTokenizeToNextFrame();
|
|
872
1198
|
this.#primaryCaretElement = void 0;
|
|
873
|
-
this.#
|
|
874
|
-
|
|
875
|
-
if (selections.length === 0 && this.#matches === void 0 && this.#markerManager === void 0) {
|
|
1199
|
+
this.#setSelectedLinesSafe(null);
|
|
1200
|
+
if (selections.length === 0 && this.#matches === void 0 && this.#markerRenderer === void 0) {
|
|
876
1201
|
this.#selections = void 0;
|
|
877
1202
|
this.#overlayElements?.forEach((el) => el.remove());
|
|
878
1203
|
this.#overlayElements?.clear();
|
|
1204
|
+
this.#selectionAction?.cleanup();
|
|
1205
|
+
this.#selectionAction = void 0;
|
|
879
1206
|
return;
|
|
880
1207
|
}
|
|
881
1208
|
const fragment = document.createDocumentFragment();
|
|
@@ -887,21 +1214,16 @@ var Editor = class {
|
|
|
887
1214
|
const normalizedSelections = mergeOverlappingSelections(selections);
|
|
888
1215
|
const primarySelection = normalizedSelections.at(-1);
|
|
889
1216
|
this.#selections = normalizedSelections;
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
} else if (this.#gutterElement !== void 0) {
|
|
897
|
-
const pos = getCaretPosition(primarySelection);
|
|
898
|
-
this.#gutterElement.querySelector(`[data-column-number="${pos.line + 1}"]`)?.setAttribute("data-active", "");
|
|
899
|
-
}
|
|
1217
|
+
const hasNonEmptySelection = normalizedSelections.some((selection) => !isCollapsedSelection(selection));
|
|
1218
|
+
const caretLine = getCaretPosition(primarySelection).line + 1;
|
|
1219
|
+
this.#setSelectedLinesSafe({
|
|
1220
|
+
start: caretLine,
|
|
1221
|
+
end: caretLine
|
|
1222
|
+
}, hasNonEmptySelection);
|
|
900
1223
|
for (const selection of normalizedSelections) {
|
|
901
1224
|
if (!isCollapsedSelection(selection)) this.#renderSelection(renderCtx, "selection", selection);
|
|
902
1225
|
this.#renderCaret(renderCtx, selection, selection === primarySelection);
|
|
903
1226
|
}
|
|
904
|
-
if (this.#options.enabledSelectionAction === true && !isCollapsedSelection(primarySelection)) this.#renderSelectionActionIcon(renderCtx, primarySelection);
|
|
905
1227
|
}
|
|
906
1228
|
const textDocument = this.#textDocument;
|
|
907
1229
|
if (this.#matches !== void 0 && textDocument !== void 0) {
|
|
@@ -917,11 +1239,12 @@ var Editor = class {
|
|
|
917
1239
|
this.#renderSelection(renderCtx, "match", range, isFocused ? "focus" : void 0);
|
|
918
1240
|
}
|
|
919
1241
|
}
|
|
920
|
-
if (this.#
|
|
1242
|
+
if (this.#markerRenderer !== void 0 && textDocument !== void 0) for (const marker of this.#markerRenderer.markers) this.#renderSelection(renderCtx, "marker", marker, markerSeverityDatasetKey(marker.severity));
|
|
921
1243
|
this.#overlayElement?.appendChild(fragment);
|
|
922
1244
|
this.#overlayElements?.forEach((el) => el.remove());
|
|
923
1245
|
this.#overlayElements?.clear();
|
|
924
1246
|
this.#overlayElements = renderCtx.elements;
|
|
1247
|
+
this.#updateSelectionActionPopover();
|
|
925
1248
|
}
|
|
926
1249
|
#renderSelection(renderCtx, type, range, extraDataset) {
|
|
927
1250
|
if (this.#textDocument === void 0) return;
|
|
@@ -932,7 +1255,7 @@ var Editor = class {
|
|
|
932
1255
|
const lineText = this.#textDocument.getLineText(line);
|
|
933
1256
|
const startChar = line === start.line ? start.character : 0;
|
|
934
1257
|
const endChar = isLastLine ? end.character : lineText.length;
|
|
935
|
-
if (this.#
|
|
1258
|
+
if (this.#isWrap) {
|
|
936
1259
|
const contentWidth = this.#getContentWidth();
|
|
937
1260
|
if (2 * this.#metrics.ch + this.#metrics.measureTextWidth(lineText) > contentWidth) {
|
|
938
1261
|
this.#renderWrappedSelection(renderCtx, line, lineText, startChar, endChar, isLastLine, type, extraDataset);
|
|
@@ -942,7 +1265,7 @@ var Editor = class {
|
|
|
942
1265
|
let left = 0;
|
|
943
1266
|
let width = 0;
|
|
944
1267
|
let paddingEnd = 0;
|
|
945
|
-
if (startChar === 0) left = this.#getGutterWidth() + this.#metrics.ch;
|
|
1268
|
+
if (startChar === 0) left = this.#getGutterWidth() + this.#metrics.ch + (this.#activeContentOffset?.left ?? 0);
|
|
946
1269
|
else left = this.#getCharX(line, startChar)[0];
|
|
947
1270
|
if (!isLastLine && type === "selection") paddingEnd = this.#metrics.ch;
|
|
948
1271
|
if (startChar === endChar) width = paddingEnd;
|
|
@@ -953,71 +1276,64 @@ var Editor = class {
|
|
|
953
1276
|
#renderWrappedSelection(renderCtx, line, lineText, startChar, endChar, isLastLine, type, extraDataset) {
|
|
954
1277
|
const wrapOffsets = this.#wrapLineText(line);
|
|
955
1278
|
const segmentCount = wrapOffsets.length - 1;
|
|
956
|
-
const offsetLeft = this.#getGutterWidth() + this.#metrics.ch;
|
|
1279
|
+
const offsetLeft = this.#getGutterWidth() + this.#metrics.ch + (this.#activeContentOffset?.left ?? 0);
|
|
957
1280
|
for (let wrapLine = 0; wrapLine < segmentCount; wrapLine++) {
|
|
958
1281
|
const segmentStart = wrapOffsets[wrapLine];
|
|
959
1282
|
const segmentEnd = wrapOffsets[wrapLine + 1];
|
|
960
1283
|
const wrapStartChar = Math.max(startChar, segmentStart);
|
|
961
1284
|
const wrapEndChar = Math.min(endChar, segmentEnd);
|
|
962
1285
|
if (wrapStartChar > wrapEndChar) continue;
|
|
963
|
-
|
|
964
|
-
|
|
1286
|
+
const segmentStartWidth = this.#segmentTextWidth(lineText, segmentStart, wrapStartChar);
|
|
1287
|
+
const segmentLeft = offsetLeft + segmentStartWidth;
|
|
965
1288
|
let paddingEnd = 0;
|
|
966
|
-
if (wrapStartChar === 0) segmentLeft = offsetLeft;
|
|
967
|
-
else {
|
|
968
|
-
const prefixInSegment = lineText.slice(segmentStart, wrapStartChar);
|
|
969
|
-
const prefixAsciiColumns = getExpandedAsciiTextColumns(prefixInSegment, this.#metrics.tabSize);
|
|
970
|
-
segmentLeft = offsetLeft + (prefixAsciiColumns !== -1 ? prefixAsciiColumns * this.#metrics.ch : this.#metrics.measureTextWidth(prefixInSegment));
|
|
971
|
-
}
|
|
972
1289
|
if (!isLastLine && wrapLine === segmentCount - 1 && type === "selection") paddingEnd = this.#metrics.ch;
|
|
973
|
-
|
|
974
|
-
else {
|
|
975
|
-
const selectionInSegment = lineText.slice(wrapStartChar, wrapEndChar);
|
|
976
|
-
const selectionAsciiWidth = getExpandedAsciiTextColumns(selectionInSegment, this.#metrics.tabSize);
|
|
977
|
-
segmentWidth = selectionAsciiWidth !== -1 ? selectionAsciiWidth * this.#metrics.ch : this.#metrics.measureTextWidth(selectionInSegment);
|
|
978
|
-
segmentWidth += paddingEnd;
|
|
979
|
-
}
|
|
1290
|
+
const segmentWidth = wrapStartChar === wrapEndChar ? paddingEnd : this.#segmentTextWidth(lineText, segmentStart, wrapEndChar) - segmentStartWidth + paddingEnd;
|
|
980
1291
|
this.#renderSelectionBlock(renderCtx, type, line, wrapLine, segmentLeft, segmentWidth, extraDataset);
|
|
981
1292
|
}
|
|
982
1293
|
}
|
|
1294
|
+
#segmentTextWidth(lineText, segmentStart, character) {
|
|
1295
|
+
if (character <= segmentStart) return 0;
|
|
1296
|
+
const segmentText = lineText.slice(segmentStart, character);
|
|
1297
|
+
const asciiColumns = getExpandedAsciiTextColumns(segmentText, this.#metrics.tabSize);
|
|
1298
|
+
return asciiColumns !== -1 ? asciiColumns * this.#metrics.ch : this.#metrics.measureTextWidth(segmentText);
|
|
1299
|
+
}
|
|
983
1300
|
#renderSelectionBlock(renderCtx, type, line, wrapLine, left, width, extraDataset) {
|
|
984
1301
|
if (width === 0) return;
|
|
985
1302
|
const { ch, lineHeight } = this.#metrics;
|
|
986
1303
|
const y = this.#getLineY(line) + wrapLine * lineHeight;
|
|
987
|
-
const
|
|
988
|
-
const cacheKey = `${type}-${left}-${y}-${width}${extraDataset ?? ""}`;
|
|
1304
|
+
const cacheKey = `${type}-${line}/${wrapLine}-${left}-${width} ${extraDataset ?? ""}`;
|
|
989
1305
|
const overlayEls = this.#overlayElements;
|
|
990
1306
|
const rounded = (this.#options.roundedSelection ?? true) && type === "selection";
|
|
991
|
-
const addRoundedCorner = (line
|
|
992
|
-
const
|
|
993
|
-
const css$1 = `width:${ch}px;transform:translateX(${left$1}px) translateY(${top}px);`;
|
|
1307
|
+
const addRoundedCorner = (line, wrapLine, left, radius) => {
|
|
1308
|
+
const css = `width:${ch}px;transform:translateX(${left}px) translateY(${this.#getLineY(line) + wrapLine * lineHeight}px);`;
|
|
994
1309
|
const dataset = {
|
|
995
1310
|
selectionCorner: "",
|
|
996
1311
|
[radius]: ""
|
|
997
1312
|
};
|
|
998
|
-
const cacheKeyPrefix = `${type}-block-${
|
|
999
|
-
let cacheKey
|
|
1313
|
+
const cacheKeyPrefix = `${type}-block-${line}/${wrapLine}-${left}-1ch`;
|
|
1314
|
+
let cacheKey = cacheKeyPrefix + "-" + radius;
|
|
1000
1315
|
if (radius === "rbl") {
|
|
1001
1316
|
const prevCornerKey = cacheKeyPrefix + "-rtl";
|
|
1002
1317
|
const prevCorner = renderCtx.elements.get(prevCornerKey);
|
|
1003
1318
|
if (prevCorner !== void 0) {
|
|
1004
1319
|
prevCorner.remove();
|
|
1005
1320
|
renderCtx.elements.delete(prevCornerKey);
|
|
1006
|
-
cacheKey
|
|
1321
|
+
cacheKey += "-rtl";
|
|
1007
1322
|
dataset.rtl = "";
|
|
1008
1323
|
}
|
|
1009
1324
|
}
|
|
1010
|
-
let cornerEl = renderCtx.elements.get(cacheKey
|
|
1325
|
+
let cornerEl = renderCtx.elements.get(cacheKey);
|
|
1011
1326
|
if (cornerEl !== void 0) return;
|
|
1012
|
-
if (overlayEls?.has(cacheKey
|
|
1013
|
-
cornerEl = overlayEls.get(cacheKey
|
|
1014
|
-
|
|
1327
|
+
if (overlayEls?.has(cacheKey) === true) {
|
|
1328
|
+
cornerEl = overlayEls.get(cacheKey);
|
|
1329
|
+
cornerEl.style.cssText = css;
|
|
1330
|
+
overlayEls.delete(cacheKey);
|
|
1015
1331
|
} else cornerEl = h("div", {
|
|
1016
1332
|
dataset: "selectionRange",
|
|
1017
|
-
style: { cssText: css
|
|
1333
|
+
style: { cssText: css },
|
|
1018
1334
|
children: [h("div", { dataset })]
|
|
1019
1335
|
}, renderCtx.fragment);
|
|
1020
|
-
renderCtx.elements.set(cacheKey
|
|
1336
|
+
renderCtx.elements.set(cacheKey, cornerEl);
|
|
1021
1337
|
};
|
|
1022
1338
|
const addRadiusStyle = (element) => {
|
|
1023
1339
|
const end = left + width;
|
|
@@ -1067,10 +1383,9 @@ var Editor = class {
|
|
|
1067
1383
|
if (overlayEls?.has(cacheKey) === true) {
|
|
1068
1384
|
rangeEl = overlayEls.get(cacheKey);
|
|
1069
1385
|
overlayEls.delete(cacheKey);
|
|
1070
|
-
} else rangeEl = h("div", {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}, renderCtx.fragment);
|
|
1386
|
+
} else rangeEl = h("div", { dataset: extraDataset ? [type + "Range", extraDataset] : type + "Range" }, renderCtx.fragment);
|
|
1387
|
+
rangeEl.style.width = `${width}px`;
|
|
1388
|
+
rangeEl.style.transform = `translateX(${left}px) translateY(${y}px)`;
|
|
1074
1389
|
if (rounded) addRadiusStyle(rangeEl);
|
|
1075
1390
|
renderCtx.elements.set(cacheKey, rangeEl);
|
|
1076
1391
|
}
|
|
@@ -1080,71 +1395,70 @@ var Editor = class {
|
|
|
1080
1395
|
const [left, wrapLine] = this.#getCharX(line, character);
|
|
1081
1396
|
const cacheKey = "caret-" + line + "/" + wrapLine + ":" + character;
|
|
1082
1397
|
if (renderCtx.elements.has(cacheKey)) return;
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1398
|
+
const x = left - 1;
|
|
1399
|
+
const y = this.#getLineY(line) + wrapLine * this.#metrics.lineHeight;
|
|
1400
|
+
let caretEl;
|
|
1401
|
+
if (this.#overlayElements?.has(cacheKey) === true) {
|
|
1402
|
+
caretEl = this.#overlayElements.get(cacheKey);
|
|
1403
|
+
this.#overlayElements.delete(cacheKey);
|
|
1404
|
+
} else caretEl = h("div", { dataset: "caret" }, renderCtx.fragment);
|
|
1405
|
+
caretEl.style.transform = `translateX(${x}px) translateY(${y}px)`;
|
|
1087
1406
|
renderCtx.elements.set(cacheKey, caretEl);
|
|
1088
1407
|
if (isPrimary) {
|
|
1089
1408
|
caretEl.style.scrollMargin = this.#getScrollMargin();
|
|
1090
1409
|
this.#primaryCaretElement = caretEl;
|
|
1091
1410
|
}
|
|
1092
1411
|
}
|
|
1093
|
-
#
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
const
|
|
1097
|
-
const
|
|
1098
|
-
if (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
const
|
|
1111
|
-
const fileContainer = this.#fileContainer;
|
|
1112
|
-
if (textDocument === void 0 || renderSelectionAction === void 0 || fileContainer == null) return;
|
|
1113
|
-
const line$1 = selection.end.line;
|
|
1114
|
-
const lineText = textDocument.getLineText(line$1);
|
|
1412
|
+
#updateSelectionActionPopover() {
|
|
1413
|
+
const primarySelection = this.#selections?.at(-1);
|
|
1414
|
+
const overlayElement = this.#overlayElement;
|
|
1415
|
+
const textDocument = this.#textDocument;
|
|
1416
|
+
const renderSelectionAction = this.#options.renderSelectionAction;
|
|
1417
|
+
if (this.#options.enabledSelectionAction !== true || renderSelectionAction === void 0 || primarySelection === void 0 || isCollapsedSelection(primarySelection) || this.#isContentMouseDown || overlayElement === void 0 || textDocument === void 0) {
|
|
1418
|
+
this.#selectionAction?.cleanup();
|
|
1419
|
+
this.#selectionAction = void 0;
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
const head = getCaretPosition(primarySelection);
|
|
1423
|
+
if (!this.#isLineVisible(head.line)) {
|
|
1424
|
+
this.#selectionAction?.cleanup();
|
|
1425
|
+
this.#selectionAction = void 0;
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
if (this.#selectionAction === void 0) {
|
|
1429
|
+
const getActiveSelection = () => this.#selections?.at(-1) ?? primarySelection;
|
|
1115
1430
|
const selectionActionElement = renderSelectionAction({
|
|
1116
1431
|
textDocument,
|
|
1117
|
-
selection
|
|
1118
|
-
|
|
1119
|
-
const change = textDocument.applyEdits(edits, true, this.#selections);
|
|
1120
|
-
if (change !== void 0) this.#applyChange(change);
|
|
1121
|
-
},
|
|
1122
|
-
getSelectionText: () => {
|
|
1123
|
-
return this.#textDocument?.getText(selection) ?? "";
|
|
1432
|
+
get selection() {
|
|
1433
|
+
return getActiveSelection();
|
|
1124
1434
|
},
|
|
1435
|
+
applyEdits: (edits) => this.applyEdits(edits, true),
|
|
1436
|
+
getSelectionText: () => this.#textDocument?.getText(getActiveSelection()) ?? "",
|
|
1125
1437
|
replaceSelectionText: (text) => {
|
|
1126
|
-
this.#replaceSelectionText(text);
|
|
1438
|
+
this.#replaceSelectionText(text, [getActiveSelection()]);
|
|
1127
1439
|
},
|
|
1128
1440
|
close: () => {
|
|
1129
|
-
|
|
1130
|
-
|
|
1441
|
+
this.#selectionAction?.cleanup();
|
|
1442
|
+
this.#selectionAction = void 0;
|
|
1131
1443
|
this.#scrollToPrimaryCaret();
|
|
1132
1444
|
}
|
|
1133
1445
|
});
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1446
|
+
this.#selectionAction = new SelectionActionWidget(head.line, selectionActionElement, overlayElement);
|
|
1447
|
+
}
|
|
1448
|
+
const [left, wrapLine] = this.#getCharX(head.line, head.character);
|
|
1449
|
+
const lineHeight = this.#metrics.lineHeight;
|
|
1450
|
+
const top = this.#getLineY(head.line) + wrapLine * lineHeight + lineHeight;
|
|
1451
|
+
this.#selectionAction.line = head.line;
|
|
1452
|
+
this.#selectionAction.reposition(left, top, this.#getGutterWidth());
|
|
1453
|
+
}
|
|
1454
|
+
#openSearchPanel(mode) {
|
|
1455
|
+
if (this.#searchPanel !== void 0) {
|
|
1456
|
+
this.#searchPanel.setMode(mode);
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
this.#renderSearchPanel(mode);
|
|
1146
1460
|
}
|
|
1147
|
-
#renderSearchPanel() {
|
|
1461
|
+
#renderSearchPanel(mode) {
|
|
1148
1462
|
this.#searchPanel?.cleanup();
|
|
1149
1463
|
const textDocument = this.#textDocument;
|
|
1150
1464
|
const preElement = this.#fileContainer?.shadowRoot?.querySelector("pre");
|
|
@@ -1170,19 +1484,41 @@ var Editor = class {
|
|
|
1170
1484
|
this.#scrollToPrimaryCaret(true);
|
|
1171
1485
|
this.#retainSearchPanelFocus = retainFocus;
|
|
1172
1486
|
};
|
|
1173
|
-
|
|
1487
|
+
const searchPanel = new SearchPanelWidget({
|
|
1174
1488
|
textDocument,
|
|
1175
1489
|
containerElement: preElement,
|
|
1176
1490
|
defaultQuery,
|
|
1491
|
+
mode,
|
|
1177
1492
|
initialMatch,
|
|
1178
1493
|
scrollToMatch,
|
|
1179
|
-
|
|
1494
|
+
applyReplace: (edits) => {
|
|
1495
|
+
if (edits.length === 0) return;
|
|
1496
|
+
const change = textDocument.applyEdits(edits.map((edit) => ({
|
|
1497
|
+
range: {
|
|
1498
|
+
start: textDocument.positionAt(edit.start),
|
|
1499
|
+
end: textDocument.positionAt(edit.end)
|
|
1500
|
+
},
|
|
1501
|
+
newText: edit.text
|
|
1502
|
+
})), true, this.#selections);
|
|
1503
|
+
if (change !== void 0) this.#applyChange(change, void 0, this.#applyChangeToLineAnnotations(change), { skipSearchRefresh: true });
|
|
1504
|
+
},
|
|
1505
|
+
onUpdate: (allMatches, options) => {
|
|
1180
1506
|
if (allMatches.length === 0) {
|
|
1181
1507
|
this.#matches = void 0;
|
|
1182
1508
|
this.#updateSelections(this.#selections ?? []);
|
|
1183
1509
|
return;
|
|
1184
1510
|
}
|
|
1185
1511
|
this.#matches = allMatches;
|
|
1512
|
+
if (options?.syncSelection === false) {
|
|
1513
|
+
this.#updateSelections(this.#selections ?? []);
|
|
1514
|
+
const primarySelection = this.#selections?.at(-1);
|
|
1515
|
+
if (primarySelection !== void 0) {
|
|
1516
|
+
const startOffset = textDocument.offsetAt(primarySelection.start);
|
|
1517
|
+
const endOffset = textDocument.offsetAt(primarySelection.end);
|
|
1518
|
+
for (const match of allMatches) if (match[0] === startOffset && match[1] === endOffset) return match;
|
|
1519
|
+
}
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1186
1522
|
const primarySelection = this.#selections?.at(-1);
|
|
1187
1523
|
let searchOffset = 0;
|
|
1188
1524
|
let nextMatch;
|
|
@@ -1202,6 +1538,7 @@ var Editor = class {
|
|
|
1202
1538
|
this.#updateSelections(this.#selections ?? []);
|
|
1203
1539
|
}
|
|
1204
1540
|
});
|
|
1541
|
+
this.#searchPanel = searchPanel;
|
|
1205
1542
|
this.#retainSearchPanelFocus = false;
|
|
1206
1543
|
}
|
|
1207
1544
|
#getSelectionText() {
|
|
@@ -1210,46 +1547,60 @@ var Editor = class {
|
|
|
1210
1547
|
if (textDocument === void 0 || selections === void 0) return "";
|
|
1211
1548
|
return getSelectionText(textDocument, selections);
|
|
1212
1549
|
}
|
|
1213
|
-
#
|
|
1550
|
+
#cutSelectionText() {
|
|
1551
|
+
const textDocument = this.#textDocument;
|
|
1552
|
+
const selections = this.#selections;
|
|
1553
|
+
if (textDocument === void 0 || selections === void 0 || selections.length === 0) return "";
|
|
1554
|
+
if (selections.some((selection) => isCollapsedSelection(selection))) {
|
|
1555
|
+
const cut = resolveSelectionCut(textDocument, selections);
|
|
1556
|
+
this.#applySelectionCutEdits(cut.edits, cut.nextSelectionOffsets);
|
|
1557
|
+
return cut.text;
|
|
1558
|
+
}
|
|
1559
|
+
const text = getSelectionText(textDocument, selections);
|
|
1560
|
+
this.#replaceSelectionText("", void 0, true);
|
|
1561
|
+
return text;
|
|
1562
|
+
}
|
|
1563
|
+
#applySelectionCutEdits(edits, nextSelectionOffsets) {
|
|
1564
|
+
const textDocument = this.#textDocument;
|
|
1214
1565
|
const selections = this.#selections;
|
|
1566
|
+
if (textDocument === void 0 || selections === void 0 || edits.length === 0) return;
|
|
1567
|
+
const change = textDocument.applyResolvedEdits(edits, true, selections, void 0, true);
|
|
1568
|
+
if (change === void 0) return;
|
|
1569
|
+
const nextSelections = nextSelectionOffsets.map((offset) => {
|
|
1570
|
+
const caret = textDocument.positionAt(offset);
|
|
1571
|
+
return {
|
|
1572
|
+
start: caret,
|
|
1573
|
+
end: caret,
|
|
1574
|
+
direction: 0
|
|
1575
|
+
};
|
|
1576
|
+
});
|
|
1577
|
+
textDocument.setLastUndoSelectionsAfter(nextSelections);
|
|
1578
|
+
this.#applyChange(change, nextSelections, this.#applyChangeToLineAnnotations(change));
|
|
1579
|
+
}
|
|
1580
|
+
#replaceSelectionText(text, selections = this.#selections, undoBoundary = false) {
|
|
1215
1581
|
if (selections === void 0) return;
|
|
1216
1582
|
const textDocument = this.#textDocument;
|
|
1217
1583
|
const primarySelection = selections.at(-1);
|
|
1218
1584
|
if (textDocument === void 0 || primarySelection === void 0) return;
|
|
1219
|
-
const { nextSelections, change } = Array.isArray(text) && text.length === selections.length ? applyTextReplaceToSelections(textDocument, selections, text, this.#lineAnnotations) : applyTextChangeToSelections(textDocument, selections, {
|
|
1585
|
+
const { nextSelections, change } = Array.isArray(text) && text.length === selections.length ? applyTextReplaceToSelections(textDocument, selections, text, this.#lineAnnotations, undoBoundary) : applyTextChangeToSelections(textDocument, selections, {
|
|
1220
1586
|
start: textDocument.offsetAt(primarySelection.start),
|
|
1221
1587
|
end: textDocument.offsetAt(primarySelection.end),
|
|
1222
1588
|
text: Array.isArray(text) ? text.join("\n") : text
|
|
1223
|
-
}, this.#lineAnnotations);
|
|
1589
|
+
}, this.#lineAnnotations, void 0, undoBoundary);
|
|
1224
1590
|
if (change !== void 0) this.#applyChange(change, nextSelections, this.#applyChangeToLineAnnotations(change));
|
|
1225
1591
|
}
|
|
1226
1592
|
#deleteSelectionText(forward = false) {
|
|
1227
1593
|
const selections = this.#selections;
|
|
1228
1594
|
const textDocument = this.#textDocument;
|
|
1229
1595
|
if (selections === void 0 || textDocument === void 0) return;
|
|
1230
|
-
const
|
|
1231
|
-
if (
|
|
1232
|
-
let edit;
|
|
1233
|
-
if (isCollapsedSelection(primarySelection)) {
|
|
1234
|
-
const offset = textDocument.offsetAt(primarySelection.start);
|
|
1235
|
-
const nextOffset = forward ? Math.min(textDocument.getText().length, offset + 1) : Math.max(0, offset - 1);
|
|
1236
|
-
edit = {
|
|
1237
|
-
start: Math.min(offset, nextOffset),
|
|
1238
|
-
end: Math.max(offset, nextOffset),
|
|
1239
|
-
text: ""
|
|
1240
|
-
};
|
|
1241
|
-
} else edit = {
|
|
1242
|
-
start: textDocument.offsetAt(primarySelection.start),
|
|
1243
|
-
end: textDocument.offsetAt(primarySelection.end),
|
|
1244
|
-
text: ""
|
|
1245
|
-
};
|
|
1246
|
-
this.#applyResolvedTextEdit(edit);
|
|
1596
|
+
const { nextSelections, change } = applyDeleteCharacterToSelections(textDocument, selections, forward, this.#lineAnnotations, this.#metrics.tabSize);
|
|
1597
|
+
if (change !== void 0) this.#applyChange(change, nextSelections, this.#applyChangeToLineAnnotations(change));
|
|
1247
1598
|
}
|
|
1248
1599
|
#deleteSoftLineBackward() {
|
|
1249
1600
|
const selections = this.#selections;
|
|
1250
1601
|
const textDocument = this.#textDocument;
|
|
1251
1602
|
if (selections === void 0 || textDocument === void 0) return;
|
|
1252
|
-
const { nextSelections, change } = applyDeleteSoftLineBackwardToSelections(textDocument, selections, this.#
|
|
1603
|
+
const { nextSelections, change } = applyDeleteSoftLineBackwardToSelections(textDocument, selections, this.#isWrap ? (line, character) => {
|
|
1253
1604
|
const wrapOffsets = this.#wrapLineText(line);
|
|
1254
1605
|
for (let w = 0; w + 1 < wrapOffsets.length; w++) {
|
|
1255
1606
|
const segmentStart = wrapOffsets[w];
|
|
@@ -1281,27 +1632,25 @@ var Editor = class {
|
|
|
1281
1632
|
const { nextSelections, change } = applyTransposeToSelections(textDocument, selections, this.#lineAnnotations);
|
|
1282
1633
|
if (change !== void 0) this.#applyChange(change, nextSelections, this.#applyChangeToLineAnnotations(change));
|
|
1283
1634
|
}
|
|
1284
|
-
#
|
|
1285
|
-
|
|
1286
|
-
const { nextSelections, change } = applyTextChangeToSelections(this.#textDocument, this.#selections, edit, this.#lineAnnotations, this.#metrics.tabSize);
|
|
1287
|
-
if (change !== void 0) this.#applyChange(change, nextSelections, this.#applyChangeToLineAnnotations(change));
|
|
1288
|
-
}
|
|
1289
|
-
#applyChange(change, selections, newLineAnnotations) {
|
|
1290
|
-
const fileContents = this.#fileContents;
|
|
1635
|
+
#getFileRef() {
|
|
1636
|
+
const fileInfo = this.#fileInfo;
|
|
1291
1637
|
const textDocument = this.#textDocument;
|
|
1638
|
+
if (fileInfo === void 0 || textDocument === void 0) return;
|
|
1639
|
+
const file = { ...fileInfo };
|
|
1640
|
+
Object.defineProperty(file, "contents", {
|
|
1641
|
+
enumerable: true,
|
|
1642
|
+
get: () => textDocument.getText()
|
|
1643
|
+
});
|
|
1644
|
+
return file;
|
|
1645
|
+
}
|
|
1646
|
+
#applyChange(change, selections, newLineAnnotations, options) {
|
|
1647
|
+
const fileRef = this.#getFileRef();
|
|
1292
1648
|
const onChange = this.#options.onChange;
|
|
1293
|
-
if (
|
|
1294
|
-
|
|
1295
|
-
Object.defineProperty(file, "contents", {
|
|
1296
|
-
enumerable: true,
|
|
1297
|
-
get: () => textDocument.getText()
|
|
1298
|
-
});
|
|
1299
|
-
onChange(file, newLineAnnotations ?? this.#lineAnnotations);
|
|
1300
|
-
}
|
|
1301
|
-
if (change.lineDelta !== 0) {
|
|
1649
|
+
if (fileRef !== void 0 && onChange !== void 0) onChange(fileRef, newLineAnnotations ?? this.#lineAnnotations);
|
|
1650
|
+
if (change.lineDelta !== 0 || this.#isWrap) {
|
|
1302
1651
|
for (const line of this.#lineYCache.keys()) if (line >= change.startLine) this.#lineYCache.delete(line);
|
|
1303
1652
|
}
|
|
1304
|
-
if (this.#
|
|
1653
|
+
if (this.#isWrap) {
|
|
1305
1654
|
for (const line of this.#wrapLineOffsetsCache.keys()) if (line >= change.startLine) this.#wrapLineOffsetsCache.delete(line);
|
|
1306
1655
|
}
|
|
1307
1656
|
this.#lastAccessedCharX = void 0;
|
|
@@ -1310,24 +1659,34 @@ var Editor = class {
|
|
|
1310
1659
|
if (renderRange !== void 0 && selections !== void 0 && selections.length > 0) {
|
|
1311
1660
|
const primarySelection = selections.at(-1);
|
|
1312
1661
|
const renderRangeEndLine = renderRange.startingLine + renderRange.totalLines;
|
|
1313
|
-
if (primarySelection.end.line
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1662
|
+
if (primarySelection.end.line >= renderRangeEndLine) {
|
|
1663
|
+
const widenedTotalLines = primarySelection.end.line - renderRange.startingLine + 1;
|
|
1664
|
+
const maxWidenLines = this.#viewportWindowLines === void 0 || this.#viewportWindowLines === Infinity ? Infinity : this.#viewportWindowLines * MAX_EDIT_WIDEN_WINDOW_MULTIPLE;
|
|
1665
|
+
if (change.startLine <= renderRangeEndLine && widenedTotalLines <= maxWidenLines) {
|
|
1666
|
+
if (primarySelection.end.line > renderRangeEndLine) shouldUpdateBuffer = true;
|
|
1667
|
+
renderRange = {
|
|
1668
|
+
...renderRange,
|
|
1669
|
+
totalLines: widenedTotalLines
|
|
1670
|
+
};
|
|
1671
|
+
this.#renderRange = renderRange;
|
|
1672
|
+
} else shouldUpdateBuffer = true;
|
|
1673
|
+
}
|
|
1318
1674
|
}
|
|
1319
1675
|
this.#rerender(change, newLineAnnotations, renderRange, shouldUpdateBuffer);
|
|
1676
|
+
if (options?.skipSearchRefresh !== true && this.#searchPanel !== void 0 && this.#matches !== void 0) this.#searchPanel.updateMatches({ syncSelection: false });
|
|
1320
1677
|
if (selections !== void 0) {
|
|
1321
1678
|
this.#updateSelections(selections);
|
|
1322
|
-
if (
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1679
|
+
if (options?.skipFocus !== true) {
|
|
1680
|
+
if (this.#primaryCaretElement !== void 0) this.#primaryCaretElement.scrollIntoView({
|
|
1681
|
+
block: "nearest",
|
|
1682
|
+
inline: "nearest"
|
|
1683
|
+
});
|
|
1684
|
+
else if (selections.length > 0) {
|
|
1685
|
+
const pos = getCaretPosition(selections.at(-1));
|
|
1686
|
+
this.#scrollToLine(pos.line, pos.character);
|
|
1687
|
+
}
|
|
1688
|
+
this.focus({ preventScroll: true });
|
|
1329
1689
|
}
|
|
1330
|
-
this.focus({ preventScroll: true });
|
|
1331
1690
|
}
|
|
1332
1691
|
}
|
|
1333
1692
|
#applyChangeToLineAnnotations(change) {
|
|
@@ -1359,7 +1718,7 @@ var Editor = class {
|
|
|
1359
1718
|
}
|
|
1360
1719
|
}
|
|
1361
1720
|
}
|
|
1362
|
-
lineElement ??= contentElement.querySelector(`[data-line="${line + 1}"]`);
|
|
1721
|
+
lineElement ??= contentElement.querySelector(`[data-line="${line + 1}"]` + (this.#diffSyle === "unified" ? ":not([data-line-type=\"change-deletion\"])" : ""));
|
|
1363
1722
|
if (lineElement !== null) {
|
|
1364
1723
|
if (lastAccessed !== void 0) {
|
|
1365
1724
|
lastAccessed[0] = line;
|
|
@@ -1391,7 +1750,8 @@ var Editor = class {
|
|
|
1391
1750
|
if (cachedY !== void 0) return cachedY;
|
|
1392
1751
|
const lineElement = this.#getLineElement(line);
|
|
1393
1752
|
if (lineElement === void 0) return -1;
|
|
1394
|
-
|
|
1753
|
+
let y = lineElement.offsetTop + this.#metrics.paddingTop;
|
|
1754
|
+
y += this.#activeContentOffset?.top ?? 0;
|
|
1395
1755
|
this.#lineYCache.set(line, y);
|
|
1396
1756
|
return y;
|
|
1397
1757
|
}
|
|
@@ -1399,7 +1759,7 @@ var Editor = class {
|
|
|
1399
1759
|
if (this.#lastAccessedCharX !== void 0 && this.#lastAccessedCharX[0] === line && this.#lastAccessedCharX[1] === char) return [this.#lastAccessedCharX[2], this.#lastAccessedCharX[3]];
|
|
1400
1760
|
const lineText = this.#textDocument?.getLineText(line);
|
|
1401
1761
|
const offsetLeft = this.#getGutterWidth() + this.#metrics.ch;
|
|
1402
|
-
if (lineText === void 0 || lineText.length === 0 || char <= 0) return [offsetLeft, 0];
|
|
1762
|
+
if (lineText === void 0 || lineText.length === 0 || char <= 0) return [offsetLeft + (this.#activeContentOffset?.left ?? 0), 0];
|
|
1403
1763
|
const boundedCharacter = snapTextOffsetToUnicodeBoundary(lineText, Math.min(char, lineText.length));
|
|
1404
1764
|
const textBeforeCharacter = lineText.slice(0, boundedCharacter);
|
|
1405
1765
|
const asciiColumns = getExpandedAsciiTextColumns(textBeforeCharacter, this.#metrics.tabSize);
|
|
@@ -1407,7 +1767,7 @@ var Editor = class {
|
|
|
1407
1767
|
let wrapLine = 0;
|
|
1408
1768
|
if (asciiColumns !== -1) left = offsetLeft + asciiColumns * this.#metrics.ch;
|
|
1409
1769
|
else left = offsetLeft + this.#metrics.measureTextWidth(textBeforeCharacter);
|
|
1410
|
-
if (this.#
|
|
1770
|
+
if (this.#isWrap) {
|
|
1411
1771
|
const contentWidth = this.#getContentWidth();
|
|
1412
1772
|
if (2 * this.#metrics.ch + this.#metrics.measureTextWidth(lineText) > contentWidth) {
|
|
1413
1773
|
const wrapOffsets = this.#wrapLineText(line);
|
|
@@ -1423,6 +1783,7 @@ var Editor = class {
|
|
|
1423
1783
|
}
|
|
1424
1784
|
}
|
|
1425
1785
|
}
|
|
1786
|
+
left += this.#activeContentOffset?.left ?? 0;
|
|
1426
1787
|
}
|
|
1427
1788
|
if (this.#lastAccessedCharX !== void 0) {
|
|
1428
1789
|
this.#lastAccessedCharX[0] = line;
|
|
@@ -1509,7 +1870,7 @@ var Editor = class {
|
|
|
1509
1870
|
return line < startingLine + totalLines;
|
|
1510
1871
|
}
|
|
1511
1872
|
};
|
|
1512
|
-
|
|
1513
1873
|
//#endregion
|
|
1514
1874
|
export { Editor };
|
|
1875
|
+
|
|
1515
1876
|
//# sourceMappingURL=editor.js.map
|