@codingame/monaco-vscode-chat-service-override 15.0.2 → 16.0.0
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/index.js +11 -8
- package/package.json +29 -20
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.d.ts +22 -0
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +10 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +9 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +80 -55
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.js +17 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/{askToSelectPrompt.d.ts → askToSelectPrompt/askToSelectPrompt.d.ts} +9 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/askToSelectPrompt.js +79 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.js +53 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.js +19 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.d.ts +13 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.js +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +6 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +163 -72
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +22 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +4 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +17 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +9 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.js +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +242 -74
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.js +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.d.ts +47 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +688 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.d.ts +28 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +355 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +71 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +395 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +98 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +216 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +97 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +831 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +7 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +32 -47
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +110 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +985 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +69 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.js +67 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +147 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +56 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +284 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +578 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.d.ts +45 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.js +122 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.js +320 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.d.ts +31 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js +50 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +22 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +166 -62
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +6 -104
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +704 -732
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +10 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +329 -236
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +4 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +14 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +17 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +217 -18
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css +114 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditorController.css +30 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +56 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css +90 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +65 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.js +14 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +16 -8
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +175 -57
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.d.ts +66 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +313 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +3 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +4 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.js +30 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.d.ts +2 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.js +6 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +10 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +18 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.js +117 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.js +3 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +6 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +157 -65
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +39 -21
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -3
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +11 -10
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +47 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.d.ts +5 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.js +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.js +0 -142
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +0 -52
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +0 -331
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +0 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +0 -110
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.js +0 -13
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.d.ts +0 -31
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.js +0 -85
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +0 -11
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +0 -22
package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js
ADDED
|
@@ -0,0 +1,831 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { streamToBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
4
|
+
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
5
|
+
import { StringSHA1 } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hash';
|
|
6
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import { ResourceMap, ResourceSet } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
8
|
+
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
9
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
10
|
+
import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
11
|
+
import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
12
|
+
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
|
13
|
+
import { LineRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/lineRange';
|
|
14
|
+
import { OffsetEdit } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/offsetEdit';
|
|
15
|
+
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
16
|
+
import { nullDocumentDiff } from '../../../../../editor/common/diff/documentDiffProvider.js';
|
|
17
|
+
import { RangeMapping, DetailedLineRangeMapping } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/diff/rangeMapping';
|
|
18
|
+
import '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
|
|
19
|
+
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
|
20
|
+
import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
|
|
21
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
22
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
23
|
+
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
24
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
25
|
+
import { UndoRedoElementType } from '@codingame/monaco-vscode-api/vscode/vs/platform/undoRedo/common/undoRedo';
|
|
26
|
+
import { IUndoRedoService } from '@codingame/monaco-vscode-api/vscode/vs/platform/undoRedo/common/undoRedo.service';
|
|
27
|
+
import { SaveReason } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
|
|
28
|
+
import { IFilesConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service';
|
|
29
|
+
import { SnapshotContext } from '@codingame/monaco-vscode-bba55be6-41a2-50cd-a3cc-8bafa35bfa89-common/vscode/vs/workbench/services/workingCopy/common/fileWorkingCopy';
|
|
30
|
+
import { NotebookTextDiffEditor } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor';
|
|
31
|
+
import { getNotebookEditorFromEditorPane } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
32
|
+
import { CellEditType, NotebookCellsChangeType, NotebookSetting } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
33
|
+
import { computeDiff } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/notebook/common/notebookDiff';
|
|
34
|
+
import { INotebookEditorModelResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.service';
|
|
35
|
+
import { INotebookLoggingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookLoggingService.service';
|
|
36
|
+
import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
|
|
37
|
+
import { INotebookEditorWorkerService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/services/notebookWorkerService.service';
|
|
38
|
+
import { WorkingSetEntryState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
|
|
39
|
+
import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
|
|
40
|
+
import { AbstractChatEditingModifiedFileEntry } from './chatEditingModifiedFileEntry.js';
|
|
41
|
+
import { getNotebookSnapshotFileURI, restoreSnapshot, createSnapshot, deserializeSnapshot, SnapshotComparer } from './notebook/chatEditingModifiedNotebookSnapshot.js';
|
|
42
|
+
import { ChatEditingNotebookCellEntry } from './notebook/chatEditingNotebookCellEntry.js';
|
|
43
|
+
import { ChatEditingNotebookDiffEditorIntegration, ChatEditingNotebookEditorIntegration } from './notebook/chatEditingNotebookEditorIntegration.js';
|
|
44
|
+
import { ChatEditingNotebookFileSystemProvider } from './notebook/chatEditingNotebookFileSystemProvider.js';
|
|
45
|
+
import { isTransientIPyNbExtensionEvent, adjustCellDiffAndOriginalModelBasedOnCellMovements, getCorrespondingOriginalCellIndex, adjustCellDiffAndOriginalModelBasedOnCellAddDelete, calculateNotebookRewriteRatio, adjustCellDiffForRevertingAnInsertedCell, adjustCellDiffForKeepingAnInsertedCell, adjustCellDiffForRevertingADeletedCell } from './notebook/helpers.js';
|
|
46
|
+
import { countChanges, sortCellChanges } from './notebook/notebookCellChanges.js';
|
|
47
|
+
import { observableValue, transaction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
|
|
48
|
+
import { ObservablePromise } from '@codingame/monaco-vscode-ae8a8ca1-f243-508b-9c37-c88ebbd295fa-common/vscode/vs/base/common/observableInternal/promise';
|
|
49
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
|
50
|
+
|
|
51
|
+
var ChatEditingModifiedNotebookEntry_1;
|
|
52
|
+
const SnapshotLanguageId = 'VSCodeChatNotebookSnapshotLanguage';
|
|
53
|
+
let ChatEditingModifiedNotebookEntry = class ChatEditingModifiedNotebookEntry extends AbstractChatEditingModifiedFileEntry {
|
|
54
|
+
static { ChatEditingModifiedNotebookEntry_1 = this; }
|
|
55
|
+
static { this.NewModelCounter = 0; }
|
|
56
|
+
get isProcessingResponse() {
|
|
57
|
+
return this._isProcessingResponse;
|
|
58
|
+
}
|
|
59
|
+
get cellsDiffInfo() {
|
|
60
|
+
return this._cellsDiffInfo;
|
|
61
|
+
}
|
|
62
|
+
static async create(uri, _multiDiffEntryDelegate, telemetryInfo, chatKind, initialContent, instantiationService) {
|
|
63
|
+
return instantiationService.invokeFunction(async (accessor) => {
|
|
64
|
+
const notebookService = accessor.get(INotebookService);
|
|
65
|
+
const resolver = accessor.get(INotebookEditorModelResolverService);
|
|
66
|
+
const configurationServie = accessor.get(IConfigurationService);
|
|
67
|
+
const resourceRef = await resolver.resolve(uri);
|
|
68
|
+
const notebook = resourceRef.object.notebook;
|
|
69
|
+
const originalUri = getNotebookSnapshotFileURI(telemetryInfo.sessionId, telemetryInfo.requestId, generateUuid(), notebook.uri.scheme === Schemas.untitled ? `/${notebook.uri.path}` : notebook.uri.path, notebook.viewType);
|
|
70
|
+
const [options, buffer] = await Promise.all([
|
|
71
|
+
notebookService.withNotebookDataProvider(resourceRef.object.notebook.notebookType),
|
|
72
|
+
notebookService.createNotebookTextDocumentSnapshot(notebook.uri, SnapshotContext.Backup, CancellationToken.None).then(s => streamToBuffer(s))
|
|
73
|
+
]);
|
|
74
|
+
const disposables = ( new DisposableStore());
|
|
75
|
+
disposables.add(ChatEditingNotebookFileSystemProvider.registerFile(originalUri, buffer));
|
|
76
|
+
const originalRef = await resolver.resolve(originalUri, notebook.viewType);
|
|
77
|
+
if (initialContent) {
|
|
78
|
+
restoreSnapshot(originalRef.object.notebook, initialContent);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
initialContent = createSnapshot(notebook, options.serializer.options, configurationServie);
|
|
82
|
+
restoreSnapshot(originalRef.object.notebook, initialContent);
|
|
83
|
+
const edits = [];
|
|
84
|
+
notebook.cells.forEach((cell, index) => {
|
|
85
|
+
const internalId = generateCellHash(cell.uri);
|
|
86
|
+
edits.push({ editType: CellEditType.PartialInternalMetadata, index, internalMetadata: { internalId } });
|
|
87
|
+
});
|
|
88
|
+
resourceRef.object.notebook.applyEdits(edits, true, undefined, () => undefined, undefined, false);
|
|
89
|
+
originalRef.object.notebook.applyEdits(edits, true, undefined, () => undefined, undefined, false);
|
|
90
|
+
}
|
|
91
|
+
const instance = instantiationService.createInstance(ChatEditingModifiedNotebookEntry_1, resourceRef, originalRef, _multiDiffEntryDelegate, options.serializer.options, telemetryInfo, chatKind, initialContent);
|
|
92
|
+
instance._register(disposables);
|
|
93
|
+
return instance;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
static canHandleSnapshotContent(initialContent) {
|
|
97
|
+
if (!initialContent) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
deserializeSnapshot(initialContent);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
catch (ex) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
static canHandleSnapshot(snapshot) {
|
|
109
|
+
if (snapshot.languageId === SnapshotLanguageId && ChatEditingModifiedNotebookEntry_1.canHandleSnapshotContent(snapshot.current)) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
constructor(modifiedResourceRef, originalResourceRef, _multiDiffEntryDelegate, transientOptions, telemetryInfo, kind, initialContent, configurationService, fileConfigService, chatService, fileService, instantiationService, textModelService, modelService, undoRedoService, notebookEditorWorkerService, loggingService, notebookResolver) {
|
|
115
|
+
super(modifiedResourceRef.object.notebook.uri, telemetryInfo, kind, configurationService, fileConfigService, chatService, fileService, undoRedoService, instantiationService);
|
|
116
|
+
this.modifiedResourceRef = modifiedResourceRef;
|
|
117
|
+
this._multiDiffEntryDelegate = _multiDiffEntryDelegate;
|
|
118
|
+
this.transientOptions = transientOptions;
|
|
119
|
+
this.configurationService = configurationService;
|
|
120
|
+
this.textModelService = textModelService;
|
|
121
|
+
this.modelService = modelService;
|
|
122
|
+
this.notebookEditorWorkerService = notebookEditorWorkerService;
|
|
123
|
+
this.loggingService = loggingService;
|
|
124
|
+
this.notebookResolver = notebookResolver;
|
|
125
|
+
this._isProcessingResponse = observableValue('isProcessingResponse', false);
|
|
126
|
+
this._isEditFromUs = false;
|
|
127
|
+
this._allEditsAreFromUs = true;
|
|
128
|
+
this._changesCount = observableValue(this, 0);
|
|
129
|
+
this.changesCount = this._changesCount;
|
|
130
|
+
this.cellEntryMap = ( new ResourceMap());
|
|
131
|
+
this.modifiedToOriginalCell = ( new ResourceMap());
|
|
132
|
+
this._cellsDiffInfo = observableValue('diffInfo', []);
|
|
133
|
+
this.editedCells = ( new ResourceSet());
|
|
134
|
+
this.computeRequestId = 0;
|
|
135
|
+
this.cellTextModelMap = ( new ResourceMap());
|
|
136
|
+
this.initialContentComparer = ( new SnapshotComparer(initialContent));
|
|
137
|
+
this.modifiedModel = this._register(modifiedResourceRef).object.notebook;
|
|
138
|
+
this.originalModel = this._register(originalResourceRef).object.notebook;
|
|
139
|
+
this.originalURI = this.originalModel.uri;
|
|
140
|
+
this.initialContent = initialContent;
|
|
141
|
+
this.initializeModelsFromDiff();
|
|
142
|
+
this._register(this.modifiedModel.onDidChangeContent(this.mirrorNotebookEdits, this));
|
|
143
|
+
}
|
|
144
|
+
initializeModelsFromDiffImpl(cellsDiffInfo) {
|
|
145
|
+
this.cellEntryMap.forEach(entry => entry.dispose());
|
|
146
|
+
this.cellEntryMap.clear();
|
|
147
|
+
const diffs = ( cellsDiffInfo.map((cellDiff, i) => {
|
|
148
|
+
switch (cellDiff.type) {
|
|
149
|
+
case 'delete':
|
|
150
|
+
return this.createDeleteCellDiffInfo(cellDiff.originalCellIndex);
|
|
151
|
+
case 'insert':
|
|
152
|
+
return this.createInsertedCellDiffInfo(cellDiff.modifiedCellIndex);
|
|
153
|
+
default:
|
|
154
|
+
return this.createModifiedCellDiffInfo(cellDiff.modifiedCellIndex, cellDiff.originalCellIndex);
|
|
155
|
+
}
|
|
156
|
+
}));
|
|
157
|
+
this._cellsDiffInfo.set(diffs, undefined);
|
|
158
|
+
this._changesCount.set(countChanges(diffs), undefined);
|
|
159
|
+
}
|
|
160
|
+
async initializeModelsFromDiff() {
|
|
161
|
+
const id = ++this.computeRequestId;
|
|
162
|
+
if (this._areOriginalAndModifiedIdenticalImpl()) {
|
|
163
|
+
const cellsDiffInfo = ( this.modifiedModel.cells.map((_, index) => {
|
|
164
|
+
return { type: 'unchanged', originalCellIndex: index, modifiedCellIndex: index };
|
|
165
|
+
}));
|
|
166
|
+
this.initializeModelsFromDiffImpl(cellsDiffInfo);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const cellsDiffInfo = [];
|
|
170
|
+
try {
|
|
171
|
+
this._isProcessingResponse.set(true, undefined);
|
|
172
|
+
const notebookDiff = await this.notebookEditorWorkerService.computeDiff(this.originalURI, this.modifiedURI);
|
|
173
|
+
if (id !== this.computeRequestId) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const result = computeDiff(this.originalModel, this.modifiedModel, notebookDiff);
|
|
177
|
+
if (result.cellDiffInfo.length) {
|
|
178
|
+
cellsDiffInfo.push(...result.cellDiffInfo);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (ex) {
|
|
182
|
+
this.loggingService.error('Notebook Chat', 'Error computing diff:\n' + ex);
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
this._isProcessingResponse.set(false, undefined);
|
|
186
|
+
}
|
|
187
|
+
this.initializeModelsFromDiffImpl(cellsDiffInfo);
|
|
188
|
+
}
|
|
189
|
+
updateCellDiffInfo(cellsDiffInfo, transcation) {
|
|
190
|
+
this._cellsDiffInfo.set(sortCellChanges(cellsDiffInfo), transcation);
|
|
191
|
+
this._changesCount.set(countChanges(cellsDiffInfo), transcation);
|
|
192
|
+
}
|
|
193
|
+
mirrorNotebookEdits(e) {
|
|
194
|
+
if (this._isEditFromUs || ( Array.from(( this.cellEntryMap.values())).some(entry => entry.isEditFromUs))) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
let didResetToOriginalContent = this.initialContentComparer.isEqual(this.modifiedModel);
|
|
198
|
+
const currentState = this._stateObs.get();
|
|
199
|
+
if (currentState === WorkingSetEntryState.Rejected) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (currentState === WorkingSetEntryState.Modified && didResetToOriginalContent) {
|
|
203
|
+
this._stateObs.set(WorkingSetEntryState.Rejected, undefined);
|
|
204
|
+
this.updateCellDiffInfo([], undefined);
|
|
205
|
+
this.initializeModelsFromDiff();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (!e.rawEvents.length) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (isTransientIPyNbExtensionEvent(this.modifiedModel.notebookType, e)) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
this._allEditsAreFromUs = false;
|
|
215
|
+
for (const event of e.rawEvents.filter(event => event.kind !== NotebookCellsChangeType.ChangeCellContent)) {
|
|
216
|
+
switch (event.kind) {
|
|
217
|
+
case NotebookCellsChangeType.ChangeDocumentMetadata: {
|
|
218
|
+
const edit = {
|
|
219
|
+
editType: CellEditType.DocumentMetadata,
|
|
220
|
+
metadata: this.modifiedModel.metadata
|
|
221
|
+
};
|
|
222
|
+
this.originalModel.applyEdits([edit], true, undefined, () => undefined, undefined, false);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case NotebookCellsChangeType.ModelChange: {
|
|
226
|
+
let cellDiffs = sortCellChanges(this._cellsDiffInfo.get());
|
|
227
|
+
this._applyEditsSync(() => {
|
|
228
|
+
event.changes.forEach(change => {
|
|
229
|
+
change[2].forEach((cell, i) => {
|
|
230
|
+
if (cell.internalMetadata.internalId) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const index = change[0] + i;
|
|
234
|
+
const internalId = generateCellHash(cell.uri);
|
|
235
|
+
const edits = [{ editType: CellEditType.PartialInternalMetadata, index, internalMetadata: { internalId } }];
|
|
236
|
+
this.modifiedModel.applyEdits(edits, true, undefined, () => undefined, undefined, false);
|
|
237
|
+
cell.internalMetadata ??= {};
|
|
238
|
+
cell.internalMetadata.internalId = internalId;
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
event.changes.forEach(change => {
|
|
243
|
+
cellDiffs = adjustCellDiffAndOriginalModelBasedOnCellAddDelete(change, cellDiffs, this.modifiedModel.cells.length, this.originalModel.cells.length, this.originalModel.applyEdits.bind(this.originalModel), this.createModifiedCellDiffInfo.bind(this));
|
|
244
|
+
});
|
|
245
|
+
this.updateCellDiffInfo(cellDiffs, undefined);
|
|
246
|
+
this.disposeDeletedCellEntries();
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case NotebookCellsChangeType.ChangeCellLanguage: {
|
|
250
|
+
const index = getCorrespondingOriginalCellIndex(event.index, this._cellsDiffInfo.get());
|
|
251
|
+
if (typeof index === 'number') {
|
|
252
|
+
const edit = {
|
|
253
|
+
editType: CellEditType.CellLanguage,
|
|
254
|
+
index,
|
|
255
|
+
language: event.language
|
|
256
|
+
};
|
|
257
|
+
this.originalModel.applyEdits([edit], true, undefined, () => undefined, undefined, false);
|
|
258
|
+
}
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case NotebookCellsChangeType.ChangeCellMetadata: {
|
|
262
|
+
const index = getCorrespondingOriginalCellIndex(event.index, this._cellsDiffInfo.get());
|
|
263
|
+
if (typeof index === 'number') {
|
|
264
|
+
const edit = {
|
|
265
|
+
editType: CellEditType.Metadata,
|
|
266
|
+
index,
|
|
267
|
+
metadata: event.metadata
|
|
268
|
+
};
|
|
269
|
+
this.originalModel.applyEdits([edit], true, undefined, () => undefined, undefined, false);
|
|
270
|
+
}
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
case NotebookCellsChangeType.ChangeCellMime:
|
|
274
|
+
break;
|
|
275
|
+
case NotebookCellsChangeType.ChangeCellInternalMetadata: {
|
|
276
|
+
const index = getCorrespondingOriginalCellIndex(event.index, this._cellsDiffInfo.get());
|
|
277
|
+
if (typeof index === 'number') {
|
|
278
|
+
const edit = {
|
|
279
|
+
editType: CellEditType.PartialInternalMetadata,
|
|
280
|
+
index,
|
|
281
|
+
internalMetadata: event.internalMetadata
|
|
282
|
+
};
|
|
283
|
+
this.originalModel.applyEdits([edit], true, undefined, () => undefined, undefined, false);
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
case NotebookCellsChangeType.Output: {
|
|
288
|
+
const index = getCorrespondingOriginalCellIndex(event.index, this._cellsDiffInfo.get());
|
|
289
|
+
if (typeof index === 'number') {
|
|
290
|
+
const edit = {
|
|
291
|
+
editType: CellEditType.Output,
|
|
292
|
+
index,
|
|
293
|
+
append: event.append,
|
|
294
|
+
outputs: event.outputs
|
|
295
|
+
};
|
|
296
|
+
this.originalModel.applyEdits([edit], true, undefined, () => undefined, undefined, false);
|
|
297
|
+
}
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case NotebookCellsChangeType.OutputItem: {
|
|
301
|
+
const index = getCorrespondingOriginalCellIndex(event.index, this._cellsDiffInfo.get());
|
|
302
|
+
if (typeof index === 'number') {
|
|
303
|
+
const edit = {
|
|
304
|
+
editType: CellEditType.OutputItems,
|
|
305
|
+
outputId: event.outputId,
|
|
306
|
+
append: event.append,
|
|
307
|
+
items: event.outputItems
|
|
308
|
+
};
|
|
309
|
+
this.originalModel.applyEdits([edit], true, undefined, () => undefined, undefined, false);
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
case NotebookCellsChangeType.Move: {
|
|
314
|
+
const result = adjustCellDiffAndOriginalModelBasedOnCellMovements(event, this._cellsDiffInfo.get().slice());
|
|
315
|
+
if (result) {
|
|
316
|
+
this.originalModel.applyEdits(result[1], true, undefined, () => undefined, undefined, false);
|
|
317
|
+
this._cellsDiffInfo.set(result[0], undefined);
|
|
318
|
+
}
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
didResetToOriginalContent = this.initialContentComparer.isEqual(this.modifiedModel);
|
|
324
|
+
if (currentState === WorkingSetEntryState.Modified && didResetToOriginalContent) {
|
|
325
|
+
this._stateObs.set(WorkingSetEntryState.Rejected, undefined);
|
|
326
|
+
this.updateCellDiffInfo([], undefined);
|
|
327
|
+
this.initializeModelsFromDiff();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async _doAccept(tx) {
|
|
332
|
+
this.updateCellDiffInfo([], tx);
|
|
333
|
+
const snapshot = createSnapshot(this.modifiedModel, this.transientOptions, this.configurationService);
|
|
334
|
+
restoreSnapshot(this.originalModel, snapshot);
|
|
335
|
+
this.initializeModelsFromDiff();
|
|
336
|
+
await this._collapse(tx);
|
|
337
|
+
const config = this._fileConfigService.getAutoSaveConfiguration(this.modifiedURI);
|
|
338
|
+
if (this.modifiedModel.uri.scheme !== Schemas.untitled && (!config.autoSave || !this.notebookResolver.isDirty(this.modifiedURI))) {
|
|
339
|
+
await this._applyEdits(async () => {
|
|
340
|
+
try {
|
|
341
|
+
await this.modifiedResourceRef.object.save({
|
|
342
|
+
reason: SaveReason.EXPLICIT,
|
|
343
|
+
force: true,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
async _doReject(tx) {
|
|
352
|
+
this.updateCellDiffInfo([], tx);
|
|
353
|
+
if (this.createdInRequestId === this._telemetryInfo.requestId) {
|
|
354
|
+
await this._applyEdits(async () => {
|
|
355
|
+
await this.modifiedResourceRef.object.revert({ soft: true });
|
|
356
|
+
await this._fileService.del(this.modifiedURI);
|
|
357
|
+
});
|
|
358
|
+
this._onDidDelete.fire();
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
await this._applyEdits(async () => {
|
|
362
|
+
const snapshot = createSnapshot(this.originalModel, this.transientOptions, this.configurationService);
|
|
363
|
+
this.restoreSnapshotInModifiedModel(snapshot);
|
|
364
|
+
if (this._allEditsAreFromUs && Array.from(( this.cellEntryMap.values())).every(entry => entry.allEditsAreFromUs)) {
|
|
365
|
+
await this.modifiedResourceRef.object.save({ reason: SaveReason.EXPLICIT, skipSaveParticipants: true });
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
this.initializeModelsFromDiff();
|
|
369
|
+
await this._collapse(tx);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async _collapse(transaction) {
|
|
373
|
+
this._multiDiffEntryDelegate.collapse(transaction);
|
|
374
|
+
}
|
|
375
|
+
_createEditorIntegration(editor) {
|
|
376
|
+
const notebookEditor = getNotebookEditorFromEditorPane(editor);
|
|
377
|
+
if (!notebookEditor && editor.getId() === NotebookTextDiffEditor.ID) {
|
|
378
|
+
const diffEditor = editor.getControl();
|
|
379
|
+
return this._instantiationService.createInstance(ChatEditingNotebookDiffEditorIntegration, diffEditor, this._cellsDiffInfo);
|
|
380
|
+
}
|
|
381
|
+
assertType(notebookEditor);
|
|
382
|
+
return this._instantiationService.createInstance(ChatEditingNotebookEditorIntegration, this, editor, this.modifiedModel, this.originalModel, this._cellsDiffInfo);
|
|
383
|
+
}
|
|
384
|
+
_resetEditsState(tx) {
|
|
385
|
+
super._resetEditsState(tx);
|
|
386
|
+
this.cellEntryMap.forEach(entry => !entry.disposed && entry.clearCurrentEditLineDecoration());
|
|
387
|
+
}
|
|
388
|
+
_createUndoRedoElement(response) {
|
|
389
|
+
const request = response.session.getRequests().find(req => req.id === response.requestId);
|
|
390
|
+
const label = request?.message.text ? ( localize(4688, "Chat Edit: '{0}'", request.message.text)) : ( localize(4689, "Chat Edit"));
|
|
391
|
+
const transientOptions = this.transientOptions;
|
|
392
|
+
const outputSizeLimit = this.configurationService.getValue(NotebookSetting.outputBackupSizeLimit) * 1024;
|
|
393
|
+
let initial = createSnapshot(this.modifiedModel, transientOptions, outputSizeLimit);
|
|
394
|
+
let last = '';
|
|
395
|
+
return {
|
|
396
|
+
type: UndoRedoElementType.Resource,
|
|
397
|
+
resource: this.modifiedURI,
|
|
398
|
+
label,
|
|
399
|
+
code: 'chat.edit',
|
|
400
|
+
confirmBeforeUndo: false,
|
|
401
|
+
undo: async () => {
|
|
402
|
+
last = createSnapshot(this.modifiedModel, transientOptions, outputSizeLimit);
|
|
403
|
+
restoreSnapshot(this.modifiedModel, initial);
|
|
404
|
+
},
|
|
405
|
+
redo: async () => {
|
|
406
|
+
initial = createSnapshot(this.modifiedModel, transientOptions, outputSizeLimit);
|
|
407
|
+
restoreSnapshot(this.modifiedModel, last);
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
async _areOriginalAndModifiedIdentical() {
|
|
412
|
+
return this._areOriginalAndModifiedIdenticalImpl();
|
|
413
|
+
}
|
|
414
|
+
_areOriginalAndModifiedIdenticalImpl() {
|
|
415
|
+
const snapshot = createSnapshot(this.originalModel, this.transientOptions, this.configurationService);
|
|
416
|
+
return ( new SnapshotComparer(snapshot)).isEqual(this.modifiedModel);
|
|
417
|
+
}
|
|
418
|
+
async acceptAgentEdits(resource, edits, isLastEdits, responseModel) {
|
|
419
|
+
const isCellUri = resource.scheme === Schemas.vscodeNotebookCell;
|
|
420
|
+
const cell = isCellUri && this.modifiedModel.cells.find(cell => isEqual(cell.uri, resource));
|
|
421
|
+
if (cell) {
|
|
422
|
+
const index = this.modifiedModel.cells.indexOf(cell);
|
|
423
|
+
const entry = this._cellsDiffInfo.get().slice().find(entry => entry.modifiedCellIndex === index);
|
|
424
|
+
if (!entry) {
|
|
425
|
+
console.error('Original cell model not found');
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
this.getOrCreateModifiedTextFileEntryForCell(cell, await entry.modifiedModel.promise, await entry.originalModel.promise);
|
|
429
|
+
}
|
|
430
|
+
const finishPreviousCells = () => {
|
|
431
|
+
this.editedCells.forEach(uri => {
|
|
432
|
+
const cell = this.modifiedModel.cells.find(cell => isEqual(cell.uri, uri));
|
|
433
|
+
const cellEntry = cell && this.cellEntryMap.get(cell.uri);
|
|
434
|
+
cellEntry?.acceptAgentEdits([], true, responseModel);
|
|
435
|
+
});
|
|
436
|
+
this.editedCells.clear();
|
|
437
|
+
};
|
|
438
|
+
this._applyEditsSync(async () => {
|
|
439
|
+
});
|
|
440
|
+
if (isLastEdits) {
|
|
441
|
+
finishPreviousCells();
|
|
442
|
+
}
|
|
443
|
+
isLastEdits = !isCellUri && isLastEdits;
|
|
444
|
+
if (isLastEdits && this.newNotebookEditGenerator) {
|
|
445
|
+
const notebookEdits = await this.newNotebookEditGenerator.generateEdits();
|
|
446
|
+
this.newNotebookEditGenerator = undefined;
|
|
447
|
+
notebookEdits.forEach(edit => this.acceptNotebookEdit(edit));
|
|
448
|
+
}
|
|
449
|
+
transaction((tx) => {
|
|
450
|
+
if (!isLastEdits) {
|
|
451
|
+
this._stateObs.set(WorkingSetEntryState.Modified, tx);
|
|
452
|
+
this._isCurrentlyBeingModifiedByObs.set(responseModel, tx);
|
|
453
|
+
const newRewriteRation = Math.max(this._rewriteRatioObs.get(), calculateNotebookRewriteRatio(this._cellsDiffInfo.get(), this.originalModel, this.modifiedModel));
|
|
454
|
+
this._rewriteRatioObs.set(Math.min(1, newRewriteRation), tx);
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
finishPreviousCells();
|
|
458
|
+
this.editedCells.clear();
|
|
459
|
+
this._resetEditsState(tx);
|
|
460
|
+
this._rewriteRatioObs.set(1, tx);
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
disposeDeletedCellEntries() {
|
|
465
|
+
const cellsUris = ( new ResourceSet(( this.modifiedModel.cells.map(cell => cell.uri))));
|
|
466
|
+
Array.from(( this.cellEntryMap.keys())).forEach(uri => {
|
|
467
|
+
if (( cellsUris.has(uri))) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
this.cellEntryMap.get(uri)?.dispose();
|
|
471
|
+
this.cellEntryMap.delete(uri);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
acceptNotebookEdit(edit) {
|
|
475
|
+
this.modifiedModel.applyEdits([edit], true, undefined, () => undefined, undefined, false);
|
|
476
|
+
this.disposeDeletedCellEntries();
|
|
477
|
+
if (edit.editType !== CellEditType.Replace) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
edit.cells.forEach((_, i) => {
|
|
481
|
+
const index = edit.index + i;
|
|
482
|
+
const cell = this.modifiedModel.cells[index];
|
|
483
|
+
if (cell.internalMetadata.internalId) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const internalId = generateCellHash(cell.uri);
|
|
487
|
+
const edits = [{ editType: CellEditType.PartialInternalMetadata, index, internalMetadata: { internalId } }];
|
|
488
|
+
this.modifiedModel.applyEdits(edits, true, undefined, () => undefined, undefined, false);
|
|
489
|
+
});
|
|
490
|
+
let diff = [];
|
|
491
|
+
if (edit.count === 0) {
|
|
492
|
+
diff = sortCellChanges(this._cellsDiffInfo.get());
|
|
493
|
+
diff.forEach(d => {
|
|
494
|
+
if (d.type !== 'delete' && d.modifiedCellIndex >= edit.index) {
|
|
495
|
+
d.modifiedCellIndex += edit.cells.length;
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
const diffInsert = ( edit.cells.map((_, i) => this.createInsertedCellDiffInfo(edit.index + i)));
|
|
499
|
+
diff.splice(edit.index, 0, ...diffInsert);
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
diff = ( sortCellChanges(this._cellsDiffInfo.get()).map((d) => {
|
|
503
|
+
if (d.type === 'unchanged' && d.modifiedCellIndex >= edit.index && d.modifiedCellIndex <= (edit.index + edit.count - 1)) {
|
|
504
|
+
return this.createDeleteCellDiffInfo(d.originalCellIndex);
|
|
505
|
+
}
|
|
506
|
+
if (d.type !== 'delete' && d.modifiedCellIndex >= (edit.index + edit.count)) {
|
|
507
|
+
d.modifiedCellIndex -= edit.count;
|
|
508
|
+
return d;
|
|
509
|
+
}
|
|
510
|
+
return d;
|
|
511
|
+
}));
|
|
512
|
+
}
|
|
513
|
+
this.updateCellDiffInfo(diff, undefined);
|
|
514
|
+
}
|
|
515
|
+
computeStateAfterAcceptingRejectingChanges(accepted) {
|
|
516
|
+
const currentSnapshot = createSnapshot(this.modifiedModel, this.transientOptions, this.configurationService);
|
|
517
|
+
if (( new SnapshotComparer(currentSnapshot)).isEqual(this.originalModel)) {
|
|
518
|
+
const state = accepted ? WorkingSetEntryState.Accepted : WorkingSetEntryState.Rejected;
|
|
519
|
+
this._stateObs.set(state, undefined);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
createModifiedCellDiffInfo(modifiedCellIndex, originalCellIndex) {
|
|
523
|
+
const modifiedCell = this.modifiedModel.cells[modifiedCellIndex];
|
|
524
|
+
const originalCell = this.originalModel.cells[originalCellIndex];
|
|
525
|
+
this.modifiedToOriginalCell.set(modifiedCell.uri, originalCell.uri);
|
|
526
|
+
const modifiedCellModelPromise = this.resolveCellModel(modifiedCell.uri);
|
|
527
|
+
const originalCellModelPromise = this.resolveCellModel(originalCell.uri);
|
|
528
|
+
Promise.all([modifiedCellModelPromise, originalCellModelPromise]).then(([modifiedCellModel, originalCellModel]) => {
|
|
529
|
+
this.getOrCreateModifiedTextFileEntryForCell(modifiedCell, modifiedCellModel, originalCellModel);
|
|
530
|
+
});
|
|
531
|
+
const diff = observableValue('diff', nullDocumentDiff);
|
|
532
|
+
const unchangedCell = {
|
|
533
|
+
type: 'unchanged',
|
|
534
|
+
modifiedCellIndex,
|
|
535
|
+
originalCellIndex,
|
|
536
|
+
keep: async (changes) => {
|
|
537
|
+
const [modifiedCellModel, originalCellModel] = await Promise.all([modifiedCellModelPromise, originalCellModelPromise]);
|
|
538
|
+
const entry = this.getOrCreateModifiedTextFileEntryForCell(modifiedCell, modifiedCellModel, originalCellModel);
|
|
539
|
+
return entry ? entry.keep(changes) : false;
|
|
540
|
+
},
|
|
541
|
+
undo: async (changes) => {
|
|
542
|
+
const [modifiedCellModel, originalCellModel] = await Promise.all([modifiedCellModelPromise, originalCellModelPromise]);
|
|
543
|
+
const entry = this.getOrCreateModifiedTextFileEntryForCell(modifiedCell, modifiedCellModel, originalCellModel);
|
|
544
|
+
return entry ? entry.undo(changes) : false;
|
|
545
|
+
},
|
|
546
|
+
modifiedModel: ( new ObservablePromise(modifiedCellModelPromise)),
|
|
547
|
+
originalModel: ( new ObservablePromise(originalCellModelPromise)),
|
|
548
|
+
diff
|
|
549
|
+
};
|
|
550
|
+
return unchangedCell;
|
|
551
|
+
}
|
|
552
|
+
createInsertedCellDiffInfo(modifiedCellIndex) {
|
|
553
|
+
const cell = this.modifiedModel.cells[modifiedCellIndex];
|
|
554
|
+
const lines = cell.getValue().split(/\r?\n/);
|
|
555
|
+
const originalRange = ( new Range(1, 0, 1, 0));
|
|
556
|
+
const modifiedRange = ( new Range(1, 0, lines.length, lines[lines.length - 1].length));
|
|
557
|
+
const innerChanges = ( new RangeMapping(originalRange, modifiedRange));
|
|
558
|
+
const changes = [( new DetailedLineRangeMapping(( new LineRange(1, 1)), ( new LineRange(1, lines.length)), [innerChanges]))];
|
|
559
|
+
const originalModelUri = this.modifiedModel.uri.with({ query: ( (ChatEditingModifiedNotebookEntry_1.NewModelCounter++).toString()), scheme: 'emptyCell' });
|
|
560
|
+
const originalModel = this.modelService.getModel(originalModelUri) || this._register(this.modelService.createModel('', null, originalModelUri));
|
|
561
|
+
this.modifiedToOriginalCell.set(cell.uri, originalModelUri);
|
|
562
|
+
const keep = async () => {
|
|
563
|
+
this._applyEditsSync(() => this.keepPreviouslyInsertedCell(cell));
|
|
564
|
+
this.computeStateAfterAcceptingRejectingChanges(true);
|
|
565
|
+
return true;
|
|
566
|
+
};
|
|
567
|
+
const undo = async () => {
|
|
568
|
+
this._applyEditsSync(() => this.undoPreviouslyInsertedCell(cell));
|
|
569
|
+
this.computeStateAfterAcceptingRejectingChanges(false);
|
|
570
|
+
return true;
|
|
571
|
+
};
|
|
572
|
+
this.resolveCellModel(cell.uri).then(modifiedModel => {
|
|
573
|
+
this.getOrCreateModifiedTextFileEntryForCell(cell, modifiedModel, originalModel);
|
|
574
|
+
});
|
|
575
|
+
return {
|
|
576
|
+
type: 'insert',
|
|
577
|
+
originalCellIndex: undefined,
|
|
578
|
+
modifiedCellIndex: modifiedCellIndex,
|
|
579
|
+
keep,
|
|
580
|
+
undo,
|
|
581
|
+
modifiedModel: ( new ObservablePromise(this.resolveCellModel(cell.uri))),
|
|
582
|
+
originalModel: ( new ObservablePromise(Promise.resolve(originalModel))),
|
|
583
|
+
diff: observableValue('deletedCellDiff', {
|
|
584
|
+
changes,
|
|
585
|
+
identical: false,
|
|
586
|
+
moves: [],
|
|
587
|
+
quitEarly: false,
|
|
588
|
+
})
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
createDeleteCellDiffInfo(originalCellIndex) {
|
|
592
|
+
const originalCell = this.originalModel.cells[originalCellIndex];
|
|
593
|
+
const lines = ( ( new Array(originalCell.textBuffer.getLineCount())).fill(0).map((_, i) => originalCell.textBuffer.getLineContent(i + 1)));
|
|
594
|
+
const originalRange = ( new Range(1, 0, lines.length, lines[lines.length - 1].length));
|
|
595
|
+
const modifiedRange = ( new Range(1, 0, 1, 0));
|
|
596
|
+
const innerChanges = ( new RangeMapping(modifiedRange, originalRange));
|
|
597
|
+
const changes = [( new DetailedLineRangeMapping(( new LineRange(1, lines.length)), ( new LineRange(1, 1)), [innerChanges]))];
|
|
598
|
+
const modifiedModelUri = this.modifiedModel.uri.with({ query: ( (ChatEditingModifiedNotebookEntry_1.NewModelCounter++).toString()), scheme: 'emptyCell' });
|
|
599
|
+
const modifiedModel = this.modelService.getModel(modifiedModelUri) || this._register(this.modelService.createModel('', null, modifiedModelUri));
|
|
600
|
+
const keep = async () => {
|
|
601
|
+
this._applyEditsSync(() => this.keepPreviouslyDeletedCell(this.originalModel.cells.indexOf(originalCell)));
|
|
602
|
+
this.computeStateAfterAcceptingRejectingChanges(true);
|
|
603
|
+
return true;
|
|
604
|
+
};
|
|
605
|
+
const undo = async () => {
|
|
606
|
+
this._applyEditsSync(() => this.undoPreviouslyDeletedCell(this.originalModel.cells.indexOf(originalCell), originalCell));
|
|
607
|
+
this.computeStateAfterAcceptingRejectingChanges(false);
|
|
608
|
+
return true;
|
|
609
|
+
};
|
|
610
|
+
return {
|
|
611
|
+
type: 'delete',
|
|
612
|
+
modifiedCellIndex: undefined,
|
|
613
|
+
originalCellIndex,
|
|
614
|
+
originalModel: ( new ObservablePromise(this.resolveCellModel(originalCell.uri))),
|
|
615
|
+
modifiedModel: ( new ObservablePromise(Promise.resolve(modifiedModel))),
|
|
616
|
+
keep,
|
|
617
|
+
undo,
|
|
618
|
+
diff: observableValue('cellDiff', {
|
|
619
|
+
changes,
|
|
620
|
+
identical: false,
|
|
621
|
+
moves: [],
|
|
622
|
+
quitEarly: false,
|
|
623
|
+
})
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
undoPreviouslyInsertedCell(cell) {
|
|
627
|
+
let diffs = [];
|
|
628
|
+
this._applyEditsSync(() => {
|
|
629
|
+
const index = this.modifiedModel.cells.indexOf(cell);
|
|
630
|
+
diffs = adjustCellDiffForRevertingAnInsertedCell(index, this._cellsDiffInfo.get(), this.modifiedModel.applyEdits.bind(this.modifiedModel));
|
|
631
|
+
});
|
|
632
|
+
this.disposeDeletedCellEntries();
|
|
633
|
+
this.updateCellDiffInfo(diffs, undefined);
|
|
634
|
+
}
|
|
635
|
+
keepPreviouslyInsertedCell(cell) {
|
|
636
|
+
const modifiedCellIndex = this.modifiedModel.cells.indexOf(cell);
|
|
637
|
+
if (modifiedCellIndex === -1) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const cellToInsert = {
|
|
641
|
+
cellKind: cell.cellKind,
|
|
642
|
+
language: cell.language,
|
|
643
|
+
metadata: cell.metadata,
|
|
644
|
+
outputs: cell.outputs,
|
|
645
|
+
source: cell.getValue(),
|
|
646
|
+
mime: cell.mime,
|
|
647
|
+
internalMetadata: {
|
|
648
|
+
internalId: cell.internalMetadata.internalId
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
this.cellEntryMap.get(cell.uri)?.dispose();
|
|
652
|
+
this.cellEntryMap.delete(cell.uri);
|
|
653
|
+
const cellDiffs = adjustCellDiffForKeepingAnInsertedCell(modifiedCellIndex, this._cellsDiffInfo.get().slice(), cellToInsert, this.originalModel.applyEdits.bind(this.originalModel), this.createModifiedCellDiffInfo.bind(this));
|
|
654
|
+
this.updateCellDiffInfo(cellDiffs, undefined);
|
|
655
|
+
}
|
|
656
|
+
undoPreviouslyDeletedCell(deletedOriginalIndex, originalCell) {
|
|
657
|
+
const cellToInsert = {
|
|
658
|
+
cellKind: originalCell.cellKind,
|
|
659
|
+
language: originalCell.language,
|
|
660
|
+
metadata: originalCell.metadata,
|
|
661
|
+
outputs: originalCell.outputs,
|
|
662
|
+
source: originalCell.getValue(),
|
|
663
|
+
mime: originalCell.mime,
|
|
664
|
+
internalMetadata: {
|
|
665
|
+
internalId: originalCell.internalMetadata.internalId
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
let cellDiffs = [];
|
|
669
|
+
this._applyEditsSync(() => {
|
|
670
|
+
cellDiffs = adjustCellDiffForRevertingADeletedCell(deletedOriginalIndex, this._cellsDiffInfo.get(), cellToInsert, this.modifiedModel.applyEdits.bind(this.modifiedModel), this.createModifiedCellDiffInfo.bind(this));
|
|
671
|
+
});
|
|
672
|
+
this.updateCellDiffInfo(cellDiffs, undefined);
|
|
673
|
+
}
|
|
674
|
+
keepPreviouslyDeletedCell(deletedOriginalIndex) {
|
|
675
|
+
const edit = { cells: [], count: 1, editType: CellEditType.Replace, index: deletedOriginalIndex, };
|
|
676
|
+
this.originalModel.applyEdits([edit], true, undefined, () => undefined, undefined, false);
|
|
677
|
+
const diffs = ( sortCellChanges(this._cellsDiffInfo.get())
|
|
678
|
+
.filter(d => !(d.type === 'delete' && d.originalCellIndex === deletedOriginalIndex))
|
|
679
|
+
.map(diff => {
|
|
680
|
+
if (diff.type !== 'insert' && diff.originalCellIndex > deletedOriginalIndex) {
|
|
681
|
+
return {
|
|
682
|
+
...diff,
|
|
683
|
+
originalCellIndex: diff.originalCellIndex - 1,
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
return diff;
|
|
687
|
+
}));
|
|
688
|
+
this.updateCellDiffInfo(diffs, undefined);
|
|
689
|
+
}
|
|
690
|
+
async _applyEdits(operation) {
|
|
691
|
+
this._isEditFromUs = true;
|
|
692
|
+
try {
|
|
693
|
+
await operation();
|
|
694
|
+
}
|
|
695
|
+
finally {
|
|
696
|
+
this._isEditFromUs = false;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
_applyEditsSync(operation) {
|
|
700
|
+
this._isEditFromUs = true;
|
|
701
|
+
try {
|
|
702
|
+
operation();
|
|
703
|
+
}
|
|
704
|
+
finally {
|
|
705
|
+
this._isEditFromUs = false;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
createSnapshot(requestId, undoStop) {
|
|
709
|
+
return {
|
|
710
|
+
resource: this.modifiedURI,
|
|
711
|
+
languageId: SnapshotLanguageId,
|
|
712
|
+
snapshotUri: getNotebookSnapshotFileURI(this._telemetryInfo.sessionId, requestId, undoStop, this.modifiedURI.path, this.modifiedModel.viewType),
|
|
713
|
+
original: createSnapshot(this.originalModel, this.transientOptions, this.configurationService),
|
|
714
|
+
current: createSnapshot(this.modifiedModel, this.transientOptions, this.configurationService),
|
|
715
|
+
originalToCurrentEdit: OffsetEdit.empty,
|
|
716
|
+
state: this.state.get(),
|
|
717
|
+
telemetryInfo: this.telemetryInfo,
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
equalsSnapshot(snapshot) {
|
|
721
|
+
return !!snapshot &&
|
|
722
|
+
isEqual(this.modifiedURI, snapshot.resource) &&
|
|
723
|
+
this.state.get() === snapshot.state &&
|
|
724
|
+
( new SnapshotComparer(snapshot.original)).isEqual(this.originalModel) &&
|
|
725
|
+
( new SnapshotComparer(snapshot.current)).isEqual(this.modifiedModel);
|
|
726
|
+
}
|
|
727
|
+
restoreFromSnapshot(snapshot, restoreToDisk = true) {
|
|
728
|
+
this.updateCellDiffInfo([], undefined);
|
|
729
|
+
this._stateObs.set(snapshot.state, undefined);
|
|
730
|
+
restoreSnapshot(this.originalModel, snapshot.original);
|
|
731
|
+
if (restoreToDisk) {
|
|
732
|
+
this.restoreSnapshotInModifiedModel(snapshot.current);
|
|
733
|
+
}
|
|
734
|
+
this.initializeModelsFromDiff();
|
|
735
|
+
}
|
|
736
|
+
resetToInitialContent() {
|
|
737
|
+
this.updateCellDiffInfo([], undefined);
|
|
738
|
+
this.restoreSnapshotInModifiedModel(this.initialContent);
|
|
739
|
+
this.initializeModelsFromDiff();
|
|
740
|
+
}
|
|
741
|
+
restoreSnapshotInModifiedModel(snapshot) {
|
|
742
|
+
if (snapshot === createSnapshot(this.modifiedModel, this.transientOptions, this.configurationService)) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
this._applyEditsSync(() => {
|
|
746
|
+
this.modifiedModel.pushStackElement();
|
|
747
|
+
restoreSnapshot(this.modifiedModel, snapshot);
|
|
748
|
+
this.modifiedModel.pushStackElement();
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
async resolveCellModel(cellURI) {
|
|
752
|
+
const cell = this.originalModel.cells.concat(this.modifiedModel.cells).find(cell => isEqual(cell.uri, cellURI));
|
|
753
|
+
if (!cell) {
|
|
754
|
+
throw ( new Error('Cell not found'));
|
|
755
|
+
}
|
|
756
|
+
const model = this.cellTextModelMap.get(cell.uri) || this._register(await this.textModelService.createModelReference(cell.uri)).object.textEditorModel;
|
|
757
|
+
this.cellTextModelMap.set(cell.uri, model);
|
|
758
|
+
return model;
|
|
759
|
+
}
|
|
760
|
+
getOrCreateModifiedTextFileEntryForCell(cell, modifiedCellModel, originalCellModel) {
|
|
761
|
+
let cellEntry = this.cellEntryMap.get(cell.uri);
|
|
762
|
+
if (cellEntry) {
|
|
763
|
+
return cellEntry;
|
|
764
|
+
}
|
|
765
|
+
const disposables = ( new DisposableStore());
|
|
766
|
+
cellEntry = this._register(this._instantiationService.createInstance(ChatEditingNotebookCellEntry, this.modifiedResourceRef.object.resource, cell, modifiedCellModel, originalCellModel, disposables));
|
|
767
|
+
this.cellEntryMap.set(cell.uri, cellEntry);
|
|
768
|
+
disposables.add(autorun(r => {
|
|
769
|
+
if (this.modifiedModel.cells.indexOf(cell) === -1) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
const diffs = this.cellsDiffInfo.get().slice();
|
|
773
|
+
const index = this.modifiedModel.cells.indexOf(cell);
|
|
774
|
+
let entry = diffs.find(entry => entry.modifiedCellIndex === index);
|
|
775
|
+
if (!entry) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const entryIndex = diffs.indexOf(entry);
|
|
779
|
+
entry.diff.set(cellEntry.diffInfo.read(r), undefined);
|
|
780
|
+
if (cellEntry.diffInfo.get().identical && entry.type === 'modified') {
|
|
781
|
+
entry = {
|
|
782
|
+
...entry,
|
|
783
|
+
type: 'unchanged',
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
if (!cellEntry.diffInfo.get().identical && entry.type === 'unchanged') {
|
|
787
|
+
entry = {
|
|
788
|
+
...entry,
|
|
789
|
+
type: 'modified',
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
diffs.splice(entryIndex, 1, { ...entry });
|
|
793
|
+
transaction(tx => {
|
|
794
|
+
this.updateCellDiffInfo(diffs, tx);
|
|
795
|
+
});
|
|
796
|
+
}));
|
|
797
|
+
disposables.add(autorun(r => {
|
|
798
|
+
if (this.modifiedModel.cells.indexOf(cell) === -1) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
const cellState = cellEntry.state.read(r);
|
|
802
|
+
if (cellState === WorkingSetEntryState.Accepted) {
|
|
803
|
+
this.computeStateAfterAcceptingRejectingChanges(true);
|
|
804
|
+
}
|
|
805
|
+
else if (cellState === WorkingSetEntryState.Rejected) {
|
|
806
|
+
this.computeStateAfterAcceptingRejectingChanges(false);
|
|
807
|
+
}
|
|
808
|
+
}));
|
|
809
|
+
return cellEntry;
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
ChatEditingModifiedNotebookEntry = ChatEditingModifiedNotebookEntry_1 = ( __decorate([
|
|
813
|
+
( __param(7, IConfigurationService)),
|
|
814
|
+
( __param(8, IFilesConfigurationService)),
|
|
815
|
+
( __param(9, IChatService)),
|
|
816
|
+
( __param(10, IFileService)),
|
|
817
|
+
( __param(11, IInstantiationService)),
|
|
818
|
+
( __param(12, ITextModelService)),
|
|
819
|
+
( __param(13, IModelService)),
|
|
820
|
+
( __param(14, IUndoRedoService)),
|
|
821
|
+
( __param(15, INotebookEditorWorkerService)),
|
|
822
|
+
( __param(16, INotebookLoggingService)),
|
|
823
|
+
( __param(17, INotebookEditorModelResolverService))
|
|
824
|
+
], ChatEditingModifiedNotebookEntry));
|
|
825
|
+
function generateCellHash(cellUri) {
|
|
826
|
+
const hash = ( new StringSHA1());
|
|
827
|
+
hash.update(( cellUri.toString()));
|
|
828
|
+
return hash.digest().substring(0, 8);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
export { ChatEditingModifiedNotebookEntry };
|