@codingame/monaco-vscode-api 1.85.0 → 1.85.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -10
- package/contributions.js +1 -0
- package/missing-services.js +91 -5
- package/monaco-editor-treemending.patch +957 -950
- package/package.json +6 -6
- package/vscode/src/vs/base/common/jsonFormatter.js +8 -1
- package/vscode/src/vs/platform/actions/browser/buttonbar.js +128 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.js +2 -1
- package/vscode/src/vs/platform/layout/browser/zIndexRegistry.js +58 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +56 -1
- package/vscode/src/vs/workbench/browser/actions/layoutActions.js +186 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +191 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +238 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +75 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +205 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorInput.js +168 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +35 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +340 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +1195 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +115 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +81 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.js +62 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +583 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +290 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.js +167 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatContextKeys.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +562 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatParserTypes.js +31 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProvider.js +24 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatRequestParser.js +193 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatService.js +22 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +52 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatViewModel.js +258 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +37 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWordCounter.js +25 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +388 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +61 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +49 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +647 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +300 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +60 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +249 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +107 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +333 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +99 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +55 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +2 -0
- package/vscode/src/vs/workbench/contrib/contextmenu/browser/contextmenu.contribution.js +20 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +855 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +410 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +178 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +1485 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +125 -0
- package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsInput.js +41 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsUtils.js +102 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +988 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.js +431 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +417 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +806 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.js +915 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/utils.js +19 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +129 -10
- package/vscode/src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.js +205 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +150 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +480 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +5 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +90 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +54 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +108 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +258 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +614 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +307 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +44 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +165 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +78 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +169 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +64 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/cellOutputClipboard.js +49 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findFilters.js +70 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +120 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.js +416 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.js +663 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +593 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOutputActions.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/coreActions.js +326 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +539 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/foldingController.js +265 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +348 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebook.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellEditorHint.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellInsertToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellOutput.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellStatusBar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellTitleToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookDnd.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookEditorStickyScroll.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFocusIndicator.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFolding.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookKernelActionViewItem.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookOutline.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookBrowser.js +95 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditor.js +437 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorExtensions.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +2730 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookIcons.js +139 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookLogger.js +17 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookOptions.js +564 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookViewEvents.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellPart.js +119 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellComments.js +135 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys.js +178 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.js +35 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDnd.js +377 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDragRenderer.js +97 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions.js +194 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellExecution.js +71 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocus.js +20 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.js +652 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellProgressBar.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.js +303 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbarStickyScroll.js +24 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.js +228 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatActions.js +302 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController.js +438 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatPart.js +45 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellExecutionIcon.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.js +107 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellOutput.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/foldedCellHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.js +430 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellAnchor.js +54 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.js +1131 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellListView.js +21 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.js +341 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.js +2155 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewThemeMapping.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.js +507 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel.js +47 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.js +40 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher.js +31 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/foldingModel.js +257 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.js +239 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.js +211 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.js +808 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/viewContext.js +8 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.js +381 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar.js +527 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.js +163 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelQuickPickStrategy.js +651 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelView.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler.js +98 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar.js +62 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellOutputTextModel.js +101 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.js +346 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookCommon.js +152 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookContextKeys.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorInput.js +296 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +261 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionService.js +3 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKernelService.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKeymapService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookLoggingService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookPerformance.js +16 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookRange.js +66 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWorkerService.js +4 -0
- package/vscode/src/vs/workbench/contrib/preferences/common/settingsEditorColorRegistry.js +130 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +847 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +89 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +1942 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/urlFinder.js +107 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsBase.js +49 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsFind.js +387 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/common/constants.js +66 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/constants.js +11 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions.js +24 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets.js +95 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.js +4 -1
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.js +2 -1
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/featuredExtensionService.js +159 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedExtensionPoint.js +375 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.js +563 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.js +932 -0
- package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +15 -1
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.d.ts +2 -2
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +190 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +77 -0
- package/assets/break.mp3 +0 -0
- package/assets/chatRequestSent.mp3 +0 -0
- package/assets/chatResponsePending.mp3 +0 -0
- package/assets/chatResponseReceived1.mp3 +0 -0
- package/assets/chatResponseReceived2.mp3 +0 -0
- package/assets/chatResponseReceived3.mp3 +0 -0
- package/assets/chatResponseReceived4.mp3 +0 -0
- package/assets/clear.mp3 +0 -0
- package/assets/defaultIcon.png +0 -0
- package/assets/diffLineDeleted.mp3 +0 -0
- package/assets/diffLineInserted.mp3 +0 -0
- package/assets/diffLineModified.mp3 +0 -0
- package/assets/error.mp3 +0 -0
- package/assets/fake.html +0 -10
- package/assets/foldedAreas.mp3 +0 -0
- package/assets/format.mp3 +0 -0
- package/assets/index-no-csp.html +0 -1226
- package/assets/index.html +0 -1227
- package/assets/quickFixes.mp3 +0 -0
- package/assets/save.mp3 +0 -0
- package/assets/service-worker.js +0 -457
- package/assets/taskCompleted.mp3 +0 -0
- package/assets/taskFailed.mp3 +0 -0
- package/assets/terminalBell.mp3 +0 -0
- package/assets/warning.mp3 +0 -0
- package/assets/webWorkerExtensionHostIframe.html +0 -123
- package/override/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +0 -2
- package/override/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +0 -2
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -5
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { disposableWindowInterval } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
3
|
+
import { $window } from 'monaco-editor/esm/vs/base/browser/window.js';
|
|
4
|
+
import { toAction } from 'monaco-editor/esm/vs/base/common/actions.js';
|
|
5
|
+
import { equals, tail } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
6
|
+
import { AsyncIterableSource } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
7
|
+
import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
8
|
+
import { Event, Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
9
|
+
import { Lazy } from 'monaco-editor/esm/vs/base/common/lazy.js';
|
|
10
|
+
import { DisposableStore, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
11
|
+
import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
|
|
12
|
+
import { IBulkEditService } from 'monaco-editor/esm/vs/editor/browser/services/bulkEditService.js';
|
|
13
|
+
import { StableEditorScrollState } from 'monaco-editor/esm/vs/editor/browser/stableEditorScroll.js';
|
|
14
|
+
import { RenderOptions, LineSource, renderLines } from 'monaco-editor/esm/vs/editor/browser/widget/diffEditor/renderLines.js';
|
|
15
|
+
import { EditOperation } from 'monaco-editor/esm/vs/editor/common/core/editOperation.js';
|
|
16
|
+
import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
|
|
17
|
+
import { Selection } from 'monaco-editor/esm/vs/editor/common/core/selection.js';
|
|
18
|
+
import { DetailedLineRangeMapping } from 'monaco-editor/esm/vs/editor/common/diff/rangeMapping.js';
|
|
19
|
+
import { TextEdit } from 'monaco-editor/esm/vs/editor/common/languages.js';
|
|
20
|
+
import { ModelDecorationOptions } from 'monaco-editor/esm/vs/editor/common/model/textModel.js';
|
|
21
|
+
import { IEditorWorkerService } from 'monaco-editor/esm/vs/editor/common/services/editorWorker.js';
|
|
22
|
+
import { InlineDecoration } from 'monaco-editor/esm/vs/editor/common/viewModel.js';
|
|
23
|
+
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
24
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
25
|
+
import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
26
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
27
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
28
|
+
import { countWords, getNWords } from '../../chat/common/chatWordCounter.js';
|
|
29
|
+
import { InlineChatFileCreatePreviewWidget, InlineChatLivePreviewWidget } from './inlineChatLivePreviewWidget.js';
|
|
30
|
+
import { ReplyResponse } from './inlineChatSession.js';
|
|
31
|
+
import { CTX_INLINE_CHAT_DOCUMENT_CHANGED, CTX_INLINE_CHAT_CHANGE_HAS_DIFF, CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF } from '../common/inlineChat.js';
|
|
32
|
+
var LiveStrategy_1, LiveStrategy3_1;
|
|
33
|
+
class EditModeStrategy {
|
|
34
|
+
constructor(_zone) {
|
|
35
|
+
this._zone = _zone;
|
|
36
|
+
this._onDidAccept = ( new Emitter());
|
|
37
|
+
this._onDidDiscard = ( new Emitter());
|
|
38
|
+
this.onDidAccept = this._onDidAccept.event;
|
|
39
|
+
this.onDidDiscard = this._onDidDiscard.event;
|
|
40
|
+
}
|
|
41
|
+
dispose() {
|
|
42
|
+
this._onDidAccept.dispose();
|
|
43
|
+
this._onDidDiscard.dispose();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
let PreviewStrategy = class PreviewStrategy extends EditModeStrategy {
|
|
47
|
+
constructor(_session, zone, contextKeyService) {
|
|
48
|
+
super(zone);
|
|
49
|
+
this._session = _session;
|
|
50
|
+
this._ctxDocumentChanged = CTX_INLINE_CHAT_DOCUMENT_CHANGED.bindTo(contextKeyService);
|
|
51
|
+
this._listener = Event.debounce(_session.textModelN.onDidChangeContent.bind(_session.textModelN), () => { }, 350)(_ => {
|
|
52
|
+
if (!_session.textModelN.isDisposed() && !_session.textModel0.isDisposed()) {
|
|
53
|
+
this._ctxDocumentChanged.set(_session.hasChangedText);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
dispose() {
|
|
58
|
+
this._listener.dispose();
|
|
59
|
+
this._ctxDocumentChanged.reset();
|
|
60
|
+
super.dispose();
|
|
61
|
+
}
|
|
62
|
+
async start() {
|
|
63
|
+
}
|
|
64
|
+
async apply() {
|
|
65
|
+
if (!(this._session.lastExchange?.response instanceof ReplyResponse)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const editResponse = this._session.lastExchange?.response;
|
|
69
|
+
const { textModelN: modelN } = this._session;
|
|
70
|
+
if (modelN.equalsTextBuffer(this._session.textModel0.getTextBuffer())) {
|
|
71
|
+
modelN.pushStackElement();
|
|
72
|
+
for (const edits of editResponse.allLocalEdits) {
|
|
73
|
+
modelN.pushEditOperations(null, ( edits.map(TextEdit.asEditOperation)), () => null);
|
|
74
|
+
}
|
|
75
|
+
modelN.pushStackElement();
|
|
76
|
+
}
|
|
77
|
+
const { untitledTextModel } = this._session.lastExchange.response;
|
|
78
|
+
if (untitledTextModel && !untitledTextModel.isDisposed() && untitledTextModel.isDirty()) {
|
|
79
|
+
await untitledTextModel.save({ reason: 1 });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async cancel() {
|
|
83
|
+
}
|
|
84
|
+
async makeChanges(_edits) {
|
|
85
|
+
}
|
|
86
|
+
async undoChanges(_altVersionId) {
|
|
87
|
+
}
|
|
88
|
+
async makeProgressiveChanges() {
|
|
89
|
+
}
|
|
90
|
+
async renderChanges(response) {
|
|
91
|
+
if (response.allLocalEdits.length > 0) {
|
|
92
|
+
const allEditOperation = ( response.allLocalEdits.map(edits => ( edits.map(TextEdit.asEditOperation))));
|
|
93
|
+
await this._zone.widget.showEditsPreview(this._session.textModel0, this._session.textModelN, allEditOperation);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this._zone.widget.hideEditsPreview();
|
|
97
|
+
}
|
|
98
|
+
if (response.untitledTextModel) {
|
|
99
|
+
this._zone.widget.showCreatePreview(response.untitledTextModel);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this._zone.widget.hideCreatePreview();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
hasFocus() {
|
|
106
|
+
return this._zone.widget.hasFocus();
|
|
107
|
+
}
|
|
108
|
+
needsMargin() {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
PreviewStrategy = ( __decorate([
|
|
113
|
+
( __param(2, IContextKeyService))
|
|
114
|
+
], PreviewStrategy));
|
|
115
|
+
class InlineDiffDecorations {
|
|
116
|
+
constructor(editor, visible = false) {
|
|
117
|
+
this._data = [];
|
|
118
|
+
this._visible = false;
|
|
119
|
+
this._collection = editor.createDecorationsCollection();
|
|
120
|
+
this._visible = visible;
|
|
121
|
+
}
|
|
122
|
+
get visible() {
|
|
123
|
+
return this._visible;
|
|
124
|
+
}
|
|
125
|
+
set visible(value) {
|
|
126
|
+
this._visible = value;
|
|
127
|
+
this.update();
|
|
128
|
+
}
|
|
129
|
+
clear() {
|
|
130
|
+
this._collection.clear();
|
|
131
|
+
this._data.length = 0;
|
|
132
|
+
}
|
|
133
|
+
collectEditOperation(op) {
|
|
134
|
+
this._data.push(InlineDiffDecorations._asDecorationData(op));
|
|
135
|
+
}
|
|
136
|
+
update() {
|
|
137
|
+
this._collection.set(( this._data.map(d => {
|
|
138
|
+
const res = { ...d.tracking };
|
|
139
|
+
if (this._visible) {
|
|
140
|
+
res.options = { ...res.options, ...d.decorating };
|
|
141
|
+
}
|
|
142
|
+
return res;
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
145
|
+
static _asDecorationData(edit) {
|
|
146
|
+
let content = edit.text;
|
|
147
|
+
if (content.length > 12) {
|
|
148
|
+
content = content.substring(0, 12) + '…';
|
|
149
|
+
}
|
|
150
|
+
const tracking = {
|
|
151
|
+
range: edit.range,
|
|
152
|
+
options: {
|
|
153
|
+
description: 'inline-chat-inline-diff',
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const decorating = {
|
|
157
|
+
description: 'inline-chat-inline-diff',
|
|
158
|
+
className: !edit.range.isEmpty() ? 'inline-chat-lines-inserted-range' : undefined,
|
|
159
|
+
showIfCollapsed: true,
|
|
160
|
+
before: {
|
|
161
|
+
content,
|
|
162
|
+
inlineClassName: 'inline-chat-lines-deleted-range-inline',
|
|
163
|
+
attachedData: edit,
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
return { tracking, decorating };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
let LiveStrategy = LiveStrategy_1 = class LiveStrategy extends EditModeStrategy {
|
|
170
|
+
constructor(_session, _editor, zone, configService, _storageService, _bulkEditService, _editorWorkerService, _instaService) {
|
|
171
|
+
super(zone);
|
|
172
|
+
this._session = _session;
|
|
173
|
+
this._editor = _editor;
|
|
174
|
+
this._storageService = _storageService;
|
|
175
|
+
this._bulkEditService = _bulkEditService;
|
|
176
|
+
this._editorWorkerService = _editorWorkerService;
|
|
177
|
+
this._instaService = _instaService;
|
|
178
|
+
this._diffEnabled = false;
|
|
179
|
+
this._store = ( new DisposableStore());
|
|
180
|
+
this._editCount = 0;
|
|
181
|
+
this._diffEnabled = configService.getValue('inlineChat.showDiff');
|
|
182
|
+
this._inlineDiffDecorations = ( new InlineDiffDecorations(this._editor, this._diffEnabled));
|
|
183
|
+
this._inlineDiffDecorations.visible = this._diffEnabled;
|
|
184
|
+
this._store.add(configService.onDidChangeConfiguration(e => {
|
|
185
|
+
if (e.affectsConfiguration('inlineChat.showDiff')) {
|
|
186
|
+
this._diffEnabled = !this._diffEnabled;
|
|
187
|
+
this._doToggleDiff();
|
|
188
|
+
}
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
dispose() {
|
|
192
|
+
super.dispose();
|
|
193
|
+
this._inlineDiffDecorations.clear();
|
|
194
|
+
this._store.dispose();
|
|
195
|
+
}
|
|
196
|
+
_doToggleDiff() {
|
|
197
|
+
this._inlineDiffDecorations.visible = this._diffEnabled;
|
|
198
|
+
}
|
|
199
|
+
async start() {
|
|
200
|
+
}
|
|
201
|
+
async apply() {
|
|
202
|
+
if (this._editCount > 0) {
|
|
203
|
+
this._editor.pushUndoStop();
|
|
204
|
+
}
|
|
205
|
+
if (!(this._session.lastExchange?.response instanceof ReplyResponse)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const { untitledTextModel } = this._session.lastExchange.response;
|
|
209
|
+
if (untitledTextModel && !untitledTextModel.isDisposed() && untitledTextModel.isDirty()) {
|
|
210
|
+
await untitledTextModel.save({ reason: 1 });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
async cancel() {
|
|
214
|
+
const { textModelN: modelN, textModelNAltVersion, textModelNSnapshotAltVersion } = this._session;
|
|
215
|
+
if (modelN.isDisposed()) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const targetAltVersion = textModelNSnapshotAltVersion ?? textModelNAltVersion;
|
|
219
|
+
LiveStrategy_1._undoModelUntil(modelN, targetAltVersion);
|
|
220
|
+
}
|
|
221
|
+
async makeChanges(edits) {
|
|
222
|
+
const cursorStateComputerAndInlineDiffCollection = (undoEdits) => {
|
|
223
|
+
let last = null;
|
|
224
|
+
for (const edit of undoEdits) {
|
|
225
|
+
last = !last || last.isBefore(edit.range.getEndPosition()) ? edit.range.getEndPosition() : last;
|
|
226
|
+
this._inlineDiffDecorations.collectEditOperation(edit);
|
|
227
|
+
}
|
|
228
|
+
return last && [Selection.fromPositions(last)];
|
|
229
|
+
};
|
|
230
|
+
if (++this._editCount === 1) {
|
|
231
|
+
this._editor.pushUndoStop();
|
|
232
|
+
}
|
|
233
|
+
this._editor.executeEdits('inline-chat-live', edits, cursorStateComputerAndInlineDiffCollection);
|
|
234
|
+
}
|
|
235
|
+
async undoChanges(altVersionId) {
|
|
236
|
+
const { textModelN } = this._session;
|
|
237
|
+
LiveStrategy_1._undoModelUntil(textModelN, altVersionId);
|
|
238
|
+
}
|
|
239
|
+
async makeProgressiveChanges(edits, opts) {
|
|
240
|
+
if (++this._editCount === 1) {
|
|
241
|
+
this._editor.pushUndoStop();
|
|
242
|
+
}
|
|
243
|
+
const durationInSec = opts.duration / 1000;
|
|
244
|
+
for (const edit of edits) {
|
|
245
|
+
const wordCount = countWords(edit.text ?? '');
|
|
246
|
+
const speed = wordCount / durationInSec;
|
|
247
|
+
await performAsyncTextEdit(this._session.textModelN, asProgressiveEdit(edit, speed, opts.token));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async renderChanges(response) {
|
|
251
|
+
const diff = await this._editorWorkerService.computeDiff(this._session.textModel0.uri, this._session.textModelN.uri, { ignoreTrimWhitespace: false, maxComputationTimeMs: 5000, computeMoves: false }, 'advanced');
|
|
252
|
+
this._updateSummaryMessage(diff?.changes ?? []);
|
|
253
|
+
this._inlineDiffDecorations.update();
|
|
254
|
+
if (response.untitledTextModel) {
|
|
255
|
+
this._zone.widget.showCreatePreview(response.untitledTextModel);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
this._zone.widget.hideCreatePreview();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
static _undoModelUntil(model, targetAltVersion) {
|
|
262
|
+
while (targetAltVersion < model.getAlternativeVersionId() && model.canUndo()) {
|
|
263
|
+
model.undo();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
_updateSummaryMessage(mappings) {
|
|
267
|
+
let linesChanged = 0;
|
|
268
|
+
for (const change of mappings) {
|
|
269
|
+
linesChanged += change.changedLineCount;
|
|
270
|
+
}
|
|
271
|
+
let message;
|
|
272
|
+
if (linesChanged === 0) {
|
|
273
|
+
message = ( localizeWithPath(
|
|
274
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies',
|
|
275
|
+
'lines.0',
|
|
276
|
+
"Nothing changed"
|
|
277
|
+
));
|
|
278
|
+
}
|
|
279
|
+
else if (linesChanged === 1) {
|
|
280
|
+
message = ( localizeWithPath(
|
|
281
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies',
|
|
282
|
+
'lines.1',
|
|
283
|
+
"Changed 1 line"
|
|
284
|
+
));
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
message = ( localizeWithPath(
|
|
288
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies',
|
|
289
|
+
'lines.N',
|
|
290
|
+
"Changed {0} lines",
|
|
291
|
+
linesChanged
|
|
292
|
+
));
|
|
293
|
+
}
|
|
294
|
+
this._zone.widget.updateStatus(message);
|
|
295
|
+
}
|
|
296
|
+
needsMargin() {
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
hasFocus() {
|
|
300
|
+
return this._zone.widget.hasFocus();
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
LiveStrategy = LiveStrategy_1 = ( __decorate([
|
|
304
|
+
( __param(3, IConfigurationService)),
|
|
305
|
+
( __param(4, IStorageService)),
|
|
306
|
+
( __param(5, IBulkEditService)),
|
|
307
|
+
( __param(6, IEditorWorkerService)),
|
|
308
|
+
( __param(7, IInstantiationService))
|
|
309
|
+
], LiveStrategy));
|
|
310
|
+
let LivePreviewStrategy = class LivePreviewStrategy extends LiveStrategy {
|
|
311
|
+
constructor(session, editor, zone, configService, storageService, bulkEditService, editorWorkerService, instaService) {
|
|
312
|
+
super(session, editor, zone, configService, storageService, bulkEditService, editorWorkerService, instaService);
|
|
313
|
+
this._diffZonePool = [];
|
|
314
|
+
this._currentLineRangeGroups = [];
|
|
315
|
+
this._previewZone = ( new Lazy(
|
|
316
|
+
() => instaService.createInstance(InlineChatFileCreatePreviewWidget, editor)
|
|
317
|
+
));
|
|
318
|
+
}
|
|
319
|
+
dispose() {
|
|
320
|
+
for (const zone of this._diffZonePool) {
|
|
321
|
+
zone.hide();
|
|
322
|
+
zone.dispose();
|
|
323
|
+
}
|
|
324
|
+
this._previewZone.rawValue?.hide();
|
|
325
|
+
this._previewZone.rawValue?.dispose();
|
|
326
|
+
super.dispose();
|
|
327
|
+
}
|
|
328
|
+
async _updateDiffZones() {
|
|
329
|
+
const diff = await this._editorWorkerService.computeDiff(this._session.textModel0.uri, this._session.textModelN.uri, { ignoreTrimWhitespace: false, maxComputationTimeMs: 5000, computeMoves: false }, 'advanced');
|
|
330
|
+
if (!diff || diff.changes.length === 0) {
|
|
331
|
+
for (const zone of this._diffZonePool) {
|
|
332
|
+
zone.hide();
|
|
333
|
+
}
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const originalStartLineNumber = this._session.session.wholeRange?.startLineNumber ?? 1;
|
|
337
|
+
const mainGroup = [];
|
|
338
|
+
let lastGroup;
|
|
339
|
+
const groups = [mainGroup];
|
|
340
|
+
for (let i = 0; i < diff.changes.length; i++) {
|
|
341
|
+
const change = diff.changes[i];
|
|
342
|
+
if (change.original.startLineNumber >= originalStartLineNumber || 'true') {
|
|
343
|
+
mainGroup.push(change);
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (!lastGroup) {
|
|
347
|
+
lastGroup = [change];
|
|
348
|
+
groups.push(lastGroup);
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
const last = tail(lastGroup);
|
|
352
|
+
const treshold = Math.ceil((change.modified.length + last.modified.length) * .75);
|
|
353
|
+
if (change.modified.startLineNumber - last.modified.endLineNumberExclusive <= treshold) {
|
|
354
|
+
lastGroup.push(change);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
lastGroup = [change];
|
|
358
|
+
groups.push(lastGroup);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const beforeAndNowAreEqual = equals(this._currentLineRangeGroups, groups, (groupA, groupB) => {
|
|
362
|
+
return equals(groupA, groupB, (mappingA, mappingB) => {
|
|
363
|
+
return mappingA.original.equals(mappingB.original) && mappingA.modified.equals(mappingB.modified);
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
if (beforeAndNowAreEqual) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
this._updateSummaryMessage(diff.changes);
|
|
370
|
+
this._currentLineRangeGroups = groups;
|
|
371
|
+
const handleDiff = () => {
|
|
372
|
+
this._updateDiffZones();
|
|
373
|
+
};
|
|
374
|
+
while (groups.length > this._diffZonePool.length) {
|
|
375
|
+
this._diffZonePool.push(this._instaService.createInstance(InlineChatLivePreviewWidget, this._editor, this._session, {}, this._diffZonePool.length === 0 ? handleDiff : undefined));
|
|
376
|
+
}
|
|
377
|
+
for (let i = 0; i < groups.length; i++) {
|
|
378
|
+
this._diffZonePool[i].showForChanges(groups[i]);
|
|
379
|
+
}
|
|
380
|
+
for (let i = groups.length; i < this._diffZonePool.length; i++) {
|
|
381
|
+
this._diffZonePool[i].hide();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
async makeProgressiveChanges(edits, opts) {
|
|
385
|
+
const changeTask = super.makeProgressiveChanges(edits, opts);
|
|
386
|
+
let renderTask = Promise.resolve();
|
|
387
|
+
const changeListener = this._session.textModelN.onDidChangeContent(() => {
|
|
388
|
+
changeListener.dispose();
|
|
389
|
+
renderTask = this._updateDiffZones();
|
|
390
|
+
});
|
|
391
|
+
await changeTask;
|
|
392
|
+
await renderTask;
|
|
393
|
+
changeListener.dispose();
|
|
394
|
+
}
|
|
395
|
+
async undoChanges(altVersionId) {
|
|
396
|
+
await super.undoChanges(altVersionId);
|
|
397
|
+
await this._updateDiffZones();
|
|
398
|
+
}
|
|
399
|
+
async renderChanges(response) {
|
|
400
|
+
await this._updateDiffZones();
|
|
401
|
+
if (response.untitledTextModel && !response.untitledTextModel.isDisposed()) {
|
|
402
|
+
this._previewZone.value.showCreation(this._session.wholeRange.value.getStartPosition().delta(-1), response.untitledTextModel);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
this._previewZone.value.hide();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
hasFocus() {
|
|
409
|
+
return super.hasFocus() || Boolean(this._previewZone.rawValue?.hasFocus()) || ( this._diffZonePool.some(zone => zone.isVisible && zone.hasFocus()));
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
LivePreviewStrategy = ( __decorate([
|
|
413
|
+
( __param(3, IConfigurationService)),
|
|
414
|
+
( __param(4, IStorageService)),
|
|
415
|
+
( __param(5, IBulkEditService)),
|
|
416
|
+
( __param(6, IEditorWorkerService)),
|
|
417
|
+
( __param(7, IInstantiationService))
|
|
418
|
+
], LivePreviewStrategy));
|
|
419
|
+
async function performAsyncTextEdit(model, edit) {
|
|
420
|
+
const [id] = model.deltaDecorations([], [{
|
|
421
|
+
range: edit.range,
|
|
422
|
+
options: {
|
|
423
|
+
description: 'asyncTextEdit',
|
|
424
|
+
stickiness: 0
|
|
425
|
+
}
|
|
426
|
+
}]);
|
|
427
|
+
let first = true;
|
|
428
|
+
for await (const part of edit.newText) {
|
|
429
|
+
if (model.isDisposed()) {
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
const range = model.getDecorationRange(id);
|
|
433
|
+
if (!range) {
|
|
434
|
+
throw new Error('FAILED to perform async replace edit because the anchor decoration was removed');
|
|
435
|
+
}
|
|
436
|
+
const edit = first
|
|
437
|
+
? EditOperation.replace(range, part)
|
|
438
|
+
: EditOperation.insert(range.getEndPosition(), part);
|
|
439
|
+
model.pushEditOperations(null, [edit], () => null);
|
|
440
|
+
first = false;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function asProgressiveEdit(edit, wordsPerSec, token) {
|
|
444
|
+
wordsPerSec = Math.max(10, wordsPerSec);
|
|
445
|
+
const stream = ( new AsyncIterableSource());
|
|
446
|
+
let newText = edit.text ?? '';
|
|
447
|
+
const handle = disposableWindowInterval($window, () => {
|
|
448
|
+
const r = getNWords(newText, 1);
|
|
449
|
+
stream.emitOne(r.value);
|
|
450
|
+
newText = newText.substring(r.value.length);
|
|
451
|
+
if (r.isFullString) {
|
|
452
|
+
handle.dispose();
|
|
453
|
+
stream.resolve();
|
|
454
|
+
d.dispose();
|
|
455
|
+
}
|
|
456
|
+
}, 1000 / wordsPerSec);
|
|
457
|
+
const d = token.onCancellationRequested(() => {
|
|
458
|
+
handle.dispose();
|
|
459
|
+
stream.resolve();
|
|
460
|
+
d.dispose();
|
|
461
|
+
});
|
|
462
|
+
return {
|
|
463
|
+
range: edit.range,
|
|
464
|
+
newText: stream.asyncIterable
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
let LiveStrategy3 = LiveStrategy3_1 = class LiveStrategy3 extends EditModeStrategy {
|
|
468
|
+
constructor(_session, _editor, zone, contextKeyService, _storageService, _bulkEditService, _editorWorkerService, _instaService) {
|
|
469
|
+
super(zone);
|
|
470
|
+
this._session = _session;
|
|
471
|
+
this._editor = _editor;
|
|
472
|
+
this._storageService = _storageService;
|
|
473
|
+
this._bulkEditService = _bulkEditService;
|
|
474
|
+
this._editorWorkerService = _editorWorkerService;
|
|
475
|
+
this._instaService = _instaService;
|
|
476
|
+
this._store = ( new DisposableStore());
|
|
477
|
+
this._sessionStore = ( new DisposableStore());
|
|
478
|
+
this._modifiedRangesThatHaveBeenInteractedWith = [];
|
|
479
|
+
this._editCount = 0;
|
|
480
|
+
this._decoModifiedInteractedWith = ModelDecorationOptions.register({ description: 'inline-chat-modified-interacted-with', stickiness: 0 });
|
|
481
|
+
this._ctxCurrentChangeHasDiff = CTX_INLINE_CHAT_CHANGE_HAS_DIFF.bindTo(contextKeyService);
|
|
482
|
+
this._ctxCurrentChangeShowsDiff = CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF.bindTo(contextKeyService);
|
|
483
|
+
this._modifiedRangesDecorations = this._editor.createDecorationsCollection();
|
|
484
|
+
this._previewZone = ( new Lazy(
|
|
485
|
+
() => _instaService.createInstance(InlineChatFileCreatePreviewWidget, _editor)
|
|
486
|
+
));
|
|
487
|
+
}
|
|
488
|
+
dispose() {
|
|
489
|
+
this._resetDiff();
|
|
490
|
+
this._previewZone.rawValue?.dispose();
|
|
491
|
+
this._store.dispose();
|
|
492
|
+
super.dispose();
|
|
493
|
+
}
|
|
494
|
+
_resetDiff() {
|
|
495
|
+
this._ctxCurrentChangeHasDiff.reset();
|
|
496
|
+
this._ctxCurrentChangeShowsDiff.reset();
|
|
497
|
+
this._sessionStore.clear();
|
|
498
|
+
this._modifiedRangesDecorations.clear();
|
|
499
|
+
this._modifiedRangesThatHaveBeenInteractedWith.length = 0;
|
|
500
|
+
this._zone.widget.updateStatus('');
|
|
501
|
+
}
|
|
502
|
+
async start() {
|
|
503
|
+
this._resetDiff();
|
|
504
|
+
}
|
|
505
|
+
async apply() {
|
|
506
|
+
this._resetDiff();
|
|
507
|
+
if (this._editCount > 0) {
|
|
508
|
+
this._editor.pushUndoStop();
|
|
509
|
+
}
|
|
510
|
+
if (!(this._session.lastExchange?.response instanceof ReplyResponse)) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const { untitledTextModel } = this._session.lastExchange.response;
|
|
514
|
+
if (untitledTextModel && !untitledTextModel.isDisposed() && untitledTextModel.isDirty()) {
|
|
515
|
+
await untitledTextModel.save({ reason: 1 });
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
async cancel() {
|
|
519
|
+
this._resetDiff();
|
|
520
|
+
const { textModelN: modelN, textModelNAltVersion, textModelNSnapshotAltVersion } = this._session;
|
|
521
|
+
if (modelN.isDisposed()) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const targetAltVersion = textModelNSnapshotAltVersion ?? textModelNAltVersion;
|
|
525
|
+
LiveStrategy3_1._undoModelUntil(modelN, targetAltVersion);
|
|
526
|
+
}
|
|
527
|
+
async makeChanges(edits) {
|
|
528
|
+
const cursorStateComputerAndInlineDiffCollection = (undoEdits) => {
|
|
529
|
+
let last = null;
|
|
530
|
+
for (const edit of undoEdits) {
|
|
531
|
+
last = !last || last.isBefore(edit.range.getEndPosition()) ? edit.range.getEndPosition() : last;
|
|
532
|
+
}
|
|
533
|
+
return last && [Selection.fromPositions(last)];
|
|
534
|
+
};
|
|
535
|
+
if (++this._editCount === 1) {
|
|
536
|
+
this._editor.pushUndoStop();
|
|
537
|
+
}
|
|
538
|
+
this._editor.executeEdits('inline-chat-live', edits, cursorStateComputerAndInlineDiffCollection);
|
|
539
|
+
}
|
|
540
|
+
async undoChanges(altVersionId) {
|
|
541
|
+
this._sessionStore.clear();
|
|
542
|
+
this._modifiedRangesDecorations.clear();
|
|
543
|
+
this._modifiedRangesThatHaveBeenInteractedWith.length = 0;
|
|
544
|
+
const { textModelN } = this._session;
|
|
545
|
+
LiveStrategy3_1._undoModelUntil(textModelN, altVersionId);
|
|
546
|
+
}
|
|
547
|
+
async makeProgressiveChanges(edits, opts) {
|
|
548
|
+
if (++this._editCount === 1) {
|
|
549
|
+
this._editor.pushUndoStop();
|
|
550
|
+
}
|
|
551
|
+
const listener = this._session.textModelN.onDidChangeContent(async () => {
|
|
552
|
+
await this._showDiff(false, false);
|
|
553
|
+
});
|
|
554
|
+
try {
|
|
555
|
+
const durationInSec = opts.duration / 1000;
|
|
556
|
+
for (const edit of edits) {
|
|
557
|
+
const wordCount = countWords(edit.text ?? '');
|
|
558
|
+
const speed = wordCount / durationInSec;
|
|
559
|
+
await performAsyncTextEdit(this._session.textModelN, asProgressiveEdit(edit, speed, opts.token));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
finally {
|
|
563
|
+
listener.dispose();
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
async _computeDiff() {
|
|
567
|
+
const diff = await this._editorWorkerService.computeDiff(this._session.textModel0.uri, this._session.textModelN.uri, { ignoreTrimWhitespace: false, maxComputationTimeMs: Number.MAX_SAFE_INTEGER, computeMoves: false }, 'advanced');
|
|
568
|
+
if (!diff || diff.changes.length === 0) {
|
|
569
|
+
return { identical: false, quitEarly: false, changes: [], moves: [] };
|
|
570
|
+
}
|
|
571
|
+
const mergedChanges = [diff.changes[0]];
|
|
572
|
+
for (let i = 1; i < diff.changes.length; i++) {
|
|
573
|
+
const lastChange = mergedChanges[mergedChanges.length - 1];
|
|
574
|
+
const thisChange = diff.changes[i];
|
|
575
|
+
if (thisChange.modified.startLineNumber - lastChange.modified.endLineNumberExclusive <= 5) {
|
|
576
|
+
mergedChanges[mergedChanges.length - 1] = ( new DetailedLineRangeMapping(
|
|
577
|
+
lastChange.original.join(thisChange.original),
|
|
578
|
+
lastChange.modified.join(thisChange.modified),
|
|
579
|
+
(lastChange.innerChanges ?? []).concat(thisChange.innerChanges ?? [])
|
|
580
|
+
));
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
mergedChanges.push(thisChange);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
identical: diff.identical,
|
|
588
|
+
quitEarly: diff.quitEarly,
|
|
589
|
+
changes: mergedChanges,
|
|
590
|
+
moves: []
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
async _showDiff(isFinalChanges, isAfterManualInteraction) {
|
|
594
|
+
const diff = await this._computeDiff();
|
|
595
|
+
this._sessionStore.clear();
|
|
596
|
+
if (diff.identical || diff.changes.length === 0) {
|
|
597
|
+
if (isAfterManualInteraction) {
|
|
598
|
+
this._sessionStore.clear();
|
|
599
|
+
this._onDidDiscard.fire();
|
|
600
|
+
}
|
|
601
|
+
return undefined;
|
|
602
|
+
}
|
|
603
|
+
const viewZoneIds = ( new Set());
|
|
604
|
+
const newDecorations = [];
|
|
605
|
+
const mightContainNonBasicASCII = this._session.textModel0.mightContainNonBasicASCII() ?? false;
|
|
606
|
+
const mightContainRTL = this._session.textModel0.mightContainRTL() ?? false;
|
|
607
|
+
const renderOptions = RenderOptions.fromEditor(this._editor);
|
|
608
|
+
let widgetData;
|
|
609
|
+
for (let i = 0; i < diff.changes.length; i++) {
|
|
610
|
+
const { original, modified, innerChanges } = diff.changes[i];
|
|
611
|
+
const modifiedRange = modified.isEmpty
|
|
612
|
+
? ( new Range(
|
|
613
|
+
modified.startLineNumber,
|
|
614
|
+
1,
|
|
615
|
+
modified.startLineNumber,
|
|
616
|
+
this._session.textModelN.getLineLength(modified.startLineNumber)
|
|
617
|
+
))
|
|
618
|
+
: ( new Range(
|
|
619
|
+
modified.startLineNumber,
|
|
620
|
+
1,
|
|
621
|
+
modified.endLineNumberExclusive - 1,
|
|
622
|
+
this._session.textModelN.getLineLength(modified.endLineNumberExclusive - 1)
|
|
623
|
+
));
|
|
624
|
+
const hasBeenInteractedWith = ( this._modifiedRangesThatHaveBeenInteractedWith.some(id => {
|
|
625
|
+
const range = this._session.textModelN.getDecorationRange(id);
|
|
626
|
+
return range && Range.areIntersecting(range, modifiedRange);
|
|
627
|
+
}));
|
|
628
|
+
if (hasBeenInteractedWith) {
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
if (innerChanges) {
|
|
632
|
+
for (const { modifiedRange } of innerChanges) {
|
|
633
|
+
newDecorations.push({
|
|
634
|
+
range: modifiedRange,
|
|
635
|
+
options: {
|
|
636
|
+
description: 'inline-modified',
|
|
637
|
+
className: 'inline-chat-inserted-range',
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
newDecorations.push({
|
|
641
|
+
range: modifiedRange,
|
|
642
|
+
options: {
|
|
643
|
+
description: 'inline-modified',
|
|
644
|
+
className: 'inline-chat-inserted-range-linehighlight',
|
|
645
|
+
isWholeLine: true
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
const source = ( new LineSource(
|
|
651
|
+
original.mapToLineArray(l => this._session.textModel0.tokenization.getLineTokens(l)),
|
|
652
|
+
[],
|
|
653
|
+
mightContainNonBasicASCII,
|
|
654
|
+
mightContainRTL
|
|
655
|
+
));
|
|
656
|
+
const domNode = document.createElement('div');
|
|
657
|
+
domNode.className = 'inline-chat-original-zone2';
|
|
658
|
+
const result = renderLines(source, renderOptions, [( new InlineDecoration(( new Range(original.startLineNumber, 1, original.startLineNumber, 1)), '', 0 ))], domNode);
|
|
659
|
+
let myViewZoneId = '';
|
|
660
|
+
const myViewZone = {
|
|
661
|
+
afterLineNumber: modifiedRange.startLineNumber - 1,
|
|
662
|
+
heightInLines: result.heightInLines,
|
|
663
|
+
domNode,
|
|
664
|
+
};
|
|
665
|
+
if (isFinalChanges) {
|
|
666
|
+
const [id] = this._modifiedRangesDecorations.append([{ range: modifiedRange, options: this._decoModifiedInteractedWith }]);
|
|
667
|
+
const actions = [
|
|
668
|
+
toAction({
|
|
669
|
+
id: 'accept',
|
|
670
|
+
label: ( localizeWithPath(
|
|
671
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies',
|
|
672
|
+
'accept',
|
|
673
|
+
"Accept"
|
|
674
|
+
)),
|
|
675
|
+
class: ThemeIcon.asClassName(Codicon.check),
|
|
676
|
+
run: () => {
|
|
677
|
+
this._modifiedRangesThatHaveBeenInteractedWith.push(id);
|
|
678
|
+
return this._showDiff(true, true);
|
|
679
|
+
}
|
|
680
|
+
}),
|
|
681
|
+
toAction({
|
|
682
|
+
id: 'discard',
|
|
683
|
+
label: ( localizeWithPath(
|
|
684
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies',
|
|
685
|
+
'discard',
|
|
686
|
+
"Discard"
|
|
687
|
+
)),
|
|
688
|
+
class: ThemeIcon.asClassName(Codicon.discard),
|
|
689
|
+
run: () => {
|
|
690
|
+
const edits = [];
|
|
691
|
+
for (const innerChange of innerChanges) {
|
|
692
|
+
const originalValue = this._session.textModel0.getValueInRange(innerChange.originalRange);
|
|
693
|
+
edits.push(EditOperation.replace(innerChange.modifiedRange, originalValue));
|
|
694
|
+
}
|
|
695
|
+
this._session.textModelN.pushEditOperations(null, edits, () => null);
|
|
696
|
+
return this._showDiff(true, true);
|
|
697
|
+
}
|
|
698
|
+
}),
|
|
699
|
+
];
|
|
700
|
+
const toggleDiff = !original.isEmpty
|
|
701
|
+
? () => {
|
|
702
|
+
const scrollState = StableEditorScrollState.capture(this._editor);
|
|
703
|
+
if (!( viewZoneIds.has(myViewZoneId))) {
|
|
704
|
+
this._editor.changeViewZones(accessor => {
|
|
705
|
+
myViewZoneId = accessor.addZone(myViewZone);
|
|
706
|
+
viewZoneIds.add(myViewZoneId);
|
|
707
|
+
});
|
|
708
|
+
this._ctxCurrentChangeShowsDiff.set(true);
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
this._editor.changeViewZones(accessor => {
|
|
712
|
+
accessor.removeZone(myViewZoneId);
|
|
713
|
+
viewZoneIds.delete(myViewZoneId);
|
|
714
|
+
});
|
|
715
|
+
this._ctxCurrentChangeShowsDiff.set(false);
|
|
716
|
+
}
|
|
717
|
+
scrollState.restore(this._editor);
|
|
718
|
+
}
|
|
719
|
+
: undefined;
|
|
720
|
+
const zoneLineNumber = this._zone.position.lineNumber;
|
|
721
|
+
const myDistance = zoneLineNumber <= modifiedRange.startLineNumber
|
|
722
|
+
? modifiedRange.startLineNumber - zoneLineNumber
|
|
723
|
+
: zoneLineNumber - modifiedRange.endLineNumber;
|
|
724
|
+
if (!widgetData || widgetData.distance > myDistance) {
|
|
725
|
+
widgetData = { distance: myDistance, position: modifiedRange.getStartPosition().delta(-1), index: i, actions, toggleDiff };
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
if (widgetData) {
|
|
730
|
+
this._zone.widget.setExtraButtons(widgetData.actions);
|
|
731
|
+
this._zone.updatePositionAndHeight(widgetData.position);
|
|
732
|
+
this._editor.revealPositionInCenterIfOutsideViewport(widgetData.position);
|
|
733
|
+
this._updateSummaryMessage(diff.changes, widgetData.index);
|
|
734
|
+
this._ctxCurrentChangeHasDiff.set(Boolean(widgetData.toggleDiff));
|
|
735
|
+
this.toggleDiff = widgetData.toggleDiff;
|
|
736
|
+
}
|
|
737
|
+
const decorations = this._editor.createDecorationsCollection(newDecorations);
|
|
738
|
+
this._sessionStore.add(toDisposable(() => {
|
|
739
|
+
decorations.clear();
|
|
740
|
+
this._editor.changeViewZones(accessor => viewZoneIds.forEach(accessor.removeZone, accessor));
|
|
741
|
+
viewZoneIds.clear();
|
|
742
|
+
this._zone.widget.setExtraButtons([]);
|
|
743
|
+
}));
|
|
744
|
+
if (isAfterManualInteraction && newDecorations.length === 0) {
|
|
745
|
+
this._sessionStore.clear();
|
|
746
|
+
this._onDidAccept.fire();
|
|
747
|
+
}
|
|
748
|
+
return widgetData?.position;
|
|
749
|
+
}
|
|
750
|
+
async renderChanges(response) {
|
|
751
|
+
if (response.untitledTextModel && !response.untitledTextModel.isDisposed()) {
|
|
752
|
+
this._previewZone.value.showCreation(this._session.wholeRange.value.getStartPosition().delta(-1), response.untitledTextModel);
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
this._previewZone.value.hide();
|
|
756
|
+
}
|
|
757
|
+
return await this._showDiff(true, false);
|
|
758
|
+
}
|
|
759
|
+
static _undoModelUntil(model, targetAltVersion) {
|
|
760
|
+
while (targetAltVersion < model.getAlternativeVersionId() && model.canUndo()) {
|
|
761
|
+
model.undo();
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
_updateSummaryMessage(mappings, index) {
|
|
765
|
+
const changesCount = mappings.length;
|
|
766
|
+
let message;
|
|
767
|
+
if (changesCount === 0) {
|
|
768
|
+
message = ( localizeWithPath(
|
|
769
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies',
|
|
770
|
+
'change.0',
|
|
771
|
+
"Nothing changed"
|
|
772
|
+
));
|
|
773
|
+
}
|
|
774
|
+
else if (changesCount === 1) {
|
|
775
|
+
message = ( localizeWithPath(
|
|
776
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies',
|
|
777
|
+
'change.1',
|
|
778
|
+
"1 change"
|
|
779
|
+
));
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
message = ( localizeWithPath(
|
|
783
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies',
|
|
784
|
+
'lines.NM',
|
|
785
|
+
"{1} changes",
|
|
786
|
+
index + 1,
|
|
787
|
+
changesCount
|
|
788
|
+
));
|
|
789
|
+
}
|
|
790
|
+
this._zone.widget.updateStatus(message);
|
|
791
|
+
}
|
|
792
|
+
needsMargin() {
|
|
793
|
+
return true;
|
|
794
|
+
}
|
|
795
|
+
hasFocus() {
|
|
796
|
+
return this._zone.widget.hasFocus();
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
LiveStrategy3 = LiveStrategy3_1 = ( __decorate([
|
|
800
|
+
( __param(3, IContextKeyService)),
|
|
801
|
+
( __param(4, IStorageService)),
|
|
802
|
+
( __param(5, IBulkEditService)),
|
|
803
|
+
( __param(6, IEditorWorkerService)),
|
|
804
|
+
( __param(7, IInstantiationService))
|
|
805
|
+
], LiveStrategy3));
|
|
806
|
+
export { EditModeStrategy, LivePreviewStrategy, LiveStrategy, LiveStrategy3, PreviewStrategy, asProgressiveEdit, performAsyncTextEdit };
|