@codingame/monaco-vscode-chat-service-override 2.0.3 → 2.1.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/chat.js +6 -2
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +20 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +14 -59
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +4 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +0 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +11 -16
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +24 -15
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +7 -8
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +106 -115
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +17 -7
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +236 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +210 -0
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditor.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.js +0 -250
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
3
|
-
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
4
|
-
import { GlyphMarginLane } from 'vscode/vscode/vs/editor/common/model';
|
|
5
|
-
import { ModelDecorationOptions } from 'vscode/vscode/vs/editor/common/model/textModel';
|
|
6
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
7
|
-
import { registerIcon } from 'vscode/vscode/vs/platform/theme/common/iconRegistry';
|
|
8
|
-
import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
9
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
10
|
-
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
11
|
-
import { GutterActionsRegistry } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/editorLineNumberMenu';
|
|
12
|
-
import { Action } from 'vscode/vscode/vs/base/common/actions';
|
|
13
|
-
import { IInlineChatService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
14
|
-
import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
|
|
15
|
-
import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
|
|
16
|
-
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
17
|
-
import { IInlineChatSessionService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSession';
|
|
18
|
-
import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
|
|
19
|
-
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
20
|
-
import { LOCALIZED_START_INLINE_CHAT_STRING } from './inlineChatActions.js';
|
|
21
|
-
import { IDebugService } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
|
|
22
|
-
import { IPreferencesService } from 'vscode/vscode/vs/workbench/services/preferences/common/preferences';
|
|
23
|
-
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
24
|
-
|
|
25
|
-
var InlineChatDecorationsContribution_1;
|
|
26
|
-
const GUTTER_INLINE_CHAT_OPAQUE_ICON = registerIcon('inline-chat-opaque', Codicon.sparkle, ( localizeWithPath(
|
|
27
|
-
'vs/workbench/contrib/inlineChat/browser/inlineChatDecorations',
|
|
28
|
-
'startInlineChatOpaqueIcon',
|
|
29
|
-
'Icon which spawns the inline chat from the gutter. It is half opaque by default and becomes completely opaque on hover.'
|
|
30
|
-
)));
|
|
31
|
-
const GUTTER_INLINE_CHAT_TRANSPARENT_ICON = registerIcon('inline-chat-transparent', Codicon.sparkle, ( localizeWithPath(
|
|
32
|
-
'vs/workbench/contrib/inlineChat/browser/inlineChatDecorations',
|
|
33
|
-
'startInlineChatTransparentIcon',
|
|
34
|
-
'Icon which spawns the inline chat from the gutter. It is transparent by default and becomes opaque on hover.'
|
|
35
|
-
)));
|
|
36
|
-
let InlineChatDecorationsContribution = class InlineChatDecorationsContribution extends Disposable {
|
|
37
|
-
static { InlineChatDecorationsContribution_1 = this; }
|
|
38
|
-
static { this.TOOLBAR_SETTING_ID = 'inlineChat.showToolbarIcon'; }
|
|
39
|
-
static { this.GUTTER_SETTING_ID = 'inlineChat.showGutterIcon'; }
|
|
40
|
-
static { this.GUTTER_ICON_OPAQUE_CLASSNAME = 'codicon-inline-chat-opaque'; }
|
|
41
|
-
static { this.GUTTER_ICON_TRANSPARENT_CLASSNAME = 'codicon-inline-chat-transparent'; }
|
|
42
|
-
constructor(_editor, _contextKeyService, _inlineChatService, _inlineChatSessionService, _configurationService, _keybindingService, _debugService) {
|
|
43
|
-
super();
|
|
44
|
-
this._editor = _editor;
|
|
45
|
-
this._inlineChatService = _inlineChatService;
|
|
46
|
-
this._inlineChatSessionService = _inlineChatSessionService;
|
|
47
|
-
this._configurationService = _configurationService;
|
|
48
|
-
this._keybindingService = _keybindingService;
|
|
49
|
-
this._debugService = _debugService;
|
|
50
|
-
this._currentBreakpoints = [];
|
|
51
|
-
this._hasInlineChatSession = false;
|
|
52
|
-
this._hasActiveDebugSession = false;
|
|
53
|
-
this._debugSessions = ( new Set());
|
|
54
|
-
this._localToDispose = ( new DisposableStore());
|
|
55
|
-
this._gutterDecorationTransparent = this._registerGutterDecoration(true);
|
|
56
|
-
this._gutterDecorationOpaque = this._registerGutterDecoration(false);
|
|
57
|
-
this._register(this._configurationService.onDidChangeConfiguration((e) => {
|
|
58
|
-
if (!e.affectsConfiguration(InlineChatDecorationsContribution_1.GUTTER_SETTING_ID)) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this._onEnablementOrModelChanged();
|
|
62
|
-
}));
|
|
63
|
-
this._register(this._inlineChatSessionService.onWillStartSession((e) => {
|
|
64
|
-
if (e === this._editor) {
|
|
65
|
-
this._hasInlineChatSession = true;
|
|
66
|
-
this._onEnablementOrModelChanged();
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
69
|
-
this._register(this._inlineChatSessionService.onDidEndSession((e) => {
|
|
70
|
-
if (e === this._editor) {
|
|
71
|
-
this._hasInlineChatSession = false;
|
|
72
|
-
this._onEnablementOrModelChanged();
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
this._register(this._debugService.onWillNewSession((session) => {
|
|
76
|
-
this._debugSessions.add(session);
|
|
77
|
-
if (!this._hasActiveDebugSession) {
|
|
78
|
-
this._hasActiveDebugSession = true;
|
|
79
|
-
this._onEnablementOrModelChanged();
|
|
80
|
-
}
|
|
81
|
-
}));
|
|
82
|
-
this._register(this._debugService.onDidEndSession((session) => {
|
|
83
|
-
this._debugSessions.delete(session);
|
|
84
|
-
if (this._debugSessions.size === 0) {
|
|
85
|
-
this._hasActiveDebugSession = false;
|
|
86
|
-
this._onEnablementOrModelChanged();
|
|
87
|
-
}
|
|
88
|
-
}));
|
|
89
|
-
this._register(this._inlineChatService.onDidChangeProviders(() => this._onEnablementOrModelChanged()));
|
|
90
|
-
this._register(this._editor.onDidChangeModel(() => this._onEnablementOrModelChanged()));
|
|
91
|
-
this._register(this._keybindingService.onDidUpdateKeybindings(() => {
|
|
92
|
-
this._updateDecorationHover();
|
|
93
|
-
this._onEnablementOrModelChanged();
|
|
94
|
-
}));
|
|
95
|
-
this._updateDecorationHover();
|
|
96
|
-
this._onEnablementOrModelChanged();
|
|
97
|
-
}
|
|
98
|
-
_registerGutterDecoration(isTransparent) {
|
|
99
|
-
return ModelDecorationOptions.register({
|
|
100
|
-
description: 'inline-chat-decoration',
|
|
101
|
-
glyphMarginClassName: ThemeIcon.asClassName(isTransparent ? GUTTER_INLINE_CHAT_TRANSPARENT_ICON : GUTTER_INLINE_CHAT_OPAQUE_ICON),
|
|
102
|
-
glyphMargin: { position: GlyphMarginLane.Left },
|
|
103
|
-
stickiness: 1 ,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
_updateDecorationHover() {
|
|
107
|
-
const keybinding = this._keybindingService.lookupKeybinding('inlineChat.start')?.getLabel() ?? undefined;
|
|
108
|
-
if (this._inlineChatKeybinding === keybinding) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this._inlineChatKeybinding = keybinding;
|
|
112
|
-
const hoverMessage = ( new MarkdownString(keybinding ? ( localizeWithPath(
|
|
113
|
-
'vs/workbench/contrib/inlineChat/browser/inlineChatDecorations',
|
|
114
|
-
'runWithKeybinding',
|
|
115
|
-
'Start Inline Chat ({0})',
|
|
116
|
-
keybinding
|
|
117
|
-
)) : LOCALIZED_START_INLINE_CHAT_STRING));
|
|
118
|
-
this._gutterDecorationTransparent.glyphMarginHoverMessage = hoverMessage;
|
|
119
|
-
this._gutterDecorationOpaque.glyphMarginHoverMessage = hoverMessage;
|
|
120
|
-
}
|
|
121
|
-
_updateCurrentBreakpoints(uri) {
|
|
122
|
-
this._currentBreakpoints = this._debugService.getModel().getBreakpoints({ uri });
|
|
123
|
-
}
|
|
124
|
-
_onEnablementOrModelChanged() {
|
|
125
|
-
this._localToDispose.clear();
|
|
126
|
-
if (!this._editor.hasModel() || this._hasActiveDebugSession || this._hasInlineChatSession || this._showGutterIconMode() === "never" || !this._hasProvider()) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const editor = this._editor;
|
|
130
|
-
const decorationUpdateScheduler = ( new RunOnceScheduler(() => this._onSelectionOrContentChanged(editor), 100));
|
|
131
|
-
this._localToDispose.add(decorationUpdateScheduler);
|
|
132
|
-
this._localToDispose.add(this._debugService.getModel().onDidChangeBreakpoints(() => {
|
|
133
|
-
this._updateCurrentBreakpoints(editor.getModel().uri);
|
|
134
|
-
decorationUpdateScheduler.schedule();
|
|
135
|
-
}));
|
|
136
|
-
this._localToDispose.add(this._editor.onDidChangeCursorSelection(() => decorationUpdateScheduler.schedule()));
|
|
137
|
-
this._localToDispose.add(this._editor.onDidChangeModelContent(() => decorationUpdateScheduler.schedule()));
|
|
138
|
-
this._localToDispose.add(this._editor.onMouseDown(async (e) => {
|
|
139
|
-
const showGutterIconMode = this._showGutterIconMode();
|
|
140
|
-
const gutterDecorationClassName = showGutterIconMode === "always" ?
|
|
141
|
-
InlineChatDecorationsContribution_1.GUTTER_ICON_OPAQUE_CLASSNAME :
|
|
142
|
-
(showGutterIconMode === "mouseover" ?
|
|
143
|
-
InlineChatDecorationsContribution_1.GUTTER_ICON_TRANSPARENT_CLASSNAME : undefined);
|
|
144
|
-
if (!gutterDecorationClassName || !e.target.element?.classList.contains(gutterDecorationClassName)) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
InlineChatController.get(this._editor)?.run();
|
|
148
|
-
}));
|
|
149
|
-
this._localToDispose.add({
|
|
150
|
-
dispose: () => {
|
|
151
|
-
if (this._gutterDecorationID) {
|
|
152
|
-
this._removeGutterDecoration(this._gutterDecorationID);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
this._updateCurrentBreakpoints(editor.getModel().uri);
|
|
157
|
-
decorationUpdateScheduler.schedule();
|
|
158
|
-
}
|
|
159
|
-
_onSelectionOrContentChanged(editor) {
|
|
160
|
-
const selection = editor.getSelection();
|
|
161
|
-
const startLineNumber = selection.startLineNumber;
|
|
162
|
-
const model = editor.getModel();
|
|
163
|
-
let isEnabled = false;
|
|
164
|
-
const hasBreakpoint = ( this._currentBreakpoints.some(bp => bp.lineNumber === startLineNumber));
|
|
165
|
-
if (!hasBreakpoint) {
|
|
166
|
-
const selectionIsEmpty = selection.isEmpty();
|
|
167
|
-
if (selectionIsEmpty) {
|
|
168
|
-
if (/^\s*$/g.test(model.getLineContent(startLineNumber))) {
|
|
169
|
-
isEnabled = true;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
const startPosition = selection.getStartPosition();
|
|
174
|
-
const endPosition = selection.getEndPosition();
|
|
175
|
-
const startWord = model.getWordAtPosition(startPosition);
|
|
176
|
-
const endWord = model.getWordAtPosition(endPosition);
|
|
177
|
-
const isFirstWordCoveredOrNull = !!startWord ? startPosition.column <= startWord.startColumn : true;
|
|
178
|
-
const isLastWordCoveredOrNull = !!endWord ? endPosition.column >= endWord.endColumn : true;
|
|
179
|
-
isEnabled = isFirstWordCoveredOrNull && isLastWordCoveredOrNull;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (isEnabled) {
|
|
183
|
-
if (this._gutterDecorationID === undefined) {
|
|
184
|
-
this._addGutterDecoration(startLineNumber);
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
const decorationRange = model.getDecorationRange(this._gutterDecorationID);
|
|
188
|
-
if (decorationRange?.startLineNumber !== startLineNumber) {
|
|
189
|
-
this._updateGutterDecoration(this._gutterDecorationID, startLineNumber);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
else if (this._gutterDecorationID) {
|
|
194
|
-
this._removeGutterDecoration(this._gutterDecorationID);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
_showGutterIconMode() {
|
|
198
|
-
return this._configurationService.getValue(InlineChatDecorationsContribution_1.GUTTER_SETTING_ID);
|
|
199
|
-
}
|
|
200
|
-
_hasProvider() {
|
|
201
|
-
return !Iterable.isEmpty(this._inlineChatService.getAllProvider());
|
|
202
|
-
}
|
|
203
|
-
_addGutterDecoration(lineNumber) {
|
|
204
|
-
this._editor.changeDecorations((accessor) => {
|
|
205
|
-
const showGutterIconMode = this._showGutterIconMode();
|
|
206
|
-
if (showGutterIconMode === "never" ) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
this._gutterDecorationID = accessor.addDecoration(( new Range(lineNumber, 0, lineNumber, 0)), showGutterIconMode === "always" ? this._gutterDecorationOpaque : this._gutterDecorationTransparent);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
_removeGutterDecoration(decorationId) {
|
|
213
|
-
this._editor.changeDecorations((accessor) => {
|
|
214
|
-
accessor.removeDecoration(decorationId);
|
|
215
|
-
});
|
|
216
|
-
this._gutterDecorationID = undefined;
|
|
217
|
-
}
|
|
218
|
-
_updateGutterDecoration(decorationId, lineNumber) {
|
|
219
|
-
this._editor.changeDecorations((accessor) => {
|
|
220
|
-
accessor.changeDecoration(decorationId, ( new Range(lineNumber, 0, lineNumber, 0)));
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
dispose() {
|
|
224
|
-
super.dispose();
|
|
225
|
-
this._localToDispose.dispose();
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
InlineChatDecorationsContribution = InlineChatDecorationsContribution_1 = ( __decorate([
|
|
229
|
-
( __param(1, IContextKeyService)),
|
|
230
|
-
( __param(2, IInlineChatService)),
|
|
231
|
-
( __param(3, IInlineChatSessionService)),
|
|
232
|
-
( __param(4, IConfigurationService)),
|
|
233
|
-
( __param(5, IKeybindingService)),
|
|
234
|
-
( __param(6, IDebugService))
|
|
235
|
-
], InlineChatDecorationsContribution));
|
|
236
|
-
GutterActionsRegistry.registerGutterActionsGenerator(({ lineNumber, editor, accessor }, result) => {
|
|
237
|
-
const inlineChatService = accessor.get(IInlineChatService);
|
|
238
|
-
const noProviders = Iterable.isEmpty(inlineChatService.getAllProvider());
|
|
239
|
-
if (noProviders) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
const preferencesService = accessor.get(IPreferencesService);
|
|
243
|
-
result.push(( new Action('inlineChat.configureShowGutterIcon', ( localizeWithPath(
|
|
244
|
-
'vs/workbench/contrib/inlineChat/browser/inlineChatDecorations',
|
|
245
|
-
'configureShowGutterIcon',
|
|
246
|
-
"Configure Inline Chat Icon"
|
|
247
|
-
)), undefined, true, () => { preferencesService.openUserSettings({ query: 'inlineChat.showGutterIcon' }); })));
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
export { InlineChatDecorationsContribution };
|