@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/chatEditingCodeEditorIntegration.js
ADDED
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import '../media/chatEditorController.css';
|
|
4
|
+
import { getTotalWidth } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
5
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
6
|
+
import { DisposableStore, toDisposable, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
8
|
+
import { isEqual, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
9
|
+
import { themeColorFromId } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
10
|
+
import { MouseTargetType } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser';
|
|
11
|
+
import { observableCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/observableCodeEditor';
|
|
12
|
+
import { AccessibleDiffViewer } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/diffEditor/components/accessibleDiffViewer';
|
|
13
|
+
import { RenderOptions, LineSource, renderLines } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/diffEditor/components/diffEditorViewZones/renderLines';
|
|
14
|
+
import { diffAddDecoration, diffWholeLineAddDecoration, diffDeleteDecoration } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/diffEditor/registrations.contribution';
|
|
15
|
+
import { EditorOption } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions';
|
|
16
|
+
import { LineRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/lineRange';
|
|
17
|
+
import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
|
|
18
|
+
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
19
|
+
import { Selection } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/selection';
|
|
20
|
+
import { TrackedRangeStickiness, MinimapPosition, OverviewRulerLane } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
|
|
21
|
+
import { ModelDecorationOptions } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel';
|
|
22
|
+
import { InlineDecoration, InlineDecorationType } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/viewModel';
|
|
23
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
24
|
+
import { AccessibilitySignal } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
|
|
25
|
+
import { IAccessibilitySignalService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
|
|
26
|
+
import { MenuWorkbenchToolBar, HiddenItemStrategy } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/toolbar';
|
|
27
|
+
import { MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
28
|
+
import { TextEditorSelectionRevealType } from '@codingame/monaco-vscode-api/vscode/vs/platform/editor/common/editor';
|
|
29
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
30
|
+
import { EditorsOrder, isDiffEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
|
|
31
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
32
|
+
import { overviewRulerModifiedForeground, minimapGutterModifiedBackground, overviewRulerAddedForeground, minimapGutterAddedBackground, overviewRulerDeletedForeground, minimapGutterDeletedBackground } from '@codingame/monaco-vscode-ae8a8ca1-f243-508b-9c37-c88ebbd295fa-common/vscode/vs/workbench/contrib/scm/common/quickDiff';
|
|
33
|
+
import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
34
|
+
import { WorkingSetEntryState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
|
|
35
|
+
import { isTextDiffEditorForEntry } from './chatEditing.js';
|
|
36
|
+
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
37
|
+
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
|
|
38
|
+
import { autorun, autorunWithStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
|
39
|
+
import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
|
|
40
|
+
import { constObservable, observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
|
|
41
|
+
|
|
42
|
+
var ChatEditingCodeEditorIntegration_1, DiffHunkWidget_1;
|
|
43
|
+
let ChatEditingCodeEditorIntegration = class ChatEditingCodeEditorIntegration {
|
|
44
|
+
static { ChatEditingCodeEditorIntegration_1 = this; }
|
|
45
|
+
static { this._diffLineDecorationData = ModelDecorationOptions.register({ description: 'diff-line-decoration' }); }
|
|
46
|
+
constructor(_entry, _editor, documentDiffInfo, _chatAgentService, _editorService, _accessibilitySignalsService, instantiationService) {
|
|
47
|
+
this._entry = _entry;
|
|
48
|
+
this._editor = _editor;
|
|
49
|
+
this._chatAgentService = _chatAgentService;
|
|
50
|
+
this._editorService = _editorService;
|
|
51
|
+
this._accessibilitySignalsService = _accessibilitySignalsService;
|
|
52
|
+
this._currentIndex = observableValue(this, -1);
|
|
53
|
+
this.currentIndex = this._currentIndex;
|
|
54
|
+
this._store = ( new DisposableStore());
|
|
55
|
+
this._diffHunksRenderStore = this._store.add(( new DisposableStore()));
|
|
56
|
+
this._diffHunkWidgets = [];
|
|
57
|
+
this._viewZones = [];
|
|
58
|
+
this._accessibleDiffViewVisible = observableValue(this, false);
|
|
59
|
+
this._diffLineDecorations = _editor.createDecorationsCollection();
|
|
60
|
+
const codeEditorObs = observableCodeEditor(_editor);
|
|
61
|
+
this._diffLineDecorations = this._editor.createDecorationsCollection();
|
|
62
|
+
this._diffVisualDecorations = this._editor.createDecorationsCollection();
|
|
63
|
+
const enabledObs = derived(r => {
|
|
64
|
+
if (!isEqual(codeEditorObs.model.read(r)?.uri, documentDiffInfo.read(r).modifiedModel.uri)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (this._editor.getOption(EditorOption.inDiffEditor) && !instantiationService.invokeFunction(isTextDiffEditorForEntry, _entry, this._editor)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
72
|
+
this._store.add(autorun(r => {
|
|
73
|
+
if (!enabledObs.read(r)) {
|
|
74
|
+
this._diffLineDecorations.clear();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const data = [];
|
|
78
|
+
const diff = documentDiffInfo.read(r);
|
|
79
|
+
for (const diffEntry of diff.changes) {
|
|
80
|
+
data.push({
|
|
81
|
+
range: diffEntry.modified.toInclusiveRange() ?? ( new Range(
|
|
82
|
+
diffEntry.modified.startLineNumber,
|
|
83
|
+
1,
|
|
84
|
+
diffEntry.modified.startLineNumber,
|
|
85
|
+
Number.MAX_SAFE_INTEGER
|
|
86
|
+
)),
|
|
87
|
+
options: ChatEditingCodeEditorIntegration_1._diffLineDecorationData
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
this._diffLineDecorations.set(data);
|
|
91
|
+
}));
|
|
92
|
+
let lastModifyingRequestId;
|
|
93
|
+
this._store.add(autorun(r => {
|
|
94
|
+
if (enabledObs.read(r)
|
|
95
|
+
&& !_entry.isCurrentlyBeingModifiedBy.read(r)
|
|
96
|
+
&& lastModifyingRequestId !== _entry.lastModifyingRequestId
|
|
97
|
+
&& !documentDiffInfo.read(r).identical) {
|
|
98
|
+
lastModifyingRequestId = _entry.lastModifyingRequestId;
|
|
99
|
+
const position = _editor.getPosition() ?? ( new Position(1, 1));
|
|
100
|
+
const ranges = this._diffLineDecorations.getRanges();
|
|
101
|
+
let initialIndex = ranges.findIndex(r => r.containsPosition(position));
|
|
102
|
+
if (initialIndex < 0) {
|
|
103
|
+
initialIndex = 0;
|
|
104
|
+
for (; initialIndex < ranges.length - 1; initialIndex++) {
|
|
105
|
+
const range = ranges[initialIndex];
|
|
106
|
+
if (range.endLineNumber >= position.lineNumber) {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
this._currentIndex.set(initialIndex, undefined);
|
|
112
|
+
_editor.revealRange(ranges[initialIndex]);
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
this._store.add(autorun(r => {
|
|
116
|
+
if (!enabledObs.read(r)) {
|
|
117
|
+
this._clearDiffRendering();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!_entry.isCurrentlyBeingModifiedBy.read(r)) {
|
|
121
|
+
if (!this._editor.getOption(EditorOption.inDiffEditor)) {
|
|
122
|
+
codeEditorObs.getOption(EditorOption.fontInfo).read(r);
|
|
123
|
+
codeEditorObs.getOption(EditorOption.lineHeight).read(r);
|
|
124
|
+
const reviewMode = _entry.reviewMode.read(r);
|
|
125
|
+
const diff = documentDiffInfo.read(r);
|
|
126
|
+
this._updateDiffRendering(diff, reviewMode);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this._clearDiffRendering();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}));
|
|
133
|
+
this._store.add(autorun(r => {
|
|
134
|
+
const position = codeEditorObs.positions.read(r)?.at(0);
|
|
135
|
+
if (!position || !enabledObs.read(r)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const diff = documentDiffInfo.read(r);
|
|
139
|
+
const mapping = diff.changes.find(m => m.modified.contains(position.lineNumber) || m.modified.isEmpty && m.modified.startLineNumber === position.lineNumber);
|
|
140
|
+
if (mapping?.modified.isEmpty) {
|
|
141
|
+
this._accessibilitySignalsService.playSignal(AccessibilitySignal.diffLineDeleted, { source: 'chatEditingEditor.cursorPositionChanged' });
|
|
142
|
+
}
|
|
143
|
+
else if (mapping?.original.isEmpty) {
|
|
144
|
+
this._accessibilitySignalsService.playSignal(AccessibilitySignal.diffLineInserted, { source: 'chatEditingEditor.cursorPositionChanged' });
|
|
145
|
+
}
|
|
146
|
+
else if (mapping) {
|
|
147
|
+
this._accessibilitySignalsService.playSignal(AccessibilitySignal.diffLineModified, { source: 'chatEditingEditor.cursorPositionChanged' });
|
|
148
|
+
}
|
|
149
|
+
}));
|
|
150
|
+
this._store.add(autorunWithStore((r, store) => {
|
|
151
|
+
const visible = this._accessibleDiffViewVisible.read(r);
|
|
152
|
+
if (!visible || !enabledObs.read(r)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const accessibleDiffWidget = ( new AccessibleDiffViewContainer());
|
|
156
|
+
_editor.addOverlayWidget(accessibleDiffWidget);
|
|
157
|
+
store.add(toDisposable(() => _editor.removeOverlayWidget(accessibleDiffWidget)));
|
|
158
|
+
store.add(instantiationService.createInstance(AccessibleDiffViewer, accessibleDiffWidget.getDomNode(), enabledObs, (visible, tx) => this._accessibleDiffViewVisible.set(visible, tx), constObservable(true), ( codeEditorObs.layoutInfo.map((v, r) => v.width)), ( codeEditorObs.layoutInfo.map((v, r) => v.height)), ( documentDiffInfo.map(diff => diff.changes.slice())), instantiationService.createInstance(AccessibleDiffViewerModel, documentDiffInfo, _editor)));
|
|
159
|
+
}));
|
|
160
|
+
let actualOptions;
|
|
161
|
+
const restoreActualOptions = () => {
|
|
162
|
+
if (actualOptions !== undefined) {
|
|
163
|
+
this._editor.updateOptions(actualOptions);
|
|
164
|
+
actualOptions = undefined;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
this._store.add(toDisposable(restoreActualOptions));
|
|
168
|
+
const renderAsBeingModified = derived(this, r => {
|
|
169
|
+
return enabledObs.read(r) && Boolean(_entry.isCurrentlyBeingModifiedBy.read(r));
|
|
170
|
+
});
|
|
171
|
+
this._store.add(autorun(r => {
|
|
172
|
+
const value = renderAsBeingModified.read(r);
|
|
173
|
+
if (value) {
|
|
174
|
+
actualOptions ??= {
|
|
175
|
+
readOnly: this._editor.getOption(EditorOption.readOnly),
|
|
176
|
+
stickyScroll: this._editor.getOption(EditorOption.stickyScroll),
|
|
177
|
+
codeLens: this._editor.getOption(EditorOption.codeLens),
|
|
178
|
+
guides: this._editor.getOption(EditorOption.guides)
|
|
179
|
+
};
|
|
180
|
+
this._editor.updateOptions({
|
|
181
|
+
readOnly: true,
|
|
182
|
+
stickyScroll: { enabled: false },
|
|
183
|
+
codeLens: false,
|
|
184
|
+
guides: { indentation: false, bracketPairs: false }
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
restoreActualOptions();
|
|
189
|
+
}
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
dispose() {
|
|
193
|
+
this._clear();
|
|
194
|
+
this._store.dispose();
|
|
195
|
+
}
|
|
196
|
+
_clear() {
|
|
197
|
+
this._diffLineDecorations.clear();
|
|
198
|
+
this._clearDiffRendering();
|
|
199
|
+
this._currentIndex.set(-1, undefined);
|
|
200
|
+
}
|
|
201
|
+
_clearDiffRendering() {
|
|
202
|
+
this._editor.changeViewZones((viewZoneChangeAccessor) => {
|
|
203
|
+
for (const id of this._viewZones) {
|
|
204
|
+
viewZoneChangeAccessor.removeZone(id);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
this._viewZones = [];
|
|
208
|
+
this._diffHunksRenderStore.clear();
|
|
209
|
+
this._diffVisualDecorations.clear();
|
|
210
|
+
}
|
|
211
|
+
_updateDiffRendering(diff, reviewMode) {
|
|
212
|
+
const chatDiffAddDecoration = ModelDecorationOptions.createDynamic({
|
|
213
|
+
...diffAddDecoration,
|
|
214
|
+
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
|
|
215
|
+
});
|
|
216
|
+
const chatDiffWholeLineAddDecoration = ModelDecorationOptions.createDynamic({
|
|
217
|
+
...diffWholeLineAddDecoration,
|
|
218
|
+
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
|
219
|
+
});
|
|
220
|
+
const createOverviewDecoration = (overviewRulerColor, minimapColor) => {
|
|
221
|
+
return ModelDecorationOptions.createDynamic({
|
|
222
|
+
description: 'chat-editing-decoration',
|
|
223
|
+
overviewRuler: { color: themeColorFromId(overviewRulerColor), position: OverviewRulerLane.Left },
|
|
224
|
+
minimap: { color: themeColorFromId(minimapColor), position: MinimapPosition.Gutter },
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
const modifiedDecoration = createOverviewDecoration(overviewRulerModifiedForeground, minimapGutterModifiedBackground);
|
|
228
|
+
const addedDecoration = createOverviewDecoration(overviewRulerAddedForeground, minimapGutterAddedBackground);
|
|
229
|
+
const deletedDecoration = createOverviewDecoration(overviewRulerDeletedForeground, minimapGutterDeletedBackground);
|
|
230
|
+
this._diffHunksRenderStore.clear();
|
|
231
|
+
this._diffHunkWidgets.length = 0;
|
|
232
|
+
const diffHunkDecorations = [];
|
|
233
|
+
this._editor.changeViewZones((viewZoneChangeAccessor) => {
|
|
234
|
+
for (const id of this._viewZones) {
|
|
235
|
+
viewZoneChangeAccessor.removeZone(id);
|
|
236
|
+
}
|
|
237
|
+
this._viewZones = [];
|
|
238
|
+
const modifiedVisualDecorations = [];
|
|
239
|
+
const mightContainNonBasicASCII = diff.originalModel.mightContainNonBasicASCII();
|
|
240
|
+
const mightContainRTL = diff.originalModel.mightContainRTL();
|
|
241
|
+
const renderOptions = RenderOptions.fromEditor(this._editor);
|
|
242
|
+
const editorLineCount = this._editor.getModel()?.getLineCount();
|
|
243
|
+
for (const diffEntry of diff.changes) {
|
|
244
|
+
const originalRange = diffEntry.original;
|
|
245
|
+
diff.originalModel.tokenization.forceTokenization(Math.max(1, originalRange.endLineNumberExclusive - 1));
|
|
246
|
+
const source = ( new LineSource(
|
|
247
|
+
originalRange.mapToLineArray(l => diff.originalModel.tokenization.getLineTokens(l)),
|
|
248
|
+
[],
|
|
249
|
+
mightContainNonBasicASCII,
|
|
250
|
+
mightContainRTL
|
|
251
|
+
));
|
|
252
|
+
const decorations = [];
|
|
253
|
+
if (reviewMode) {
|
|
254
|
+
for (const i of diffEntry.innerChanges || []) {
|
|
255
|
+
decorations.push(( new InlineDecoration(
|
|
256
|
+
i.originalRange.delta(-(diffEntry.original.startLineNumber - 1)),
|
|
257
|
+
diffDeleteDecoration.className,
|
|
258
|
+
InlineDecorationType.Regular
|
|
259
|
+
)));
|
|
260
|
+
if (!(i.originalRange.isEmpty() && i.originalRange.startLineNumber === 1 && i.modifiedRange.endLineNumber === editorLineCount) && !i.modifiedRange.isEmpty()) {
|
|
261
|
+
modifiedVisualDecorations.push({
|
|
262
|
+
range: i.modifiedRange, options: chatDiffAddDecoration
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const isCreatedContent = decorations.length === 1 && decorations[0].range.isEmpty() && diffEntry.original.startLineNumber === 1;
|
|
268
|
+
if (!diffEntry.modified.isEmpty && !(isCreatedContent && (diffEntry.modified.endLineNumberExclusive - 1) === editorLineCount)) {
|
|
269
|
+
modifiedVisualDecorations.push({
|
|
270
|
+
range: diffEntry.modified.toInclusiveRange(),
|
|
271
|
+
options: chatDiffWholeLineAddDecoration
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
if (diffEntry.original.isEmpty) {
|
|
275
|
+
modifiedVisualDecorations.push({
|
|
276
|
+
range: diffEntry.modified.toInclusiveRange(),
|
|
277
|
+
options: addedDecoration
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
else if (diffEntry.modified.isEmpty) {
|
|
281
|
+
modifiedVisualDecorations.push({
|
|
282
|
+
range: ( new Range(
|
|
283
|
+
diffEntry.modified.startLineNumber - 1,
|
|
284
|
+
1,
|
|
285
|
+
diffEntry.modified.startLineNumber,
|
|
286
|
+
1
|
|
287
|
+
)),
|
|
288
|
+
options: deletedDecoration
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
modifiedVisualDecorations.push({
|
|
293
|
+
range: diffEntry.modified.toInclusiveRange(),
|
|
294
|
+
options: modifiedDecoration
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
if (reviewMode) {
|
|
298
|
+
const domNode = document.createElement('div');
|
|
299
|
+
domNode.className = 'chat-editing-original-zone view-lines line-delete monaco-mouse-cursor-text';
|
|
300
|
+
const result = renderLines(source, renderOptions, decorations, domNode);
|
|
301
|
+
if (!isCreatedContent) {
|
|
302
|
+
const viewZoneData = {
|
|
303
|
+
afterLineNumber: diffEntry.modified.startLineNumber - 1,
|
|
304
|
+
heightInLines: result.heightInLines,
|
|
305
|
+
domNode,
|
|
306
|
+
ordinal: 50000 + 2
|
|
307
|
+
};
|
|
308
|
+
this._viewZones.push(viewZoneChangeAccessor.addZone(viewZoneData));
|
|
309
|
+
}
|
|
310
|
+
const widget = this._editor.invokeWithinContext(accessor => {
|
|
311
|
+
const instaService = accessor.get(IInstantiationService);
|
|
312
|
+
return instaService.createInstance(DiffHunkWidget, diff, diffEntry, this._editor.getModel().getVersionId(), this._editor, isCreatedContent ? 0 : result.heightInLines);
|
|
313
|
+
});
|
|
314
|
+
widget.layout(diffEntry.modified.startLineNumber);
|
|
315
|
+
this._diffHunkWidgets.push(widget);
|
|
316
|
+
diffHunkDecorations.push({
|
|
317
|
+
range: diffEntry.modified.toInclusiveRange() ?? ( new Range(
|
|
318
|
+
diffEntry.modified.startLineNumber,
|
|
319
|
+
1,
|
|
320
|
+
diffEntry.modified.startLineNumber,
|
|
321
|
+
Number.MAX_SAFE_INTEGER
|
|
322
|
+
)),
|
|
323
|
+
options: {
|
|
324
|
+
description: 'diff-hunk-widget',
|
|
325
|
+
stickiness: TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
this._diffVisualDecorations.set(modifiedVisualDecorations);
|
|
331
|
+
});
|
|
332
|
+
const diffHunkDecoCollection = this._editor.createDecorationsCollection(diffHunkDecorations);
|
|
333
|
+
this._diffHunksRenderStore.add(toDisposable(() => {
|
|
334
|
+
dispose(this._diffHunkWidgets);
|
|
335
|
+
this._diffHunkWidgets.length = 0;
|
|
336
|
+
diffHunkDecoCollection.clear();
|
|
337
|
+
}));
|
|
338
|
+
const positionObs = observableFromEvent(this._editor.onDidChangeCursorPosition, _ => this._editor.getPosition());
|
|
339
|
+
const activeWidgetIdx = derived(r => {
|
|
340
|
+
const position = positionObs.read(r);
|
|
341
|
+
if (!position) {
|
|
342
|
+
return -1;
|
|
343
|
+
}
|
|
344
|
+
const idx = diffHunkDecoCollection.getRanges().findIndex(r => r.containsPosition(position));
|
|
345
|
+
return idx;
|
|
346
|
+
});
|
|
347
|
+
const toggleWidget = (activeWidget) => {
|
|
348
|
+
const positionIdx = activeWidgetIdx.get();
|
|
349
|
+
for (let i = 0; i < this._diffHunkWidgets.length; i++) {
|
|
350
|
+
const widget = this._diffHunkWidgets[i];
|
|
351
|
+
widget.toggle(widget === activeWidget || i === positionIdx);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
this._diffHunksRenderStore.add(autorun(r => {
|
|
355
|
+
const idx = activeWidgetIdx.read(r);
|
|
356
|
+
const widget = this._diffHunkWidgets[idx];
|
|
357
|
+
toggleWidget(widget);
|
|
358
|
+
}));
|
|
359
|
+
this._diffHunksRenderStore.add(this._editor.onMouseMove(e => {
|
|
360
|
+
if (e.target.type === MouseTargetType.OVERLAY_WIDGET) {
|
|
361
|
+
const id = e.target.detail;
|
|
362
|
+
const widget = this._diffHunkWidgets.find(w => w.getId() === id);
|
|
363
|
+
toggleWidget(widget);
|
|
364
|
+
}
|
|
365
|
+
else if (e.target.type === MouseTargetType.CONTENT_VIEW_ZONE) {
|
|
366
|
+
const zone = e.target.detail;
|
|
367
|
+
const idx = this._viewZones.findIndex(id => id === zone.viewZoneId);
|
|
368
|
+
toggleWidget(this._diffHunkWidgets[idx]);
|
|
369
|
+
}
|
|
370
|
+
else if (e.target.position) {
|
|
371
|
+
const { position } = e.target;
|
|
372
|
+
const idx = diffHunkDecoCollection.getRanges().findIndex(r => r.containsPosition(position));
|
|
373
|
+
toggleWidget(this._diffHunkWidgets[idx]);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
toggleWidget(undefined);
|
|
377
|
+
}
|
|
378
|
+
}));
|
|
379
|
+
this._diffHunksRenderStore.add(Event.any(this._editor.onDidScrollChange, this._editor.onDidLayoutChange)(() => {
|
|
380
|
+
for (let i = 0; i < this._diffHunkWidgets.length; i++) {
|
|
381
|
+
const widget = this._diffHunkWidgets[i];
|
|
382
|
+
const range = diffHunkDecoCollection.getRange(i);
|
|
383
|
+
if (range) {
|
|
384
|
+
widget.layout(range?.startLineNumber);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
widget.dispose();
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}));
|
|
391
|
+
}
|
|
392
|
+
enableAccessibleDiffView() {
|
|
393
|
+
this._accessibleDiffViewVisible.set(true, undefined);
|
|
394
|
+
}
|
|
395
|
+
reveal(firstOrLast) {
|
|
396
|
+
const decorations = this._diffLineDecorations
|
|
397
|
+
.getRanges()
|
|
398
|
+
.sort((a, b) => Range.compareRangesUsingStarts(a, b));
|
|
399
|
+
const index = firstOrLast ? 0 : decorations.length - 1;
|
|
400
|
+
const range = decorations.at(index);
|
|
401
|
+
if (range) {
|
|
402
|
+
this._editor.setPosition(range.getStartPosition());
|
|
403
|
+
this._editor.revealRange(range);
|
|
404
|
+
this._editor.focus();
|
|
405
|
+
this._currentIndex.set(index, undefined);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
next(wrap) {
|
|
409
|
+
return this._reveal(true, !wrap);
|
|
410
|
+
}
|
|
411
|
+
previous(wrap) {
|
|
412
|
+
return this._reveal(false, !wrap);
|
|
413
|
+
}
|
|
414
|
+
_reveal(next, strict) {
|
|
415
|
+
const position = this._editor.getPosition();
|
|
416
|
+
if (!position) {
|
|
417
|
+
this._currentIndex.set(-1, undefined);
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
const decorations = this._diffLineDecorations
|
|
421
|
+
.getRanges()
|
|
422
|
+
.sort((a, b) => Range.compareRangesUsingStarts(a, b));
|
|
423
|
+
if (decorations.length === 0) {
|
|
424
|
+
this._currentIndex.set(-1, undefined);
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
let newIndex = -1;
|
|
428
|
+
for (let i = 0; i < decorations.length; i++) {
|
|
429
|
+
const range = decorations[i];
|
|
430
|
+
if (range.containsPosition(position)) {
|
|
431
|
+
newIndex = i + (next ? 1 : -1);
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
else if (Position.isBefore(position, range.getStartPosition())) {
|
|
435
|
+
newIndex = next ? i : i - 1;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
if (strict && (newIndex < 0 || newIndex >= decorations.length)) {
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
newIndex = (newIndex + decorations.length) % decorations.length;
|
|
443
|
+
this._currentIndex.set(newIndex, undefined);
|
|
444
|
+
const targetRange = decorations[newIndex];
|
|
445
|
+
const targetPosition = next ? targetRange.getStartPosition() : targetRange.getEndPosition();
|
|
446
|
+
this._editor.setPosition(targetPosition);
|
|
447
|
+
this._editor.revealPositionInCenter(targetPosition);
|
|
448
|
+
this._editor.focus();
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
_findClosestWidget() {
|
|
452
|
+
if (!this._editor.hasModel()) {
|
|
453
|
+
return undefined;
|
|
454
|
+
}
|
|
455
|
+
const lineRelativeTop = this._editor.getTopForLineNumber(this._editor.getPosition().lineNumber) - this._editor.getScrollTop();
|
|
456
|
+
let closestWidget;
|
|
457
|
+
let closestDistance = Number.MAX_VALUE;
|
|
458
|
+
for (const widget of this._diffHunkWidgets) {
|
|
459
|
+
const widgetTop = widget.getPosition()?.preference?.top;
|
|
460
|
+
if (widgetTop !== undefined) {
|
|
461
|
+
const distance = Math.abs(widgetTop - lineRelativeTop);
|
|
462
|
+
if (distance < closestDistance) {
|
|
463
|
+
closestDistance = distance;
|
|
464
|
+
closestWidget = widget;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return closestWidget;
|
|
469
|
+
}
|
|
470
|
+
rejectNearestChange(closestWidget) {
|
|
471
|
+
closestWidget = closestWidget ?? this._findClosestWidget();
|
|
472
|
+
if (closestWidget instanceof DiffHunkWidget) {
|
|
473
|
+
closestWidget.reject();
|
|
474
|
+
this.next(true);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
acceptNearestChange(closestWidget) {
|
|
478
|
+
closestWidget = closestWidget ?? this._findClosestWidget();
|
|
479
|
+
if (closestWidget instanceof DiffHunkWidget) {
|
|
480
|
+
closestWidget.accept();
|
|
481
|
+
this.next(true);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
async toggleDiff(widget) {
|
|
485
|
+
if (!this._editor.hasModel()) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
let selection = this._editor.getSelection();
|
|
489
|
+
if (widget instanceof DiffHunkWidget) {
|
|
490
|
+
const lineNumber = widget.getStartLineNumber();
|
|
491
|
+
const position = lineNumber ? ( new Position(lineNumber, 1)) : undefined;
|
|
492
|
+
if (position && !selection.containsPosition(position)) {
|
|
493
|
+
selection = Selection.fromPositions(position);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const isDiffEditor = this._editor.getOption(EditorOption.inDiffEditor);
|
|
497
|
+
if (isDiffEditor) {
|
|
498
|
+
await this._editorService.openEditor({
|
|
499
|
+
resource: this._entry.modifiedURI,
|
|
500
|
+
options: {
|
|
501
|
+
selection,
|
|
502
|
+
selectionRevealType: TextEditorSelectionRevealType.NearTopIfOutsideViewport
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
const defaultAgentName = this._chatAgentService.getDefaultAgent(ChatAgentLocation.EditingSession)?.fullName;
|
|
508
|
+
const diffEditor = await this._editorService.openEditor({
|
|
509
|
+
original: { resource: this._entry.originalURI, options: { selection: undefined } },
|
|
510
|
+
modified: { resource: this._entry.modifiedURI, options: { selection } },
|
|
511
|
+
label: defaultAgentName
|
|
512
|
+
? ( localize(
|
|
513
|
+
4652,
|
|
514
|
+
'{0} (changes from {1})',
|
|
515
|
+
basename(this._entry.modifiedURI),
|
|
516
|
+
defaultAgentName
|
|
517
|
+
))
|
|
518
|
+
: ( localize(4653, '{0} (changes from chat)', basename(this._entry.modifiedURI)))
|
|
519
|
+
});
|
|
520
|
+
if (diffEditor && diffEditor.input) {
|
|
521
|
+
diffEditor.getControl()?.setSelection(selection);
|
|
522
|
+
const d = autorun(r => {
|
|
523
|
+
const state = this._entry.state.read(r);
|
|
524
|
+
if (state === WorkingSetEntryState.Accepted || state === WorkingSetEntryState.Rejected) {
|
|
525
|
+
d.dispose();
|
|
526
|
+
const editorIdents = [];
|
|
527
|
+
for (const candidate of this._editorService.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE)) {
|
|
528
|
+
if (isDiffEditorInput(candidate.editor)
|
|
529
|
+
&& isEqual(candidate.editor.original.resource, this._entry.originalURI)
|
|
530
|
+
&& isEqual(candidate.editor.modified.resource, this._entry.modifiedURI)) {
|
|
531
|
+
editorIdents.push(candidate);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
this._editorService.closeEditors(editorIdents);
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
ChatEditingCodeEditorIntegration = ChatEditingCodeEditorIntegration_1 = ( __decorate([
|
|
542
|
+
( __param(3, IChatAgentService)),
|
|
543
|
+
( __param(4, IEditorService)),
|
|
544
|
+
( __param(5, IAccessibilitySignalService)),
|
|
545
|
+
( __param(6, IInstantiationService))
|
|
546
|
+
], ChatEditingCodeEditorIntegration));
|
|
547
|
+
let DiffHunkWidget = class DiffHunkWidget {
|
|
548
|
+
static { DiffHunkWidget_1 = this; }
|
|
549
|
+
static { this._idPool = 0; }
|
|
550
|
+
constructor(_diffInfo, _change, _versionId, _editor, _lineDelta, instaService) {
|
|
551
|
+
this._diffInfo = _diffInfo;
|
|
552
|
+
this._change = _change;
|
|
553
|
+
this._versionId = _versionId;
|
|
554
|
+
this._editor = _editor;
|
|
555
|
+
this._lineDelta = _lineDelta;
|
|
556
|
+
this._id = `diff-change-widget-${DiffHunkWidget_1._idPool++}`;
|
|
557
|
+
this._store = ( new DisposableStore());
|
|
558
|
+
this._domNode = document.createElement('div');
|
|
559
|
+
this._domNode.className = 'chat-diff-change-content-widget';
|
|
560
|
+
const toolbar = instaService.createInstance(MenuWorkbenchToolBar, this._domNode, MenuId.ChatEditingEditorHunk, {
|
|
561
|
+
telemetrySource: 'chatEditingEditorHunk',
|
|
562
|
+
hiddenItemStrategy: HiddenItemStrategy.NoHide,
|
|
563
|
+
toolbarOptions: { primaryGroup: () => true, },
|
|
564
|
+
menuOptions: {
|
|
565
|
+
renderShortTitle: true,
|
|
566
|
+
arg: this,
|
|
567
|
+
},
|
|
568
|
+
});
|
|
569
|
+
this._store.add(toolbar);
|
|
570
|
+
this._store.add(toolbar.actionRunner.onWillRun(_ => _editor.focus()));
|
|
571
|
+
this._editor.addOverlayWidget(this);
|
|
572
|
+
}
|
|
573
|
+
dispose() {
|
|
574
|
+
this._store.dispose();
|
|
575
|
+
this._editor.removeOverlayWidget(this);
|
|
576
|
+
}
|
|
577
|
+
getId() {
|
|
578
|
+
return this._id;
|
|
579
|
+
}
|
|
580
|
+
layout(startLineNumber) {
|
|
581
|
+
const lineHeight = this._editor.getOption(EditorOption.lineHeight);
|
|
582
|
+
const { contentLeft, contentWidth, verticalScrollbarWidth } = this._editor.getLayoutInfo();
|
|
583
|
+
const scrollTop = this._editor.getScrollTop();
|
|
584
|
+
this._position = {
|
|
585
|
+
stackOridinal: 1,
|
|
586
|
+
preference: {
|
|
587
|
+
top: this._editor.getTopForLineNumber(startLineNumber) - scrollTop - (lineHeight * this._lineDelta),
|
|
588
|
+
left: contentLeft + contentWidth - (2 * verticalScrollbarWidth + getTotalWidth(this._domNode))
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
this._editor.layoutOverlayWidget(this);
|
|
592
|
+
this._lastStartLineNumber = startLineNumber;
|
|
593
|
+
}
|
|
594
|
+
toggle(show) {
|
|
595
|
+
this._domNode.classList.toggle('hover', show);
|
|
596
|
+
if (this._lastStartLineNumber) {
|
|
597
|
+
this.layout(this._lastStartLineNumber);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
getDomNode() {
|
|
601
|
+
return this._domNode;
|
|
602
|
+
}
|
|
603
|
+
getPosition() {
|
|
604
|
+
return this._position ?? null;
|
|
605
|
+
}
|
|
606
|
+
getStartLineNumber() {
|
|
607
|
+
return this._lastStartLineNumber;
|
|
608
|
+
}
|
|
609
|
+
async reject() {
|
|
610
|
+
if (this._versionId !== this._editor.getModel()?.getVersionId()) {
|
|
611
|
+
return false;
|
|
612
|
+
}
|
|
613
|
+
return await this._diffInfo.undo(this._change);
|
|
614
|
+
}
|
|
615
|
+
async accept() {
|
|
616
|
+
if (this._versionId !== this._editor.getModel()?.getVersionId()) {
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
return this._diffInfo.keep(this._change);
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
DiffHunkWidget = DiffHunkWidget_1 = ( __decorate([
|
|
623
|
+
( __param(5, IInstantiationService))
|
|
624
|
+
], DiffHunkWidget));
|
|
625
|
+
class AccessibleDiffViewContainer {
|
|
626
|
+
constructor() {
|
|
627
|
+
this._domNode = document.createElement('div');
|
|
628
|
+
this._domNode.className = 'accessible-diff-view';
|
|
629
|
+
this._domNode.style.width = '100%';
|
|
630
|
+
this._domNode.style.position = 'absolute';
|
|
631
|
+
}
|
|
632
|
+
getId() {
|
|
633
|
+
return 'chatEdits.accessibleDiffView';
|
|
634
|
+
}
|
|
635
|
+
getDomNode() {
|
|
636
|
+
return this._domNode;
|
|
637
|
+
}
|
|
638
|
+
getPosition() {
|
|
639
|
+
return {
|
|
640
|
+
preference: { top: 0, left: 0 },
|
|
641
|
+
stackOridinal: 1
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
class AccessibleDiffViewerModel {
|
|
646
|
+
constructor(_documentDiffInfo, _editor) {
|
|
647
|
+
this._documentDiffInfo = _documentDiffInfo;
|
|
648
|
+
this._editor = _editor;
|
|
649
|
+
}
|
|
650
|
+
getOriginalModel() {
|
|
651
|
+
return this._documentDiffInfo.get().originalModel;
|
|
652
|
+
}
|
|
653
|
+
getOriginalOptions() {
|
|
654
|
+
return this._editor.getOptions();
|
|
655
|
+
}
|
|
656
|
+
originalReveal(range) {
|
|
657
|
+
const changes = this._documentDiffInfo.get().changes;
|
|
658
|
+
const idx = changes.findIndex(value => value.original.intersect(LineRange.fromRange(range)));
|
|
659
|
+
if (idx >= 0) {
|
|
660
|
+
range = changes[idx].modified.toInclusiveRange() ?? range;
|
|
661
|
+
}
|
|
662
|
+
this.modifiedReveal(range);
|
|
663
|
+
}
|
|
664
|
+
getModifiedModel() {
|
|
665
|
+
return this._editor.getModel();
|
|
666
|
+
}
|
|
667
|
+
getModifiedOptions() {
|
|
668
|
+
return this._editor.getOptions();
|
|
669
|
+
}
|
|
670
|
+
modifiedReveal(range) {
|
|
671
|
+
if (range) {
|
|
672
|
+
this._editor.revealRange(range);
|
|
673
|
+
this._editor.setSelection(range);
|
|
674
|
+
}
|
|
675
|
+
this._editor.focus();
|
|
676
|
+
}
|
|
677
|
+
modifiedSetSelection(range) {
|
|
678
|
+
this._editor.setSelection(range);
|
|
679
|
+
}
|
|
680
|
+
modifiedFocus() {
|
|
681
|
+
this._editor.focus();
|
|
682
|
+
}
|
|
683
|
+
getModifiedPosition() {
|
|
684
|
+
return this._editor.getPosition() ?? undefined;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export { ChatEditingCodeEditorIntegration };
|