@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,808 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { groupBy } from 'monaco-editor/esm/vs/base/common/collections.js';
|
|
3
|
+
import { onUnexpectedError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
4
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
5
|
+
import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
6
|
+
import { clamp } from 'monaco-editor/esm/vs/base/common/numbers.js';
|
|
7
|
+
import * as strings from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
8
|
+
import { ResourceTextEdit, IBulkEditService } from 'monaco-editor/esm/vs/editor/browser/services/bulkEditService.js';
|
|
9
|
+
import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
|
|
10
|
+
import { SingleModelEditStackElement, MultiModelEditStackElement } from 'monaco-editor/esm/vs/editor/common/model/editStack.js';
|
|
11
|
+
import { IntervalNode, IntervalTree } from 'monaco-editor/esm/vs/editor/common/model/intervalTree.js';
|
|
12
|
+
import { ModelDecorationOptions } from 'monaco-editor/esm/vs/editor/common/model/textModel.js';
|
|
13
|
+
import { ITextModelService } from 'monaco-editor/esm/vs/editor/common/services/resolverService.js';
|
|
14
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
15
|
+
import { IUndoRedoService } from 'monaco-editor/esm/vs/platform/undoRedo/common/undoRedo.js';
|
|
16
|
+
import { CellEditState } from '../notebookBrowser.js';
|
|
17
|
+
import { NotebookCellSelectionCollection } from './cellSelectionCollection.js';
|
|
18
|
+
import { CodeCellViewModel } from './codeCellViewModel.js';
|
|
19
|
+
import { MarkupCellViewModel } from './markupCellViewModel.js';
|
|
20
|
+
import { NotebookCellsChangeType, CellKind, SelectionStateType } from '../../common/notebookCommon.js';
|
|
21
|
+
import { cellRangesToIndexes, cellIndexesToRanges, reduceCellRanges } from '../../common/notebookRange.js';
|
|
22
|
+
import { NotebookMetadataChangedEvent } from '../notebookViewEvents.js';
|
|
23
|
+
import { CellFindMatchModel } from '../contrib/find/findModel.js';
|
|
24
|
+
import { NotebookExecutionType, INotebookExecutionStateService } from '../../common/notebookExecutionStateService.js';
|
|
25
|
+
const invalidFunc = () => { throw new Error(`Invalid change accessor`); };
|
|
26
|
+
class DecorationsTree {
|
|
27
|
+
constructor() {
|
|
28
|
+
this._decorationsTree = ( new IntervalTree());
|
|
29
|
+
}
|
|
30
|
+
intervalSearch(start, end, filterOwnerId, filterOutValidation, cachedVersionId, onlyMarginDecorations = false) {
|
|
31
|
+
const r1 = this._decorationsTree.intervalSearch(start, end, filterOwnerId, filterOutValidation, cachedVersionId, onlyMarginDecorations);
|
|
32
|
+
return r1;
|
|
33
|
+
}
|
|
34
|
+
search(filterOwnerId, filterOutValidation, overviewRulerOnly, cachedVersionId, onlyMarginDecorations) {
|
|
35
|
+
return this._decorationsTree.search(filterOwnerId, filterOutValidation, cachedVersionId, onlyMarginDecorations);
|
|
36
|
+
}
|
|
37
|
+
collectNodesFromOwner(ownerId) {
|
|
38
|
+
const r1 = this._decorationsTree.collectNodesFromOwner(ownerId);
|
|
39
|
+
return r1;
|
|
40
|
+
}
|
|
41
|
+
collectNodesPostOrder() {
|
|
42
|
+
const r1 = this._decorationsTree.collectNodesPostOrder();
|
|
43
|
+
return r1;
|
|
44
|
+
}
|
|
45
|
+
insert(node) {
|
|
46
|
+
this._decorationsTree.insert(node);
|
|
47
|
+
}
|
|
48
|
+
delete(node) {
|
|
49
|
+
this._decorationsTree.delete(node);
|
|
50
|
+
}
|
|
51
|
+
resolveNode(node, cachedVersionId) {
|
|
52
|
+
this._decorationsTree.resolveNode(node, cachedVersionId);
|
|
53
|
+
}
|
|
54
|
+
acceptReplace(offset, length, textLength, forceMoveMarkers) {
|
|
55
|
+
this._decorationsTree.acceptReplace(offset, length, textLength, forceMoveMarkers);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const TRACKED_RANGE_OPTIONS = [
|
|
59
|
+
ModelDecorationOptions.register({ description: 'notebook-view-model-tracked-range-always-grows-when-typing-at-edges', stickiness: 0 }),
|
|
60
|
+
ModelDecorationOptions.register({ description: 'notebook-view-model-tracked-range-never-grows-when-typing-at-edges', stickiness: 1 }),
|
|
61
|
+
ModelDecorationOptions.register({ description: 'notebook-view-model-tracked-range-grows-only-when-typing-before', stickiness: 2 }),
|
|
62
|
+
ModelDecorationOptions.register({ description: 'notebook-view-model-tracked-range-grows-only-when-typing-after', stickiness: 3 }),
|
|
63
|
+
];
|
|
64
|
+
function _normalizeOptions(options) {
|
|
65
|
+
if (options instanceof ModelDecorationOptions) {
|
|
66
|
+
return options;
|
|
67
|
+
}
|
|
68
|
+
return ModelDecorationOptions.createDynamic(options);
|
|
69
|
+
}
|
|
70
|
+
let MODEL_ID = 0;
|
|
71
|
+
let NotebookViewModel = class NotebookViewModel extends Disposable {
|
|
72
|
+
get options() { return this._options; }
|
|
73
|
+
get onDidChangeOptions() { return this._onDidChangeOptions.event; }
|
|
74
|
+
get viewCells() {
|
|
75
|
+
return this._viewCells;
|
|
76
|
+
}
|
|
77
|
+
set viewCells(_) {
|
|
78
|
+
throw new Error('NotebookViewModel.viewCells is readonly');
|
|
79
|
+
}
|
|
80
|
+
get length() {
|
|
81
|
+
return this._viewCells.length;
|
|
82
|
+
}
|
|
83
|
+
get notebookDocument() {
|
|
84
|
+
return this._notebook;
|
|
85
|
+
}
|
|
86
|
+
get uri() {
|
|
87
|
+
return this._notebook.uri;
|
|
88
|
+
}
|
|
89
|
+
get metadata() {
|
|
90
|
+
return this._notebook.metadata;
|
|
91
|
+
}
|
|
92
|
+
get onDidChangeViewCells() { return this._onDidChangeViewCells.event; }
|
|
93
|
+
get lastNotebookEditResource() {
|
|
94
|
+
if (this._lastNotebookEditResource.length) {
|
|
95
|
+
return this._lastNotebookEditResource[this._lastNotebookEditResource.length - 1];
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
get layoutInfo() {
|
|
100
|
+
return this._layoutInfo;
|
|
101
|
+
}
|
|
102
|
+
get onDidChangeSelection() { return this._onDidChangeSelection.event; }
|
|
103
|
+
get selectionHandles() {
|
|
104
|
+
const handlesSet = ( new Set());
|
|
105
|
+
const handles = [];
|
|
106
|
+
( cellRangesToIndexes(this._selectionCollection.selections).map(index => index < this.length ? this.cellAt(index) : undefined)).forEach(cell => {
|
|
107
|
+
if (cell && !( handlesSet.has(cell.handle))) {
|
|
108
|
+
handles.push(cell.handle);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return handles;
|
|
112
|
+
}
|
|
113
|
+
set selectionHandles(selectionHandles) {
|
|
114
|
+
const indexes = ( selectionHandles.map(handle => this._viewCells.findIndex(cell => cell.handle === handle)));
|
|
115
|
+
this._selectionCollection.setSelections(cellIndexesToRanges(indexes), true, 'model');
|
|
116
|
+
}
|
|
117
|
+
get focused() {
|
|
118
|
+
return this._focused;
|
|
119
|
+
}
|
|
120
|
+
constructor(viewType, _notebook, _viewContext, _layoutInfo, _options, _instantiationService, _bulkEditService, _undoService, _textModelService, notebookExecutionStateService) {
|
|
121
|
+
super();
|
|
122
|
+
this.viewType = viewType;
|
|
123
|
+
this._notebook = _notebook;
|
|
124
|
+
this._viewContext = _viewContext;
|
|
125
|
+
this._layoutInfo = _layoutInfo;
|
|
126
|
+
this._options = _options;
|
|
127
|
+
this._instantiationService = _instantiationService;
|
|
128
|
+
this._bulkEditService = _bulkEditService;
|
|
129
|
+
this._undoService = _undoService;
|
|
130
|
+
this._textModelService = _textModelService;
|
|
131
|
+
this._localStore = this._register(( new DisposableStore()));
|
|
132
|
+
this._handleToViewCellMapping = ( new Map());
|
|
133
|
+
this._onDidChangeOptions = this._register(( new Emitter()));
|
|
134
|
+
this._viewCells = [];
|
|
135
|
+
this._onDidChangeViewCells = this._register(( new Emitter()));
|
|
136
|
+
this._lastNotebookEditResource = [];
|
|
137
|
+
this._onDidChangeSelection = this._register(( new Emitter()));
|
|
138
|
+
this._selectionCollection = this._register(( new NotebookCellSelectionCollection()));
|
|
139
|
+
this._decorationsTree = ( new DecorationsTree());
|
|
140
|
+
this._decorations = Object.create(null);
|
|
141
|
+
this._lastDecorationId = 0;
|
|
142
|
+
this._foldingRanges = null;
|
|
143
|
+
this._hiddenRanges = [];
|
|
144
|
+
this._focused = true;
|
|
145
|
+
this._decorationIdToCellMap = ( new Map());
|
|
146
|
+
this._statusBarItemIdToCellMap = ( new Map());
|
|
147
|
+
MODEL_ID++;
|
|
148
|
+
this.id = '$notebookViewModel' + MODEL_ID;
|
|
149
|
+
this._instanceId = strings.singleLetterHash(MODEL_ID);
|
|
150
|
+
const compute = (changes, synchronous) => {
|
|
151
|
+
const diffs = ( changes.map(splice => {
|
|
152
|
+
return [splice[0], splice[1], ( splice[2].map(cell => {
|
|
153
|
+
return createCellViewModel(this._instantiationService, this, cell, this._viewContext);
|
|
154
|
+
}))];
|
|
155
|
+
}));
|
|
156
|
+
diffs.reverse().forEach(diff => {
|
|
157
|
+
const deletedCells = this._viewCells.splice(diff[0], diff[1], ...diff[2]);
|
|
158
|
+
this._decorationsTree.acceptReplace(diff[0], diff[1], diff[2].length, true);
|
|
159
|
+
deletedCells.forEach(cell => {
|
|
160
|
+
this._handleToViewCellMapping.delete(cell.handle);
|
|
161
|
+
cell.dispose();
|
|
162
|
+
});
|
|
163
|
+
diff[2].forEach(cell => {
|
|
164
|
+
this._handleToViewCellMapping.set(cell.handle, cell);
|
|
165
|
+
this._localStore.add(cell);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
const selectionHandles = this.selectionHandles;
|
|
169
|
+
this._onDidChangeViewCells.fire({
|
|
170
|
+
synchronous: synchronous,
|
|
171
|
+
splices: diffs
|
|
172
|
+
});
|
|
173
|
+
let endSelectionHandles = [];
|
|
174
|
+
if (selectionHandles.length) {
|
|
175
|
+
const primaryHandle = selectionHandles[0];
|
|
176
|
+
const primarySelectionIndex = this._viewCells.indexOf(this.getCellByHandle(primaryHandle));
|
|
177
|
+
endSelectionHandles = [primaryHandle];
|
|
178
|
+
let delta = 0;
|
|
179
|
+
for (let i = 0; i < diffs.length; i++) {
|
|
180
|
+
const diff = diffs[0];
|
|
181
|
+
if (diff[0] + diff[1] <= primarySelectionIndex) {
|
|
182
|
+
delta += diff[2].length - diff[1];
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (diff[0] > primarySelectionIndex) {
|
|
186
|
+
endSelectionHandles = [primaryHandle];
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
if (diff[0] + diff[1] > primarySelectionIndex) {
|
|
190
|
+
endSelectionHandles = [this._viewCells[diff[0] + delta].handle];
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const selectionIndexes = ( endSelectionHandles.map(handle => this._viewCells.findIndex(cell => cell.handle === handle)));
|
|
196
|
+
this._selectionCollection.setState(cellIndexesToRanges([selectionIndexes[0]])[0], cellIndexesToRanges(selectionIndexes), true, 'model');
|
|
197
|
+
};
|
|
198
|
+
this._register(this._notebook.onDidChangeContent(e => {
|
|
199
|
+
for (let i = 0; i < e.rawEvents.length; i++) {
|
|
200
|
+
const change = e.rawEvents[i];
|
|
201
|
+
let changes = [];
|
|
202
|
+
const synchronous = e.synchronous ?? true;
|
|
203
|
+
if (change.kind === NotebookCellsChangeType.ModelChange || change.kind === NotebookCellsChangeType.Initialize) {
|
|
204
|
+
changes = change.changes;
|
|
205
|
+
compute(changes, synchronous);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
else if (change.kind === NotebookCellsChangeType.Move) {
|
|
209
|
+
compute([[change.index, change.length, []]], synchronous);
|
|
210
|
+
compute([[change.newIdx, 0, change.cells]], synchronous);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}));
|
|
217
|
+
this._register(this._notebook.onDidChangeContent(contentChanges => {
|
|
218
|
+
contentChanges.rawEvents.forEach(e => {
|
|
219
|
+
if (e.kind === NotebookCellsChangeType.ChangeDocumentMetadata) {
|
|
220
|
+
this._viewContext.eventDispatcher.emit([( new NotebookMetadataChangedEvent(this._notebook.metadata))]);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
if (contentChanges.endSelectionState) {
|
|
224
|
+
this.updateSelectionsState(contentChanges.endSelectionState);
|
|
225
|
+
}
|
|
226
|
+
}));
|
|
227
|
+
this._register(this._viewContext.eventDispatcher.onDidChangeLayout((e) => {
|
|
228
|
+
this._layoutInfo = e.value;
|
|
229
|
+
this._viewCells.forEach(cell => {
|
|
230
|
+
if (cell.cellKind === CellKind.Markup) {
|
|
231
|
+
if (e.source.width || e.source.fontInfo) {
|
|
232
|
+
cell.layoutChange({ outerWidth: e.value.width, font: e.value.fontInfo });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
if (e.source.width !== undefined) {
|
|
237
|
+
cell.layoutChange({ outerWidth: e.value.width, font: e.value.fontInfo });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}));
|
|
242
|
+
this._register(this._viewContext.notebookOptions.onDidChangeOptions(e => {
|
|
243
|
+
for (let i = 0; i < this.length; i++) {
|
|
244
|
+
const cell = this._viewCells[i];
|
|
245
|
+
cell.updateOptions(e);
|
|
246
|
+
}
|
|
247
|
+
}));
|
|
248
|
+
this._register(notebookExecutionStateService.onDidChangeExecution(e => {
|
|
249
|
+
if (e.type !== NotebookExecutionType.cell) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const cell = this.getCellByHandle(e.cellHandle);
|
|
253
|
+
if (cell instanceof CodeCellViewModel) {
|
|
254
|
+
cell.updateExecutionState(e);
|
|
255
|
+
}
|
|
256
|
+
}));
|
|
257
|
+
this._register(this._selectionCollection.onDidChangeSelection(e => {
|
|
258
|
+
this._onDidChangeSelection.fire(e);
|
|
259
|
+
}));
|
|
260
|
+
this._viewCells = ( this._notebook.cells.map(cell => {
|
|
261
|
+
return createCellViewModel(this._instantiationService, this, cell, this._viewContext);
|
|
262
|
+
}));
|
|
263
|
+
this._viewCells.forEach(cell => {
|
|
264
|
+
this._handleToViewCellMapping.set(cell.handle, cell);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
updateOptions(newOptions) {
|
|
268
|
+
this._options = { ...this._options, ...newOptions };
|
|
269
|
+
this._onDidChangeOptions.fire();
|
|
270
|
+
}
|
|
271
|
+
getFocus() {
|
|
272
|
+
return this._selectionCollection.focus;
|
|
273
|
+
}
|
|
274
|
+
getSelections() {
|
|
275
|
+
return this._selectionCollection.selections;
|
|
276
|
+
}
|
|
277
|
+
setEditorFocus(focused) {
|
|
278
|
+
this._focused = focused;
|
|
279
|
+
}
|
|
280
|
+
validateRange(cellRange) {
|
|
281
|
+
if (!cellRange) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
const start = clamp(cellRange.start, 0, this.length);
|
|
285
|
+
const end = clamp(cellRange.end, 0, this.length);
|
|
286
|
+
if (start === end) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
if (start < end) {
|
|
290
|
+
return { start, end };
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
return { start: end, end: start };
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
updateSelectionsState(state, source = 'model') {
|
|
297
|
+
if (this._focused || source === 'model') {
|
|
298
|
+
if (state.kind === SelectionStateType.Handle) {
|
|
299
|
+
const primaryIndex = state.primary !== null ? this.getCellIndexByHandle(state.primary) : null;
|
|
300
|
+
const primarySelection = primaryIndex !== null ? this.validateRange({ start: primaryIndex, end: primaryIndex + 1 }) : null;
|
|
301
|
+
const selections = ( cellIndexesToRanges(( state.selections.map(sel => this.getCellIndexByHandle(sel))))
|
|
302
|
+
.map(range => this.validateRange(range)))
|
|
303
|
+
.filter(range => range !== null);
|
|
304
|
+
this._selectionCollection.setState(primarySelection, reduceCellRanges(selections), true, source);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
const primarySelection = this.validateRange(state.focus);
|
|
308
|
+
const selections = ( state.selections
|
|
309
|
+
.map(range => this.validateRange(range)))
|
|
310
|
+
.filter(range => range !== null);
|
|
311
|
+
this._selectionCollection.setState(primarySelection, reduceCellRanges(selections), true, source);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
getFoldingStartIndex(index) {
|
|
316
|
+
if (!this._foldingRanges) {
|
|
317
|
+
return -1;
|
|
318
|
+
}
|
|
319
|
+
const range = this._foldingRanges.findRange(index + 1);
|
|
320
|
+
const startIndex = this._foldingRanges.getStartLineNumber(range) - 1;
|
|
321
|
+
return startIndex;
|
|
322
|
+
}
|
|
323
|
+
getFoldingState(index) {
|
|
324
|
+
if (!this._foldingRanges) {
|
|
325
|
+
return 0 ;
|
|
326
|
+
}
|
|
327
|
+
const range = this._foldingRanges.findRange(index + 1);
|
|
328
|
+
const startIndex = this._foldingRanges.getStartLineNumber(range) - 1;
|
|
329
|
+
if (startIndex !== index) {
|
|
330
|
+
return 0 ;
|
|
331
|
+
}
|
|
332
|
+
return this._foldingRanges.isCollapsed(range) ? 2 : 1 ;
|
|
333
|
+
}
|
|
334
|
+
getFoldedLength(index) {
|
|
335
|
+
if (!this._foldingRanges) {
|
|
336
|
+
return 0;
|
|
337
|
+
}
|
|
338
|
+
const range = this._foldingRanges.findRange(index + 1);
|
|
339
|
+
const startIndex = this._foldingRanges.getStartLineNumber(range) - 1;
|
|
340
|
+
const endIndex = this._foldingRanges.getEndLineNumber(range) - 1;
|
|
341
|
+
return endIndex - startIndex;
|
|
342
|
+
}
|
|
343
|
+
updateFoldingRanges(ranges) {
|
|
344
|
+
this._foldingRanges = ranges;
|
|
345
|
+
let updateHiddenAreas = false;
|
|
346
|
+
const newHiddenAreas = [];
|
|
347
|
+
let i = 0;
|
|
348
|
+
let k = 0;
|
|
349
|
+
let lastCollapsedStart = Number.MAX_VALUE;
|
|
350
|
+
let lastCollapsedEnd = -1;
|
|
351
|
+
for (; i < ranges.length; i++) {
|
|
352
|
+
if (!ranges.isCollapsed(i)) {
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
const startLineNumber = ranges.getStartLineNumber(i) + 1;
|
|
356
|
+
const endLineNumber = ranges.getEndLineNumber(i);
|
|
357
|
+
if (lastCollapsedStart <= startLineNumber && endLineNumber <= lastCollapsedEnd) {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (!updateHiddenAreas && k < this._hiddenRanges.length && this._hiddenRanges[k].start + 1 === startLineNumber && (this._hiddenRanges[k].end + 1) === endLineNumber) {
|
|
361
|
+
newHiddenAreas.push(this._hiddenRanges[k]);
|
|
362
|
+
k++;
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
updateHiddenAreas = true;
|
|
366
|
+
newHiddenAreas.push({ start: startLineNumber - 1, end: endLineNumber - 1 });
|
|
367
|
+
}
|
|
368
|
+
lastCollapsedStart = startLineNumber;
|
|
369
|
+
lastCollapsedEnd = endLineNumber;
|
|
370
|
+
}
|
|
371
|
+
if (updateHiddenAreas || k < this._hiddenRanges.length) {
|
|
372
|
+
this._hiddenRanges = newHiddenAreas;
|
|
373
|
+
}
|
|
374
|
+
this._viewCells.forEach(cell => {
|
|
375
|
+
if (cell.cellKind === CellKind.Markup) {
|
|
376
|
+
cell.triggerFoldingStateChange();
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
getHiddenRanges() {
|
|
381
|
+
return this._hiddenRanges;
|
|
382
|
+
}
|
|
383
|
+
getCellByHandle(handle) {
|
|
384
|
+
return this._handleToViewCellMapping.get(handle);
|
|
385
|
+
}
|
|
386
|
+
getCellIndexByHandle(handle) {
|
|
387
|
+
return this._viewCells.findIndex(cell => cell.handle === handle);
|
|
388
|
+
}
|
|
389
|
+
getCellIndex(cell) {
|
|
390
|
+
return this._viewCells.indexOf(cell);
|
|
391
|
+
}
|
|
392
|
+
cellAt(index) {
|
|
393
|
+
return this._viewCells[index];
|
|
394
|
+
}
|
|
395
|
+
getCellsInRange(range) {
|
|
396
|
+
if (!range) {
|
|
397
|
+
return this._viewCells.slice(0);
|
|
398
|
+
}
|
|
399
|
+
const validatedRange = this.validateRange(range);
|
|
400
|
+
if (validatedRange) {
|
|
401
|
+
const result = [];
|
|
402
|
+
for (let i = validatedRange.start; i < validatedRange.end; i++) {
|
|
403
|
+
result.push(this._viewCells[i]);
|
|
404
|
+
}
|
|
405
|
+
return result;
|
|
406
|
+
}
|
|
407
|
+
return [];
|
|
408
|
+
}
|
|
409
|
+
getNearestVisibleCellIndexUpwards(index) {
|
|
410
|
+
for (let i = this._hiddenRanges.length - 1; i >= 0; i--) {
|
|
411
|
+
const cellRange = this._hiddenRanges[i];
|
|
412
|
+
const foldStart = cellRange.start - 1;
|
|
413
|
+
const foldEnd = cellRange.end;
|
|
414
|
+
if (foldStart > index) {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (foldStart <= index && foldEnd >= index) {
|
|
418
|
+
return index;
|
|
419
|
+
}
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
return index;
|
|
423
|
+
}
|
|
424
|
+
getNextVisibleCellIndex(index) {
|
|
425
|
+
for (let i = 0; i < this._hiddenRanges.length; i++) {
|
|
426
|
+
const cellRange = this._hiddenRanges[i];
|
|
427
|
+
const foldStart = cellRange.start - 1;
|
|
428
|
+
const foldEnd = cellRange.end;
|
|
429
|
+
if (foldEnd < index) {
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
if (foldStart <= index) {
|
|
433
|
+
return foldEnd + 1;
|
|
434
|
+
}
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
return index + 1;
|
|
438
|
+
}
|
|
439
|
+
getPreviousVisibleCellIndex(index) {
|
|
440
|
+
for (let i = this._hiddenRanges.length - 1; i >= 0; i--) {
|
|
441
|
+
const cellRange = this._hiddenRanges[i];
|
|
442
|
+
const foldStart = cellRange.start - 1;
|
|
443
|
+
const foldEnd = cellRange.end;
|
|
444
|
+
if (foldEnd < index) {
|
|
445
|
+
return index;
|
|
446
|
+
}
|
|
447
|
+
if (foldStart <= index) {
|
|
448
|
+
return foldStart;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return index;
|
|
452
|
+
}
|
|
453
|
+
hasCell(cell) {
|
|
454
|
+
return ( this._handleToViewCellMapping.has(cell.handle));
|
|
455
|
+
}
|
|
456
|
+
getVersionId() {
|
|
457
|
+
return this._notebook.versionId;
|
|
458
|
+
}
|
|
459
|
+
getAlternativeId() {
|
|
460
|
+
return this._notebook.alternativeVersionId;
|
|
461
|
+
}
|
|
462
|
+
getTrackedRange(id) {
|
|
463
|
+
return this._getDecorationRange(id);
|
|
464
|
+
}
|
|
465
|
+
_getDecorationRange(decorationId) {
|
|
466
|
+
const node = this._decorations[decorationId];
|
|
467
|
+
if (!node) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
const versionId = this.getVersionId();
|
|
471
|
+
if (node.cachedVersionId !== versionId) {
|
|
472
|
+
this._decorationsTree.resolveNode(node, versionId);
|
|
473
|
+
}
|
|
474
|
+
if (node.range === null) {
|
|
475
|
+
return { start: node.cachedAbsoluteStart - 1, end: node.cachedAbsoluteEnd - 1 };
|
|
476
|
+
}
|
|
477
|
+
return { start: node.range.startLineNumber - 1, end: node.range.endLineNumber - 1 };
|
|
478
|
+
}
|
|
479
|
+
setTrackedRange(id, newRange, newStickiness) {
|
|
480
|
+
const node = (id ? this._decorations[id] : null);
|
|
481
|
+
if (!node) {
|
|
482
|
+
if (!newRange) {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
return this._deltaCellDecorationsImpl(0, [], [{ range: ( new Range(newRange.start + 1, 1, newRange.end + 1, 1)), options: TRACKED_RANGE_OPTIONS[newStickiness] }])[0];
|
|
486
|
+
}
|
|
487
|
+
if (!newRange) {
|
|
488
|
+
this._decorationsTree.delete(node);
|
|
489
|
+
delete this._decorations[node.id];
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
this._decorationsTree.delete(node);
|
|
493
|
+
node.reset(this.getVersionId(), newRange.start, newRange.end + 1, ( new Range(newRange.start + 1, 1, newRange.end + 1, 1)));
|
|
494
|
+
node.setOptions(TRACKED_RANGE_OPTIONS[newStickiness]);
|
|
495
|
+
this._decorationsTree.insert(node);
|
|
496
|
+
return node.id;
|
|
497
|
+
}
|
|
498
|
+
_deltaCellDecorationsImpl(ownerId, oldDecorationsIds, newDecorations) {
|
|
499
|
+
const versionId = this.getVersionId();
|
|
500
|
+
const oldDecorationsLen = oldDecorationsIds.length;
|
|
501
|
+
let oldDecorationIndex = 0;
|
|
502
|
+
const newDecorationsLen = newDecorations.length;
|
|
503
|
+
let newDecorationIndex = 0;
|
|
504
|
+
const result = ( new Array(newDecorationsLen));
|
|
505
|
+
while (oldDecorationIndex < oldDecorationsLen || newDecorationIndex < newDecorationsLen) {
|
|
506
|
+
let node = null;
|
|
507
|
+
if (oldDecorationIndex < oldDecorationsLen) {
|
|
508
|
+
do {
|
|
509
|
+
node = this._decorations[oldDecorationsIds[oldDecorationIndex++]];
|
|
510
|
+
} while (!node && oldDecorationIndex < oldDecorationsLen);
|
|
511
|
+
if (node) {
|
|
512
|
+
this._decorationsTree.delete(node);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
if (newDecorationIndex < newDecorationsLen) {
|
|
516
|
+
if (!node) {
|
|
517
|
+
const internalDecorationId = (++this._lastDecorationId);
|
|
518
|
+
const decorationId = `${this._instanceId};${internalDecorationId}`;
|
|
519
|
+
node = ( new IntervalNode(decorationId, 0, 0));
|
|
520
|
+
this._decorations[decorationId] = node;
|
|
521
|
+
}
|
|
522
|
+
const newDecoration = newDecorations[newDecorationIndex];
|
|
523
|
+
const range = newDecoration.range;
|
|
524
|
+
const options = _normalizeOptions(newDecoration.options);
|
|
525
|
+
node.ownerId = ownerId;
|
|
526
|
+
node.reset(versionId, range.startLineNumber, range.endLineNumber, Range.lift(range));
|
|
527
|
+
node.setOptions(options);
|
|
528
|
+
this._decorationsTree.insert(node);
|
|
529
|
+
result[newDecorationIndex] = node.id;
|
|
530
|
+
newDecorationIndex++;
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
if (node) {
|
|
534
|
+
delete this._decorations[node.id];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return result;
|
|
539
|
+
}
|
|
540
|
+
deltaCellDecorations(oldDecorations, newDecorations) {
|
|
541
|
+
oldDecorations.forEach(id => {
|
|
542
|
+
const handle = this._decorationIdToCellMap.get(id);
|
|
543
|
+
if (handle !== undefined) {
|
|
544
|
+
const cell = this.getCellByHandle(handle);
|
|
545
|
+
cell?.deltaCellDecorations([id], []);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
const result = [];
|
|
549
|
+
newDecorations.forEach(decoration => {
|
|
550
|
+
const cell = this.getCellByHandle(decoration.handle);
|
|
551
|
+
const ret = cell?.deltaCellDecorations([], [decoration.options]) || [];
|
|
552
|
+
ret.forEach(id => {
|
|
553
|
+
this._decorationIdToCellMap.set(id, decoration.handle);
|
|
554
|
+
});
|
|
555
|
+
result.push(...ret);
|
|
556
|
+
});
|
|
557
|
+
return result;
|
|
558
|
+
}
|
|
559
|
+
deltaCellStatusBarItems(oldItems, newItems) {
|
|
560
|
+
const deletesByHandle = groupBy(oldItems, id => this._statusBarItemIdToCellMap.get(id) ?? -1);
|
|
561
|
+
const result = [];
|
|
562
|
+
newItems.forEach(itemDelta => {
|
|
563
|
+
const cell = this.getCellByHandle(itemDelta.handle);
|
|
564
|
+
const deleted = deletesByHandle[itemDelta.handle] ?? [];
|
|
565
|
+
delete deletesByHandle[itemDelta.handle];
|
|
566
|
+
deleted.forEach(id => this._statusBarItemIdToCellMap.delete(id));
|
|
567
|
+
const ret = cell?.deltaCellStatusBarItems(deleted, itemDelta.items) || [];
|
|
568
|
+
ret.forEach(id => {
|
|
569
|
+
this._statusBarItemIdToCellMap.set(id, itemDelta.handle);
|
|
570
|
+
});
|
|
571
|
+
result.push(...ret);
|
|
572
|
+
});
|
|
573
|
+
for (const _handle in deletesByHandle) {
|
|
574
|
+
const handle = parseInt(_handle);
|
|
575
|
+
const ids = deletesByHandle[handle];
|
|
576
|
+
const cell = this.getCellByHandle(handle);
|
|
577
|
+
cell?.deltaCellStatusBarItems(ids, []);
|
|
578
|
+
ids.forEach(id => this._statusBarItemIdToCellMap.delete(id));
|
|
579
|
+
}
|
|
580
|
+
return result;
|
|
581
|
+
}
|
|
582
|
+
nearestCodeCellIndex(index ) {
|
|
583
|
+
const nearest = this.viewCells.slice(0, index).reverse().findIndex(cell => cell.cellKind === CellKind.Code);
|
|
584
|
+
if (nearest > -1) {
|
|
585
|
+
return index - nearest - 1;
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
const nearestCellTheOtherDirection = this.viewCells.slice(index + 1).findIndex(cell => cell.cellKind === CellKind.Code);
|
|
589
|
+
if (nearestCellTheOtherDirection > -1) {
|
|
590
|
+
return index + 1 + nearestCellTheOtherDirection;
|
|
591
|
+
}
|
|
592
|
+
return -1;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
getEditorViewState() {
|
|
596
|
+
const editingCells = {};
|
|
597
|
+
const collapsedInputCells = {};
|
|
598
|
+
const collapsedOutputCells = {};
|
|
599
|
+
const cellLineNumberStates = {};
|
|
600
|
+
this._viewCells.forEach((cell, i) => {
|
|
601
|
+
if (cell.getEditState() === CellEditState.Editing) {
|
|
602
|
+
editingCells[i] = true;
|
|
603
|
+
}
|
|
604
|
+
if (cell.isInputCollapsed) {
|
|
605
|
+
collapsedInputCells[i] = true;
|
|
606
|
+
}
|
|
607
|
+
if (cell instanceof CodeCellViewModel && cell.isOutputCollapsed) {
|
|
608
|
+
collapsedOutputCells[i] = true;
|
|
609
|
+
}
|
|
610
|
+
if (cell.lineNumbers !== 'inherit') {
|
|
611
|
+
cellLineNumberStates[i] = cell.lineNumbers;
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
const editorViewStates = {};
|
|
615
|
+
( this._viewCells.map(cell => ({ handle: cell.model.handle, state: cell.saveEditorViewState() }))).forEach((viewState, i) => {
|
|
616
|
+
if (viewState.state) {
|
|
617
|
+
editorViewStates[i] = viewState.state;
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
return {
|
|
621
|
+
editingCells,
|
|
622
|
+
editorViewStates,
|
|
623
|
+
cellLineNumberStates,
|
|
624
|
+
collapsedInputCells,
|
|
625
|
+
collapsedOutputCells
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
restoreEditorViewState(viewState) {
|
|
629
|
+
if (!viewState) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
this._viewCells.forEach((cell, index) => {
|
|
633
|
+
const isEditing = viewState.editingCells && viewState.editingCells[index];
|
|
634
|
+
const editorViewState = viewState.editorViewStates && viewState.editorViewStates[index];
|
|
635
|
+
cell.updateEditState(isEditing ? CellEditState.Editing : CellEditState.Preview, 'viewState');
|
|
636
|
+
const cellHeight = viewState.cellTotalHeights ? viewState.cellTotalHeights[index] : undefined;
|
|
637
|
+
cell.restoreEditorViewState(editorViewState, cellHeight);
|
|
638
|
+
if (viewState.collapsedInputCells && viewState.collapsedInputCells[index]) {
|
|
639
|
+
cell.isInputCollapsed = true;
|
|
640
|
+
}
|
|
641
|
+
if (viewState.collapsedOutputCells && viewState.collapsedOutputCells[index] && cell instanceof CodeCellViewModel) {
|
|
642
|
+
cell.isOutputCollapsed = true;
|
|
643
|
+
}
|
|
644
|
+
if (viewState.cellLineNumberStates && viewState.cellLineNumberStates[index]) {
|
|
645
|
+
cell.lineNumbers = viewState.cellLineNumberStates[index];
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
changeModelDecorations(callback) {
|
|
650
|
+
const changeAccessor = {
|
|
651
|
+
deltaDecorations: (oldDecorations, newDecorations) => {
|
|
652
|
+
return this._deltaModelDecorationsImpl(oldDecorations, newDecorations);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
let result = null;
|
|
656
|
+
try {
|
|
657
|
+
result = callback(changeAccessor);
|
|
658
|
+
}
|
|
659
|
+
catch (e) {
|
|
660
|
+
onUnexpectedError(e);
|
|
661
|
+
}
|
|
662
|
+
changeAccessor.deltaDecorations = invalidFunc;
|
|
663
|
+
return result;
|
|
664
|
+
}
|
|
665
|
+
_deltaModelDecorationsImpl(oldDecorations, newDecorations) {
|
|
666
|
+
const mapping = ( new Map());
|
|
667
|
+
oldDecorations.forEach(oldDecoration => {
|
|
668
|
+
const ownerId = oldDecoration.ownerId;
|
|
669
|
+
if (!( mapping.has(ownerId))) {
|
|
670
|
+
const cell = this._viewCells.find(cell => cell.handle === ownerId);
|
|
671
|
+
if (cell) {
|
|
672
|
+
mapping.set(ownerId, { cell: cell, oldDecorations: [], newDecorations: [] });
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
const data = mapping.get(ownerId);
|
|
676
|
+
if (data) {
|
|
677
|
+
data.oldDecorations = oldDecoration.decorations;
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
newDecorations.forEach(newDecoration => {
|
|
681
|
+
const ownerId = newDecoration.ownerId;
|
|
682
|
+
if (!( mapping.has(ownerId))) {
|
|
683
|
+
const cell = this._viewCells.find(cell => cell.handle === ownerId);
|
|
684
|
+
if (cell) {
|
|
685
|
+
mapping.set(ownerId, { cell: cell, oldDecorations: [], newDecorations: [] });
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
const data = mapping.get(ownerId);
|
|
689
|
+
if (data) {
|
|
690
|
+
data.newDecorations = newDecoration.decorations;
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
const ret = [];
|
|
694
|
+
mapping.forEach((value, ownerId) => {
|
|
695
|
+
const cellRet = value.cell.deltaModelDecorations(value.oldDecorations, value.newDecorations);
|
|
696
|
+
ret.push({
|
|
697
|
+
ownerId: ownerId,
|
|
698
|
+
decorations: cellRet
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
return ret;
|
|
702
|
+
}
|
|
703
|
+
find(value, options) {
|
|
704
|
+
const matches = [];
|
|
705
|
+
this._viewCells.forEach((cell, index) => {
|
|
706
|
+
const cellMatches = cell.startFind(value, options);
|
|
707
|
+
if (cellMatches) {
|
|
708
|
+
matches.push(( new CellFindMatchModel(cellMatches.cell, index, cellMatches.contentMatches, [])));
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
return matches.filter(match => {
|
|
712
|
+
if (match.cell.cellKind === CellKind.Code) {
|
|
713
|
+
return options.includeCodeInput;
|
|
714
|
+
}
|
|
715
|
+
if (match.cell.getEditState() === CellEditState.Editing) {
|
|
716
|
+
return options.includeMarkupInput;
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
return !options.includeMarkupPreview && options.includeMarkupInput;
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
replaceOne(cell, range, text) {
|
|
724
|
+
const viewCell = cell;
|
|
725
|
+
this._lastNotebookEditResource.push(viewCell.uri);
|
|
726
|
+
return viewCell.resolveTextModel().then(() => {
|
|
727
|
+
this._bulkEditService.apply([( new ResourceTextEdit(cell.uri, { range, text }))], { quotableLabel: 'Notebook Replace' });
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
async replaceAll(matches, texts) {
|
|
731
|
+
if (!matches.length) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
const textEdits = [];
|
|
735
|
+
this._lastNotebookEditResource.push(matches[0].cell.uri);
|
|
736
|
+
matches.forEach(match => {
|
|
737
|
+
match.contentMatches.forEach((singleMatch, index) => {
|
|
738
|
+
textEdits.push({
|
|
739
|
+
versionId: undefined,
|
|
740
|
+
textEdit: { range: singleMatch.range, text: texts[index] },
|
|
741
|
+
resource: match.cell.uri
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
return Promise.all(( matches.map(match => {
|
|
746
|
+
return match.cell.resolveTextModel();
|
|
747
|
+
}))).then(async () => {
|
|
748
|
+
this._bulkEditService.apply({ edits: textEdits }, { quotableLabel: 'Notebook Replace All' });
|
|
749
|
+
return;
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
async _withElement(element, callback) {
|
|
753
|
+
const viewCells = this._viewCells.filter(cell => element.matchesResource(cell.uri));
|
|
754
|
+
const refs = await Promise.all(( viewCells.map(cell => this._textModelService.createModelReference(cell.uri))));
|
|
755
|
+
await callback();
|
|
756
|
+
refs.forEach(ref => ref.dispose());
|
|
757
|
+
}
|
|
758
|
+
async undo() {
|
|
759
|
+
const editStack = this._undoService.getElements(this.uri);
|
|
760
|
+
const element = editStack.past.length ? editStack.past[editStack.past.length - 1] : undefined;
|
|
761
|
+
if (element && element instanceof SingleModelEditStackElement || element instanceof MultiModelEditStackElement) {
|
|
762
|
+
await this._withElement(element, async () => {
|
|
763
|
+
await this._undoService.undo(this.uri);
|
|
764
|
+
});
|
|
765
|
+
return (element instanceof SingleModelEditStackElement) ? [element.resource] : element.resources;
|
|
766
|
+
}
|
|
767
|
+
await this._undoService.undo(this.uri);
|
|
768
|
+
return [];
|
|
769
|
+
}
|
|
770
|
+
async redo() {
|
|
771
|
+
const editStack = this._undoService.getElements(this.uri);
|
|
772
|
+
const element = editStack.future[0];
|
|
773
|
+
if (element && element instanceof SingleModelEditStackElement || element instanceof MultiModelEditStackElement) {
|
|
774
|
+
await this._withElement(element, async () => {
|
|
775
|
+
await this._undoService.redo(this.uri);
|
|
776
|
+
});
|
|
777
|
+
return (element instanceof SingleModelEditStackElement) ? [element.resource] : element.resources;
|
|
778
|
+
}
|
|
779
|
+
await this._undoService.redo(this.uri);
|
|
780
|
+
return [];
|
|
781
|
+
}
|
|
782
|
+
equal(notebook) {
|
|
783
|
+
return this._notebook === notebook;
|
|
784
|
+
}
|
|
785
|
+
dispose() {
|
|
786
|
+
this._localStore.clear();
|
|
787
|
+
this._viewCells.forEach(cell => {
|
|
788
|
+
cell.dispose();
|
|
789
|
+
});
|
|
790
|
+
super.dispose();
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
NotebookViewModel = ( __decorate([
|
|
794
|
+
( __param(5, IInstantiationService)),
|
|
795
|
+
( __param(6, IBulkEditService)),
|
|
796
|
+
( __param(7, IUndoRedoService)),
|
|
797
|
+
( __param(8, ITextModelService)),
|
|
798
|
+
( __param(9, INotebookExecutionStateService))
|
|
799
|
+
], NotebookViewModel));
|
|
800
|
+
function createCellViewModel(instantiationService, notebookViewModel, cell, viewContext) {
|
|
801
|
+
if (cell.cellKind === CellKind.Code) {
|
|
802
|
+
return instantiationService.createInstance(CodeCellViewModel, notebookViewModel.viewType, cell, notebookViewModel.layoutInfo, viewContext);
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
return instantiationService.createInstance(MarkupCellViewModel, notebookViewModel.viewType, cell, notebookViewModel.layoutInfo, notebookViewModel, viewContext);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
export { NotebookViewModel, createCellViewModel };
|