@opensumi/ide-ai-native 3.7.1-next-1739781685.0 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/ai-core.contextkeys.d.ts +0 -1
- package/lib/browser/ai-core.contextkeys.d.ts.map +1 -1
- package/lib/browser/ai-core.contextkeys.js +0 -1
- package/lib/browser/ai-core.contextkeys.js.map +1 -1
- package/lib/browser/ai-core.contribution.d.ts +1 -2
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +15 -60
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/components/ChatMarkdown.d.ts.map +1 -1
- package/lib/browser/components/ChatMarkdown.js.map +1 -1
- package/lib/browser/components/WelcomeMsg.js.map +1 -1
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/contrib/intelligent-completions/index.d.ts +9 -14
- package/lib/browser/contrib/intelligent-completions/index.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/index.js +1 -6
- package/lib/browser/contrib/intelligent-completions/index.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts +0 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js +4 -26
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts +4 -5
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +42 -50
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts +3 -9
- package/lib/browser/contrib/intelligent-completions/source/base.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/base.js +3 -21
- package/lib/browser/contrib/intelligent-completions/source/base.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts +3 -10
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js +22 -95
- package/lib/browser/contrib/intelligent-completions/source/line-change.source.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.d.ts +3 -1
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.js +20 -13
- package/lib/browser/contrib/intelligent-completions/source/lint-error.source.js.map +1 -1
- package/lib/browser/contrib/terminal/component/terminal-command-suggest-controller.js +2 -2
- package/lib/browser/contrib/terminal/component/terminal-command-suggest-controller.js.map +1 -1
- package/lib/browser/index.js +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/languages/tree-sitter/wasm-manager.d.ts.map +1 -1
- package/lib/browser/languages/tree-sitter/wasm-manager.js +2 -14
- package/lib/browser/languages/tree-sitter/wasm-manager.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +2 -2
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/layout/layout.module.less +9 -9
- package/lib/browser/layout/tabbar.view.d.ts.map +1 -1
- package/lib/browser/layout/tabbar.view.js +6 -5
- package/lib/browser/layout/tabbar.view.js.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.d.ts +10 -14
- package/lib/browser/model/enhanceDecorationsCollection.d.ts.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.js +53 -42
- package/lib/browser/model/enhanceDecorationsCollection.js.map +1 -1
- package/lib/browser/model/styles.module.less +7 -0
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +0 -4
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +2 -7
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts +1 -2
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js +48 -20
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.d.ts +13 -3
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.js +72 -24
- package/lib/browser/widget/inline-chat/inline-chat.feature.registry.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts +6 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.service.js +17 -5
- package/lib/browser/widget/inline-chat/inline-chat.service.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts +5 -2
- package/lib/browser/widget/inline-chat/inline-content-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-content-widget.js +42 -17
- package/lib/browser/widget/inline-chat/inline-content-widget.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +5 -22
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +30 -61
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +12 -8
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +96 -68
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts +1 -0
- package/lib/browser/widget/inline-hint/inline-hint.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.js +5 -0
- package/lib/browser/widget/inline-hint/inline-hint.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts +2 -12
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.js +18 -26
- package/lib/browser/widget/inline-input/inline-input-widget.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts +5 -14
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.js +165 -321
- package/lib/browser/widget/inline-input/inline-input.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.module.less +0 -4
- package/lib/browser/widget/inline-input/inline-input.service.d.ts +7 -19
- package/lib/browser/widget/inline-input/inline-input.service.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.service.js +12 -72
- package/lib/browser/widget/inline-input/inline-input.service.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +19 -8
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js +39 -44
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +4 -17
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js +5 -37
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +11 -7
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +77 -33
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/utils.js +2 -2
- package/lib/common/utils.js.map +1 -1
- package/package.json +21 -21
- package/src/browser/ai-core.contextkeys.ts +0 -3
- package/src/browser/ai-core.contribution.ts +17 -68
- package/src/browser/components/ChatMarkdown.tsx +1 -1
- package/src/browser/components/WelcomeMsg.tsx +1 -1
- package/src/browser/contrib/intelligent-completions/index.ts +4 -16
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +8 -29
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +55 -86
- package/src/browser/contrib/intelligent-completions/source/base.ts +7 -28
- package/src/browser/contrib/intelligent-completions/source/line-change.source.ts +22 -129
- package/src/browser/contrib/intelligent-completions/source/lint-error.source.ts +31 -19
- package/src/browser/contrib/terminal/component/terminal-command-suggest-controller.tsx +1 -1
- package/src/browser/index.ts +2 -2
- package/src/browser/languages/tree-sitter/wasm-manager.ts +2 -12
- package/src/browser/layout/ai-layout.tsx +2 -5
- package/src/browser/layout/layout.module.less +9 -9
- package/src/browser/layout/tabbar.view.tsx +8 -10
- package/src/browser/model/enhanceDecorationsCollection.ts +77 -62
- package/src/browser/model/styles.module.less +7 -0
- package/src/browser/preferences/schema.ts +0 -4
- package/src/browser/types.ts +3 -5
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +64 -29
- package/src/browser/widget/inline-chat/inline-chat.feature.registry.ts +90 -23
- package/src/browser/widget/inline-chat/inline-chat.service.ts +17 -2
- package/src/browser/widget/inline-chat/inline-content-widget.tsx +69 -14
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +32 -87
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +114 -90
- package/src/browser/widget/inline-hint/inline-hint.controller.ts +7 -1
- package/src/browser/widget/inline-input/inline-input-widget.tsx +12 -34
- package/src/browser/widget/inline-input/inline-input.controller.ts +242 -454
- package/src/browser/widget/inline-input/inline-input.module.less +0 -4
- package/src/browser/widget/inline-input/inline-input.service.ts +13 -92
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +67 -54
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +6 -45
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +112 -40
- package/src/common/utils.ts +2 -2
- package/lib/browser/contrib/intelligent-completions/source/typing.source.d.ts +0 -9
- package/lib/browser/contrib/intelligent-completions/source/typing.source.d.ts.map +0 -1
- package/lib/browser/contrib/intelligent-completions/source/typing.source.js +0 -36
- package/lib/browser/contrib/intelligent-completions/source/typing.source.js.map +0 -1
- package/lib/browser/widget/inline-input/model.d.ts +0 -34
- package/lib/browser/widget/inline-input/model.d.ts.map +0 -1
- package/lib/browser/widget/inline-input/model.js +0 -63
- package/lib/browser/widget/inline-input/model.js.map +0 -1
- package/src/browser/contrib/intelligent-completions/source/typing.source.ts +0 -34
- package/src/browser/widget/inline-input/model.ts +0 -74
|
@@ -15,10 +15,18 @@ import { StandaloneServices } from '@opensumi/ide-monaco/lib/browser/monaco-api/
|
|
|
15
15
|
import { EditOperation } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/editOperation';
|
|
16
16
|
import { LineRange } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/lineRange';
|
|
17
17
|
import { ModelDecorationOptions } from '@opensumi/monaco-editor-core/esm/vs/editor/common/model/textModel';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
IUndoRedoService,
|
|
20
|
+
ResourceEditStackSnapshot,
|
|
21
|
+
UndoRedoGroup,
|
|
22
|
+
} from '@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo';
|
|
19
23
|
|
|
20
24
|
import { AINativeContextKey } from '../../ai-core.contextkeys';
|
|
21
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
EnhanceDecorationsCollection,
|
|
27
|
+
IDecorationSerializableState,
|
|
28
|
+
IEnhanceModelDeltaDecoration,
|
|
29
|
+
} from '../../model/enhanceDecorationsCollection';
|
|
22
30
|
import { InlineDiffService } from '../inline-diff';
|
|
23
31
|
|
|
24
32
|
import styles from './inline-stream-diff.module.less';
|
|
@@ -28,7 +36,6 @@ import {
|
|
|
28
36
|
AcceptPartialEditWidget,
|
|
29
37
|
ActiveLineDecoration,
|
|
30
38
|
AddedRangeDecoration,
|
|
31
|
-
AddedRangeDecorationsCollection,
|
|
32
39
|
EPartialEdit,
|
|
33
40
|
IPartialEditEvent,
|
|
34
41
|
IPartialEditWidgetOptions,
|
|
@@ -39,6 +46,14 @@ import {
|
|
|
39
46
|
RemovedZoneWidget,
|
|
40
47
|
} from './live-preview.component';
|
|
41
48
|
|
|
49
|
+
export interface ILivePreviewDiffDecorationSnapshotData {
|
|
50
|
+
addedDecList: IEnhanceModelDeltaDecoration[];
|
|
51
|
+
partialEditWidgetList: AcceptPartialEditWidget[];
|
|
52
|
+
removedWidgetList: RemovedZoneWidget[];
|
|
53
|
+
editStackSnapshot: ResourceEditStackSnapshot;
|
|
54
|
+
zone: LineRange;
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
export interface ITotalCodeInfo {
|
|
43
58
|
totalAddedLinesCount: number;
|
|
44
59
|
totalDeletedLinesCount: number;
|
|
@@ -82,7 +97,8 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
82
97
|
|
|
83
98
|
protected model: ITextModel;
|
|
84
99
|
|
|
85
|
-
|
|
100
|
+
// Parts that require snapshots
|
|
101
|
+
private addedRangeDec: EnhanceDecorationsCollection;
|
|
86
102
|
private partialEditWidgetList: AcceptPartialEditWidget[] = [];
|
|
87
103
|
private removedZoneWidgets: RemovedZoneWidget[] = [];
|
|
88
104
|
private zone: LineRange;
|
|
@@ -92,11 +108,12 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
92
108
|
this.model = this.monacoEditor.getModel()!;
|
|
93
109
|
|
|
94
110
|
this.undoRedoService = StandaloneServices.get(IUndoRedoService);
|
|
95
|
-
this.aiNativeContextKey = this.injector.get(AINativeContextKey, [this.monacoEditor.contextKeyService]);
|
|
96
111
|
|
|
97
112
|
this.activeLineDec = this.monacoEditor.createDecorationsCollection();
|
|
98
113
|
this.pendingRangeDec = this.monacoEditor.createDecorationsCollection();
|
|
99
114
|
|
|
115
|
+
this.aiNativeContextKey = this.injector.get(AINativeContextKey, [this.monacoEditor.contextKeyService]);
|
|
116
|
+
|
|
100
117
|
this.addDispose(
|
|
101
118
|
this.inlineStreamDiffService.onAcceptDiscardPartialEdit((isAccept) => {
|
|
102
119
|
const currentPosition = this.monacoEditor.getPosition()!;
|
|
@@ -122,13 +139,13 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
122
139
|
}),
|
|
123
140
|
);
|
|
124
141
|
|
|
125
|
-
this.addedRangeDec = new
|
|
142
|
+
this.addedRangeDec = new EnhanceDecorationsCollection(this.monacoEditor);
|
|
126
143
|
this.addDispose(
|
|
127
144
|
this.addedRangeDec.onDidDecorationsChange((newAddedRangeDec) => {
|
|
128
145
|
const inlineDiffPartialEditsIsVisible = this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.get();
|
|
129
146
|
if (inlineDiffPartialEditsIsVisible) {
|
|
130
147
|
this.partialEditWidgetList.forEach((widget) => {
|
|
131
|
-
const addedWidget = newAddedRangeDec.find((a) => widget.
|
|
148
|
+
const addedWidget = newAddedRangeDec.find((a) => widget.getDecorationId() === a.id);
|
|
132
149
|
if (addedWidget) {
|
|
133
150
|
const range = addedWidget.getRange();
|
|
134
151
|
/**
|
|
@@ -142,7 +159,11 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
142
159
|
}),
|
|
143
160
|
);
|
|
144
161
|
|
|
145
|
-
this.addDispose(
|
|
162
|
+
this.addDispose(
|
|
163
|
+
Disposable.create(() => {
|
|
164
|
+
this.clear();
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
146
167
|
}
|
|
147
168
|
|
|
148
169
|
clear() {
|
|
@@ -153,30 +174,82 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
153
174
|
this.clearPartialEditWidgetList();
|
|
154
175
|
}
|
|
155
176
|
|
|
156
|
-
|
|
157
|
-
this.
|
|
158
|
-
this.partialEditWidgetList.forEach((widget) => widget.hide());
|
|
159
|
-
this.removedZoneWidgets.forEach((widget) => widget.hide());
|
|
160
|
-
|
|
161
|
-
this.activeLineDec.clear();
|
|
162
|
-
this.pendingRangeDec.clear();
|
|
177
|
+
initialize(zone: LineRange): void {
|
|
178
|
+
this.updateZone(zone);
|
|
163
179
|
}
|
|
164
180
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*/
|
|
168
|
-
resume() {
|
|
169
|
-
this.addedRangeDec.getDecorations().forEach((dec) => dec.status === 'pending' && dec.resume());
|
|
170
|
-
this.partialEditWidgetList.forEach((widget) => widget.status === 'pending' && widget.resume());
|
|
171
|
-
this.removedZoneWidgets.forEach((widget) => widget.status === 'pending' && widget.resume());
|
|
181
|
+
getRemovedWidgets(): RemovedZoneWidget[] {
|
|
182
|
+
return this.removedZoneWidgets;
|
|
172
183
|
}
|
|
173
184
|
|
|
174
|
-
|
|
185
|
+
restoreSnapshot(snapshot: ILivePreviewDiffDecorationSnapshotData): void {
|
|
186
|
+
const {
|
|
187
|
+
addedDecList,
|
|
188
|
+
removedWidgetList,
|
|
189
|
+
zone,
|
|
190
|
+
editStackSnapshot,
|
|
191
|
+
partialEditWidgetList: snapshotPartialEditWidgetList,
|
|
192
|
+
} = snapshot;
|
|
193
|
+
|
|
194
|
+
// restore zone
|
|
175
195
|
this.updateZone(zone);
|
|
196
|
+
|
|
197
|
+
// restore added
|
|
198
|
+
this.addedRangeDec.set(addedDecList);
|
|
199
|
+
|
|
200
|
+
// restore removed
|
|
201
|
+
this.clearRemovedWidgets();
|
|
202
|
+
removedWidgetList.forEach((widget) => {
|
|
203
|
+
const position = widget.getLastPosition();
|
|
204
|
+
if (position) {
|
|
205
|
+
this.showRemovedWidgetByLineNumber(position.lineNumber, widget.textLines, {
|
|
206
|
+
isHidden: widget.isHidden,
|
|
207
|
+
recordPosition: widget.getLastPosition(),
|
|
208
|
+
undoRedoGroup: widget.group,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// restore partial edit widget
|
|
214
|
+
this.clearPartialEditWidgetList();
|
|
215
|
+
snapshotPartialEditWidgetList.forEach((snapshotWidget) => {
|
|
216
|
+
const lineNumber = snapshotWidget.getPosition()?.position?.lineNumber;
|
|
217
|
+
if (lineNumber) {
|
|
218
|
+
const newPartialEditWidget = this.createPartialEditWidget(lineNumber);
|
|
219
|
+
|
|
220
|
+
if (snapshotWidget.status === 'accept') {
|
|
221
|
+
newPartialEditWidget.accept(snapshotWidget.addedLinesCount, snapshotWidget.deletedLinesCount);
|
|
222
|
+
} else if (snapshotWidget.status === 'discard') {
|
|
223
|
+
newPartialEditWidget.discard(snapshotWidget.addedLinesCount, snapshotWidget.deletedLinesCount);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
newPartialEditWidget.setGroup(snapshotWidget.group);
|
|
227
|
+
this.partialEditWidgetList.push(newPartialEditWidget);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
this.firePartialEditWidgetList();
|
|
231
|
+
this.recordPartialEditWidgetWithAddedDec();
|
|
232
|
+
|
|
233
|
+
// restore undo/redo stack
|
|
234
|
+
const uri = this.model.uri;
|
|
235
|
+
this.undoRedoService.restoreSnapshot(editStackSnapshot);
|
|
236
|
+
const elements = this.undoRedoService.getElements(uri);
|
|
237
|
+
elements.future.concat(elements.past).forEach((node) => {
|
|
238
|
+
if (node instanceof LivePreviewUndoRedoStackElement) {
|
|
239
|
+
// 在每次 restore 的时候需要将当前的类重新指向到 undo/redo 的 stack 中
|
|
240
|
+
node.attachModel(this);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
176
243
|
}
|
|
177
244
|
|
|
178
|
-
|
|
179
|
-
return
|
|
245
|
+
createSnapshot(): ILivePreviewDiffDecorationSnapshotData {
|
|
246
|
+
return {
|
|
247
|
+
addedDecList: this.addedRangeDec.getDecorations(),
|
|
248
|
+
partialEditWidgetList: this.partialEditWidgetList,
|
|
249
|
+
removedWidgetList: this.removedZoneWidgets,
|
|
250
|
+
editStackSnapshot: this.undoRedoService.createSnapshot(this.model.uri),
|
|
251
|
+
zone: this.zone,
|
|
252
|
+
};
|
|
180
253
|
}
|
|
181
254
|
|
|
182
255
|
public showRemovedWidgetByLineNumber(
|
|
@@ -315,7 +388,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
315
388
|
const findAddedRangeDecByGroup = (model: LivePreviewDiffDecorationModel) =>
|
|
316
389
|
model.addedRangeDec.getDecorationByGroup(group);
|
|
317
390
|
|
|
318
|
-
let modifyContent
|
|
391
|
+
let modifyContent;
|
|
319
392
|
const removeContent = removedWidget?.getRemovedTextLines().join('\n') || '';
|
|
320
393
|
const range = addedDec?.getRange();
|
|
321
394
|
if (range) {
|
|
@@ -338,10 +411,10 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
338
411
|
});
|
|
339
412
|
}
|
|
340
413
|
const removedWidget = findRemovedWidgetByGroup(decorationModel);
|
|
341
|
-
removedWidget?.
|
|
414
|
+
removedWidget?.hide();
|
|
342
415
|
|
|
343
416
|
const addedDec = findAddedRangeDecByGroup(decorationModel);
|
|
344
|
-
addedDec?.
|
|
417
|
+
addedDec?.hide();
|
|
345
418
|
|
|
346
419
|
const partialEditWidget = findPartialWidgetByGroup(decorationModel);
|
|
347
420
|
const operation = this.doDiscardPartialWidget(partialEditWidget!, addedDec, removedWidget);
|
|
@@ -349,7 +422,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
349
422
|
return operation;
|
|
350
423
|
};
|
|
351
424
|
|
|
352
|
-
const
|
|
425
|
+
const accpet = (decorationModel: LivePreviewDiffDecorationModel) => {
|
|
353
426
|
// 只有点击行采纳时才会上报
|
|
354
427
|
if (isReport) {
|
|
355
428
|
this.aiReporter.end(relationId, {
|
|
@@ -366,10 +439,10 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
366
439
|
partialEditWidget?.accept(addedLinesCount, deletedLinesCount);
|
|
367
440
|
|
|
368
441
|
const removedWidget = findRemovedWidgetByGroup(decorationModel);
|
|
369
|
-
removedWidget?.
|
|
442
|
+
removedWidget?.hide();
|
|
370
443
|
|
|
371
444
|
const addedDec = findAddedRangeDecByGroup(decorationModel);
|
|
372
|
-
addedDec?.
|
|
445
|
+
addedDec?.hide();
|
|
373
446
|
};
|
|
374
447
|
|
|
375
448
|
const resume = (decorationModel: LivePreviewDiffDecorationModel) => {
|
|
@@ -385,7 +458,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
385
458
|
|
|
386
459
|
switch (type) {
|
|
387
460
|
case EPartialEdit.accept:
|
|
388
|
-
|
|
461
|
+
accpet(this);
|
|
389
462
|
if (isPushStack) {
|
|
390
463
|
const stack = this.createEditStackElement(group);
|
|
391
464
|
stack.attachModel(this);
|
|
@@ -393,7 +466,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
393
466
|
resume(model);
|
|
394
467
|
});
|
|
395
468
|
stack.registerRedo((model: LivePreviewDiffDecorationModel) => {
|
|
396
|
-
|
|
469
|
+
accpet(model);
|
|
397
470
|
});
|
|
398
471
|
}
|
|
399
472
|
break;
|
|
@@ -442,8 +515,8 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
442
515
|
|
|
443
516
|
private firePartialEditWidgetList(): void {
|
|
444
517
|
this._onPartialEditWidgetListChange.fire(this.partialEditWidgetList);
|
|
445
|
-
const
|
|
446
|
-
this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.set(
|
|
518
|
+
const visiableLists = this.partialEditWidgetList.filter((widget) => !widget.isHidden);
|
|
519
|
+
this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.set(visiableLists.length !== 0);
|
|
447
520
|
}
|
|
448
521
|
|
|
449
522
|
public createEditStackElement(group: UndoRedoGroup): LivePreviewUndoRedoStackElement {
|
|
@@ -462,7 +535,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
462
535
|
// 2. 删除 N 行 => N
|
|
463
536
|
// 3. 新增 M 行,删除 N 行 => max(M, N)
|
|
464
537
|
// 综上所述,变更行数 = sum(list.map(item => max(新增行数, 删除行数)))
|
|
465
|
-
const resolvedStatus =
|
|
538
|
+
const resolvedStatus = caculate(partialEditWidgetList);
|
|
466
539
|
const unresolvedStatus = { added: 0, deleted: 0, changed: 0 };
|
|
467
540
|
partialEditWidgetList.forEach((v, idx) => {
|
|
468
541
|
if (v.status === 'pending') {
|
|
@@ -485,7 +558,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
485
558
|
unresolvedChangedLinesCount: unresolvedStatus.changed,
|
|
486
559
|
};
|
|
487
560
|
|
|
488
|
-
function
|
|
561
|
+
function caculate(list: AcceptPartialEditWidget[]) {
|
|
489
562
|
const result = { added: 0, deleted: 0, changed: 0 };
|
|
490
563
|
list.forEach((widget) => {
|
|
491
564
|
const addedLinesCount = widget.addedLinesCount;
|
|
@@ -520,7 +593,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
520
593
|
if (lineNumber) {
|
|
521
594
|
const addedWidget = this.addedRangeDec.getDecorationByLineNumber(lineNumber);
|
|
522
595
|
if (addedWidget) {
|
|
523
|
-
widget.
|
|
596
|
+
widget.recordDecorationId(addedWidget.id);
|
|
524
597
|
}
|
|
525
598
|
}
|
|
526
599
|
});
|
|
@@ -603,13 +676,12 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
603
676
|
this.recordPartialEditWidgetWithAddedDec();
|
|
604
677
|
}
|
|
605
678
|
|
|
606
|
-
public touchRemovedWidget(states: IRemovedWidgetState[]
|
|
679
|
+
public touchRemovedWidget(states: IRemovedWidgetState[]) {
|
|
607
680
|
const run = () => {
|
|
608
681
|
this.clearRemovedWidgets();
|
|
609
682
|
states.forEach(({ textLines, position }) => {
|
|
610
683
|
this.showRemovedWidgetByLineNumber(position.lineNumber, textLines, {});
|
|
611
684
|
});
|
|
612
|
-
cb?.();
|
|
613
685
|
};
|
|
614
686
|
|
|
615
687
|
if (this.options.renderRemovedWidgetImmediately) {
|
package/src/common/utils.ts
CHANGED
|
@@ -32,10 +32,10 @@ export const extractCodeBlocks = (content: string): string => {
|
|
|
32
32
|
let startLine = 0;
|
|
33
33
|
|
|
34
34
|
lines.forEach((line, i) => {
|
|
35
|
-
if (!inBlock && line.
|
|
35
|
+
if (!inBlock && line.startsWith(BACK_QUOTE_3_SYMBOL)) {
|
|
36
36
|
inBlock = true;
|
|
37
37
|
startLine = i + 1;
|
|
38
|
-
} else if (inBlock && line.
|
|
38
|
+
} else if (inBlock && line.startsWith(BACK_QUOTE_3_SYMBOL)) {
|
|
39
39
|
inBlock = false;
|
|
40
40
|
const endLine = i;
|
|
41
41
|
newContents = lines.slice(startLine, endLine);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IDisposable } from '@opensumi/ide-core-common';
|
|
2
|
-
import { IModelContentChangedEvent } from '@opensumi/ide-monaco';
|
|
3
|
-
import { BaseCodeEditsSource } from './base';
|
|
4
|
-
export declare class TypingCodeEditsSource extends BaseCodeEditsSource {
|
|
5
|
-
priority: number;
|
|
6
|
-
mount(): IDisposable;
|
|
7
|
-
protected doTrigger(data: IModelContentChangedEvent): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=typing.source.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typing.source.d.ts","sourceRoot":"","sources":["../../../../../src/browser/contrib/intelligent-completions/source/typing.source.ts"],"names":[],"mappings":"AACA,OAAO,EAAqD,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,qBACa,qBAAsB,SAAQ,mBAAmB;IACrD,QAAQ,SAAK;IAEb,KAAK,IAAI,WAAW;cASX,SAAS,CAAC,IAAI,EAAE,yBAAyB;CAc1D"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypingCodeEditsSource = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@opensumi/di");
|
|
6
|
-
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
7
|
-
const base_1 = require("./base");
|
|
8
|
-
let TypingCodeEditsSource = class TypingCodeEditsSource extends base_1.BaseCodeEditsSource {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.priority = 2;
|
|
12
|
-
}
|
|
13
|
-
mount() {
|
|
14
|
-
this.addDispose(this.monacoEditor.onDidChangeModelContent((event) => {
|
|
15
|
-
this.doTrigger(event);
|
|
16
|
-
}));
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
async doTrigger(data) {
|
|
20
|
-
const isTypingEnabled = this.preferenceService.getValid(ide_core_common_1.AINativeSettingSectionsId.CodeEditsTyping, false);
|
|
21
|
-
if (!isTypingEnabled || !this.model) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
this.setBean({
|
|
25
|
-
typing: ide_core_common_1.ECodeEditsSourceTyping.Typing,
|
|
26
|
-
data: {
|
|
27
|
-
[ide_core_common_1.ECodeEditsSourceTyping.Typing]: data,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
exports.TypingCodeEditsSource = TypingCodeEditsSource;
|
|
33
|
-
exports.TypingCodeEditsSource = TypingCodeEditsSource = tslib_1.__decorate([
|
|
34
|
-
(0, di_1.Injectable)({ multiple: true })
|
|
35
|
-
], TypingCodeEditsSource);
|
|
36
|
-
//# sourceMappingURL=typing.source.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typing.source.js","sourceRoot":"","sources":["../../../../../src/browser/contrib/intelligent-completions/source/typing.source.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAC1C,+DAA2G;AAG3G,iCAA6C;AAGtC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,0BAAmB;IAAvD;;QACE,aAAQ,GAAG,CAAC,CAAC;IAyBtB,CAAC;IAvBQ,KAAK;QACV,IAAI,CAAC,UAAU,CACb,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAC,KAAgC,EAAE,EAAE;YAC7E,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC,CAAC,CACH,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAES,KAAK,CAAC,SAAS,CAAC,IAA+B;QACvD,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,2CAAyB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QAE1G,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,CAAC;YACX,MAAM,EAAE,wCAAsB,CAAC,MAAM;YACrC,IAAI,EAAE;gBACJ,CAAC,wCAAsB,CAAC,MAAM,CAAC,EAAE,IAAI;aACtC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA1BY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAU,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GAClB,qBAAqB,CA0BjC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { MaybePromise } from '@opensumi/ide-core-common';
|
|
2
|
-
import { ICodeEditor, IPosition, Selection } from '@opensumi/ide-monaco';
|
|
3
|
-
import { ERunStrategy, IInteractiveInputHandler } from '../../types';
|
|
4
|
-
type TRunStrategyFn = (editor: ICodeEditor, value: string) => MaybePromise<ERunStrategy>;
|
|
5
|
-
export declare class InteractiveInputModel {
|
|
6
|
-
static ID: string;
|
|
7
|
-
private _handler;
|
|
8
|
-
private _strategyHandler;
|
|
9
|
-
setHandler(h: IInteractiveInputHandler): void;
|
|
10
|
-
handler(): IInteractiveInputHandler | undefined;
|
|
11
|
-
setStrategyHandler(fn: TRunStrategyFn): void;
|
|
12
|
-
strategyHandler(): TRunStrategyFn;
|
|
13
|
-
dispose(): void;
|
|
14
|
-
}
|
|
15
|
-
export declare class InlineInputWidgetStoreInEmptyLine {
|
|
16
|
-
private position;
|
|
17
|
-
private value?;
|
|
18
|
-
constructor(position: IPosition, value?: string | undefined);
|
|
19
|
-
getPosition(): IPosition;
|
|
20
|
-
setPosition(position: IPosition): void;
|
|
21
|
-
getValue(): string | undefined;
|
|
22
|
-
setValue(value: string): void;
|
|
23
|
-
}
|
|
24
|
-
export declare class InlineInputWidgetStoreInSelection {
|
|
25
|
-
private selection;
|
|
26
|
-
private value?;
|
|
27
|
-
constructor(selection: Selection, value?: string | undefined);
|
|
28
|
-
getSelection(): Selection;
|
|
29
|
-
setSelection(selection: Selection): void;
|
|
30
|
-
getValue(): string | undefined;
|
|
31
|
-
setValue(value: string): void;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../src/browser/widget/inline-input/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAQ,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAErE,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC,YAAY,CAAC,CAAC;AAEzF,qBAAa,qBAAqB;IAChC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAgD;IAEjE,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,CAAC,gBAAgB,CAAiB;IAElC,UAAU,CAAC,CAAC,EAAE,wBAAwB,GAAG,IAAI;IAI7C,OAAO,IAAI,wBAAwB,GAAG,SAAS;IAI/C,kBAAkB,CAAC,EAAE,EAAE,cAAc,GAAG,IAAI;IAI5C,eAAe,IAAI,cAAc;IAIjC,OAAO,IAAI,IAAI;CAGvB;AAED,qBAAa,iCAAiC;IAChC,OAAO,CAAC,QAAQ;IAAa,OAAO,CAAC,KAAK,CAAC;gBAAnC,QAAQ,EAAE,SAAS,EAAU,KAAK,CAAC,EAAE,MAAM,YAAA;IAExD,WAAW,IAAI,SAAS;IAIxB,WAAW,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI;IAItC,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAGrC;AAED,qBAAa,iCAAiC;IAChC,OAAO,CAAC,SAAS;IAAa,OAAO,CAAC,KAAK,CAAC;gBAApC,SAAS,EAAE,SAAS,EAAU,KAAK,CAAC,EAAE,MAAM,YAAA;IAEzD,YAAY,IAAI,SAAS;IAIzB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIxC,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAGrC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InlineInputWidgetStoreInSelection = exports.InlineInputWidgetStoreInEmptyLine = exports.InteractiveInputModel = void 0;
|
|
4
|
-
const ai_native_1 = require("@opensumi/ide-core-browser/lib/components/ai-native");
|
|
5
|
-
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
6
|
-
class InteractiveInputModel {
|
|
7
|
-
setHandler(h) {
|
|
8
|
-
this._handler = h;
|
|
9
|
-
}
|
|
10
|
-
handler() {
|
|
11
|
-
return this._handler;
|
|
12
|
-
}
|
|
13
|
-
setStrategyHandler(fn) {
|
|
14
|
-
this._strategyHandler = fn;
|
|
15
|
-
}
|
|
16
|
-
strategyHandler() {
|
|
17
|
-
return this._strategyHandler;
|
|
18
|
-
}
|
|
19
|
-
dispose() {
|
|
20
|
-
this._handler = undefined;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.InteractiveInputModel = InteractiveInputModel;
|
|
24
|
-
InteractiveInputModel.ID = `${ai_native_1.InteractiveInput.displayName}:${(0, ide_core_common_1.uuid)(4)}`;
|
|
25
|
-
class InlineInputWidgetStoreInEmptyLine {
|
|
26
|
-
constructor(position, value) {
|
|
27
|
-
this.position = position;
|
|
28
|
-
this.value = value;
|
|
29
|
-
}
|
|
30
|
-
getPosition() {
|
|
31
|
-
return this.position;
|
|
32
|
-
}
|
|
33
|
-
setPosition(position) {
|
|
34
|
-
this.position = position;
|
|
35
|
-
}
|
|
36
|
-
getValue() {
|
|
37
|
-
return this.value;
|
|
38
|
-
}
|
|
39
|
-
setValue(value) {
|
|
40
|
-
this.value = value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.InlineInputWidgetStoreInEmptyLine = InlineInputWidgetStoreInEmptyLine;
|
|
44
|
-
class InlineInputWidgetStoreInSelection {
|
|
45
|
-
constructor(selection, value) {
|
|
46
|
-
this.selection = selection;
|
|
47
|
-
this.value = value;
|
|
48
|
-
}
|
|
49
|
-
getSelection() {
|
|
50
|
-
return this.selection;
|
|
51
|
-
}
|
|
52
|
-
setSelection(selection) {
|
|
53
|
-
this.selection = selection;
|
|
54
|
-
}
|
|
55
|
-
getValue() {
|
|
56
|
-
return this.value;
|
|
57
|
-
}
|
|
58
|
-
setValue(value) {
|
|
59
|
-
this.value = value;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.InlineInputWidgetStoreInSelection = InlineInputWidgetStoreInSelection;
|
|
63
|
-
//# sourceMappingURL=model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../src/browser/widget/inline-input/model.ts"],"names":[],"mappings":";;;AAAA,mFAAuF;AACvF,+DAA+D;AAO/D,MAAa,qBAAqB;IAMzB,UAAU,CAAC,CAA2B;QAC3C,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IACpB,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEM,kBAAkB,CAAC,EAAkB;QAC1C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC7B,CAAC;IAEM,eAAe;QACpB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;;AAxBH,sDAyBC;AAxBQ,wBAAE,GAAW,GAAG,4BAAgB,CAAC,WAAW,IAAI,IAAA,sBAAI,EAAC,CAAC,CAAC,EAAE,CAAC;AA0BnE,MAAa,iCAAiC;IAC5C,YAAoB,QAAmB,EAAU,KAAc;QAA3C,aAAQ,GAAR,QAAQ,CAAW;QAAU,UAAK,GAAL,KAAK,CAAS;IAAG,CAAC;IAE5D,WAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEM,WAAW,CAAC,QAAmB;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,QAAQ,CAAC,KAAa;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAlBD,8EAkBC;AAED,MAAa,iCAAiC;IAC5C,YAAoB,SAAoB,EAAU,KAAc;QAA5C,cAAS,GAAT,SAAS,CAAW;QAAU,UAAK,GAAL,KAAK,CAAS;IAAG,CAAC;IAE7D,YAAY;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEM,YAAY,CAAC,SAAoB;QACtC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,QAAQ,CAAC,KAAa;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAlBD,8EAkBC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@opensumi/di';
|
|
2
|
-
import { AINativeSettingSectionsId, ECodeEditsSourceTyping, IDisposable } from '@opensumi/ide-core-common';
|
|
3
|
-
import { IModelContentChangedEvent } from '@opensumi/ide-monaco';
|
|
4
|
-
|
|
5
|
-
import { BaseCodeEditsSource } from './base';
|
|
6
|
-
|
|
7
|
-
@Injectable({ multiple: true })
|
|
8
|
-
export class TypingCodeEditsSource extends BaseCodeEditsSource {
|
|
9
|
-
public priority = 2;
|
|
10
|
-
|
|
11
|
-
public mount(): IDisposable {
|
|
12
|
-
this.addDispose(
|
|
13
|
-
this.monacoEditor.onDidChangeModelContent((event: IModelContentChangedEvent) => {
|
|
14
|
-
this.doTrigger(event);
|
|
15
|
-
}),
|
|
16
|
-
);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
protected async doTrigger(data: IModelContentChangedEvent) {
|
|
21
|
-
const isTypingEnabled = this.preferenceService.getValid(AINativeSettingSectionsId.CodeEditsTyping, false);
|
|
22
|
-
|
|
23
|
-
if (!isTypingEnabled || !this.model) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
this.setBean({
|
|
28
|
-
typing: ECodeEditsSourceTyping.Typing,
|
|
29
|
-
data: {
|
|
30
|
-
[ECodeEditsSourceTyping.Typing]: data,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { InteractiveInput } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
2
|
-
import { MaybePromise, uuid } from '@opensumi/ide-core-common';
|
|
3
|
-
import { ICodeEditor, IPosition, Selection } from '@opensumi/ide-monaco';
|
|
4
|
-
|
|
5
|
-
import { ERunStrategy, IInteractiveInputHandler } from '../../types';
|
|
6
|
-
|
|
7
|
-
type TRunStrategyFn = (editor: ICodeEditor, value: string) => MaybePromise<ERunStrategy>;
|
|
8
|
-
|
|
9
|
-
export class InteractiveInputModel {
|
|
10
|
-
static ID: string = `${InteractiveInput.displayName}:${uuid(4)}`;
|
|
11
|
-
|
|
12
|
-
private _handler: IInteractiveInputHandler | undefined;
|
|
13
|
-
private _strategyHandler: TRunStrategyFn;
|
|
14
|
-
|
|
15
|
-
public setHandler(h: IInteractiveInputHandler): void {
|
|
16
|
-
this._handler = h;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public handler(): IInteractiveInputHandler | undefined {
|
|
20
|
-
return this._handler;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public setStrategyHandler(fn: TRunStrategyFn): void {
|
|
24
|
-
this._strategyHandler = fn;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public strategyHandler(): TRunStrategyFn {
|
|
28
|
-
return this._strategyHandler;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public dispose(): void {
|
|
32
|
-
this._handler = undefined;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class InlineInputWidgetStoreInEmptyLine {
|
|
37
|
-
constructor(private position: IPosition, private value?: string) {}
|
|
38
|
-
|
|
39
|
-
public getPosition(): IPosition {
|
|
40
|
-
return this.position;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public setPosition(position: IPosition): void {
|
|
44
|
-
this.position = position;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public getValue(): string | undefined {
|
|
48
|
-
return this.value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public setValue(value: string): void {
|
|
52
|
-
this.value = value;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export class InlineInputWidgetStoreInSelection {
|
|
57
|
-
constructor(private selection: Selection, private value?: string) {}
|
|
58
|
-
|
|
59
|
-
public getSelection(): Selection {
|
|
60
|
-
return this.selection;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public setSelection(selection: Selection): void {
|
|
64
|
-
this.selection = selection;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public getValue(): string | undefined {
|
|
68
|
-
return this.value;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public setValue(value: string): void {
|
|
72
|
-
this.value = value;
|
|
73
|
-
}
|
|
74
|
-
}
|