@opensumi/ide-ai-native 3.2.5 → 3.2.6-next-1724809247.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/lib/browser/ai-core.contribution.d.ts +1 -0
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +12 -23
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/ai-editor.contribution.d.ts +1 -0
- package/lib/browser/ai-editor.contribution.d.ts.map +1 -1
- package/lib/browser/ai-editor.contribution.js +8 -0
- package/lib/browser/ai-editor.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts +1 -0
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +1 -3
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat.module.less +1 -0
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +21 -3
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +2 -2
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatMarkdown.js +1 -1
- package/lib/browser/components/ChatMarkdown.js.map +1 -1
- package/lib/browser/components/ChatThinking.d.ts.map +1 -1
- package/lib/browser/components/ChatThinking.js +2 -2
- package/lib/browser/components/ChatThinking.js.map +1 -1
- package/lib/browser/contextkey/ai-native.contextkey.service.d.ts +1 -0
- package/lib/browser/contextkey/ai-native.contextkey.service.d.ts.map +1 -1
- package/lib/browser/contextkey/ai-native.contextkey.service.js +1 -0
- package/lib/browser/contextkey/ai-native.contextkey.service.js.map +1 -1
- package/lib/browser/contrib/inline-completions/completeProvider.d.ts +4 -31
- package/lib/browser/contrib/inline-completions/completeProvider.d.ts.map +1 -1
- package/lib/browser/contrib/inline-completions/completeProvider.js +3 -224
- package/lib/browser/contrib/inline-completions/completeProvider.js.map +1 -1
- package/lib/browser/contrib/inline-completions/inline-completions.handler.d.ts +1 -3
- package/lib/browser/contrib/inline-completions/inline-completions.handler.d.ts.map +1 -1
- package/lib/browser/contrib/inline-completions/inline-completions.handler.js +8 -20
- package/lib/browser/contrib/inline-completions/inline-completions.handler.js.map +1 -1
- package/lib/browser/contrib/inline-completions/model/competionModel.d.ts +2 -2
- package/lib/browser/contrib/inline-completions/model/competionModel.d.ts.map +1 -1
- package/lib/browser/contrib/inline-completions/model/inlineCompletionRequestTask.d.ts +28 -0
- package/lib/browser/contrib/inline-completions/model/inlineCompletionRequestTask.d.ts.map +1 -0
- package/lib/browser/contrib/inline-completions/model/inlineCompletionRequestTask.js +209 -0
- package/lib/browser/contrib/inline-completions/model/inlineCompletionRequestTask.js.map +1 -0
- package/lib/browser/contrib/inline-completions/promptCache.d.ts +3 -2
- package/lib/browser/contrib/inline-completions/promptCache.d.ts.map +1 -1
- package/lib/browser/contrib/inline-completions/promptCache.js.map +1 -1
- package/lib/browser/contrib/inline-completions/service/ai-completions.service.d.ts +5 -6
- package/lib/browser/contrib/inline-completions/service/ai-completions.service.d.ts.map +1 -1
- package/lib/browser/contrib/inline-completions/service/ai-completions.service.js +33 -23
- package/lib/browser/contrib/inline-completions/service/ai-completions.service.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.d.ts +18 -0
- package/lib/browser/contrib/intelligent-completions/diff-computer.d.ts.map +1 -0
- package/lib/browser/contrib/intelligent-completions/diff-computer.js +144 -0
- package/lib/browser/contrib/intelligent-completions/diff-computer.js.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts +8 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.d.ts.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js +47 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.d.ts +15 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.d.ts.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts +8 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js +19 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.handler.d.ts +20 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.handler.d.ts.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.handler.js +94 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.handler.js.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.js +3 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.js.map +1 -0
- package/lib/browser/contrib/intelligent-completions/multi-line.decoration.d.ts +33 -0
- package/lib/browser/contrib/intelligent-completions/multi-line.decoration.d.ts.map +1 -0
- package/lib/browser/contrib/intelligent-completions/multi-line.decoration.js +258 -0
- package/lib/browser/contrib/intelligent-completions/multi-line.decoration.js.map +1 -0
- package/lib/browser/contrib/merge-conflict/merge-conflict.feature.registry.d.ts +0 -1
- package/lib/browser/contrib/merge-conflict/merge-conflict.feature.registry.d.ts.map +1 -1
- package/lib/browser/contrib/merge-conflict/merge-conflict.feature.registry.js +0 -3
- package/lib/browser/contrib/merge-conflict/merge-conflict.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +7 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +4 -4
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/layout/layout.module.less +0 -9
- package/lib/browser/model/enhanceDecorationsCollection.d.ts +38 -4
- package/lib/browser/model/enhanceDecorationsCollection.d.ts.map +1 -1
- package/lib/browser/model/enhanceDecorationsCollection.js +44 -23
- package/lib/browser/model/enhanceDecorationsCollection.js.map +1 -1
- package/lib/browser/types.d.ts +20 -13
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +0 -4
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat.handler.js +18 -10
- package/lib/browser/widget/inline-chat/inline-chat.handler.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 +45 -53
- package/lib/browser/widget/inline-chat/inline-content-widget.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +16 -14
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +98 -46
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-widget.d.ts +5 -2
- package/lib/browser/widget/inline-diff/inline-diff-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-widget.js +11 -2
- package/lib/browser/widget/inline-diff/inline-diff-widget.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.handler.d.ts +12 -13
- package/lib/browser/widget/inline-diff/inline-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.handler.js +69 -77
- package/lib/browser/widget/inline-diff/inline-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts +1 -0
- package/lib/browser/widget/inline-input/inline-input-widget.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input-widget.js +1 -0
- package/lib/browser/widget/inline-input/inline-input-widget.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.handler.js +2 -2
- package/lib/browser/widget/inline-input/inline-input.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +28 -15
- 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 +56 -31
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.module.less +9 -6
- package/lib/browser/widget/inline-stream-diff/live-preview-stack.d.ts +21 -0
- package/lib/browser/widget/inline-stream-diff/live-preview-stack.d.ts.map +1 -0
- package/lib/browser/widget/inline-stream-diff/live-preview-stack.js +41 -0
- package/lib/browser/widget/inline-stream-diff/live-preview-stack.js.map +1 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +105 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js +237 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +27 -103
- 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 +186 -370
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js.map +1 -1
- package/package.json +19 -19
- package/src/browser/ai-core.contribution.ts +12 -26
- package/src/browser/ai-editor.contribution.ts +9 -0
- package/src/browser/chat/chat-agent.service.ts +1 -3
- package/src/browser/chat/chat.module.less +1 -0
- package/src/browser/chat/chat.view.tsx +48 -3
- package/src/browser/components/ChatEditor.tsx +14 -2
- package/src/browser/components/ChatMarkdown.tsx +1 -1
- package/src/browser/components/ChatThinking.tsx +3 -1
- package/src/browser/contextkey/ai-native.contextkey.service.ts +3 -0
- package/src/browser/contrib/inline-completions/completeProvider.ts +7 -289
- package/src/browser/contrib/inline-completions/inline-completions.handler.ts +15 -22
- package/src/browser/contrib/inline-completions/model/competionModel.ts +3 -2
- package/src/browser/contrib/inline-completions/model/inlineCompletionRequestTask.ts +270 -0
- package/src/browser/contrib/inline-completions/promptCache.ts +3 -2
- package/src/browser/contrib/inline-completions/service/ai-completions.service.ts +37 -36
- package/src/browser/contrib/intelligent-completions/diff-computer.ts +185 -0
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +54 -0
- package/src/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.ts +17 -0
- package/src/browser/contrib/intelligent-completions/intelligent-completions.handler.ts +130 -0
- package/src/browser/contrib/intelligent-completions/intelligent-completions.ts +15 -0
- package/src/browser/contrib/intelligent-completions/multi-line.decoration.ts +325 -0
- package/src/browser/contrib/merge-conflict/merge-conflict.feature.registry.ts +0 -4
- package/src/browser/index.ts +8 -1
- package/src/browser/layout/ai-layout.tsx +7 -1
- package/src/browser/layout/layout.module.less +0 -9
- package/src/browser/model/enhanceDecorationsCollection.ts +71 -34
- package/src/browser/types.ts +27 -14
- package/src/browser/widget/inline-chat/inline-chat.handler.ts +20 -16
- package/src/browser/widget/inline-chat/inline-content-widget.tsx +58 -61
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +102 -62
- package/src/browser/widget/inline-diff/inline-diff-widget.tsx +36 -5
- package/src/browser/widget/inline-diff/inline-diff.handler.ts +82 -94
- package/src/browser/widget/inline-input/inline-input-widget.tsx +1 -0
- package/src/browser/widget/inline-input/inline-input.handler.ts +2 -2
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +108 -45
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.module.less +9 -6
- package/src/browser/widget/inline-stream-diff/live-preview-stack.ts +52 -0
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +388 -0
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +244 -544
- package/src/common/index.ts +2 -0
|
@@ -21,13 +21,12 @@ import { EResultKind } from '../inline-chat/inline-chat.service';
|
|
|
21
21
|
import {
|
|
22
22
|
BaseInlineDiffPreviewer,
|
|
23
23
|
IDiffPreviewerOptions,
|
|
24
|
-
IExtendedSerializedState,
|
|
25
24
|
LiveInlineDiffPreviewer,
|
|
26
25
|
SideBySideInlineDiffWidget,
|
|
27
26
|
} from '../inline-diff/inline-diff-previewer';
|
|
28
27
|
import { InlineDiffWidget } from '../inline-diff/inline-diff-widget';
|
|
29
28
|
import { InlineStreamDiffHandler } from '../inline-stream-diff/inline-stream-diff.handler';
|
|
30
|
-
import { IPartialEditEvent } from '../inline-stream-diff/live-preview.
|
|
29
|
+
import { IPartialEditEvent } from '../inline-stream-diff/live-preview.component';
|
|
31
30
|
|
|
32
31
|
@Injectable()
|
|
33
32
|
export class InlineDiffHandler extends IAIMonacoContribHandler {
|
|
@@ -51,70 +50,86 @@ export class InlineDiffHandler extends IAIMonacoContribHandler {
|
|
|
51
50
|
private readonly _onMaxLineCount = new Emitter<number>();
|
|
52
51
|
public readonly onMaxLineCount: Event<number> = this._onMaxLineCount.event;
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
monaco.ICodeEditor,
|
|
56
|
-
BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler> | undefined
|
|
57
|
-
>();
|
|
53
|
+
private previewer: BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler> | undefined;
|
|
58
54
|
|
|
59
|
-
|
|
55
|
+
private _previewerNodeStore = new Map<string, InlineStreamDiffHandler | null>();
|
|
60
56
|
|
|
61
57
|
constructor() {
|
|
62
58
|
super();
|
|
63
|
-
this.registerDispose(
|
|
59
|
+
this.registerDispose(
|
|
60
|
+
this.eventBus.on(EditorGroupCloseEvent, (e: EditorGroupCloseEvent) => {
|
|
61
|
+
const uriString = e.payload.resource.uri.toString();
|
|
62
|
+
const node = this._previewerNodeStore.get(uriString);
|
|
63
|
+
|
|
64
|
+
if (node && node.previewerOptions.disposeWhenEditorClosed) {
|
|
65
|
+
this.destroyPreviewer(uriString);
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
64
69
|
}
|
|
70
|
+
|
|
65
71
|
doContribute(): IDisposable {
|
|
66
72
|
this.logger.log('InlineDiffHandler doContribute');
|
|
67
73
|
return Disposable.NULL;
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
storeState(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
storeState(key: string) {
|
|
77
|
+
if (!this.previewer) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 存储的是快照
|
|
82
|
+
const node = this.previewer.createNodeSnapshot();
|
|
83
|
+
if (node) {
|
|
84
|
+
this._previewerNodeStore.set(key, node as InlineStreamDiffHandler);
|
|
77
85
|
}
|
|
78
|
-
return previous;
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
tryRestoreState(monacoEditor: monaco.ICodeEditor, key: string) {
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
89
|
+
const node = this._previewerNodeStore.get(key);
|
|
90
|
+
if (!node) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (node.disposed) {
|
|
95
|
+
this.destroyPreviewer(key);
|
|
84
96
|
return;
|
|
85
97
|
}
|
|
86
98
|
|
|
87
|
-
return this.restoreState(monacoEditor,
|
|
99
|
+
return this.restoreState(monacoEditor, node);
|
|
88
100
|
}
|
|
89
101
|
|
|
90
|
-
restoreState(monacoEditor: monaco.ICodeEditor,
|
|
91
|
-
const
|
|
92
|
-
if (oldDiffPreviewer) {
|
|
93
|
-
oldDiffPreviewer.dispose();
|
|
94
|
-
}
|
|
102
|
+
restoreState(monacoEditor: monaco.ICodeEditor, node: InlineStreamDiffHandler) {
|
|
103
|
+
const uri = monacoEditor.getModel()?.uri;
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
previewer.
|
|
99
|
-
|
|
105
|
+
if (uri) {
|
|
106
|
+
this.previewer = this.injector.get(LiveInlineDiffPreviewer, [monacoEditor]);
|
|
107
|
+
this.previewer.attachNode(node);
|
|
108
|
+
this.listenPreviewer(this.previewer);
|
|
100
109
|
|
|
101
|
-
|
|
110
|
+
const dispose = this.previewer.onDispose(() => {
|
|
111
|
+
this.destroyPreviewer();
|
|
112
|
+
dispose.dispose();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
registerInlineDiffFeature(editor: IEditor): IDisposable {
|
|
105
118
|
const disposable = new Disposable();
|
|
106
119
|
|
|
107
120
|
const monacoEditor = editor.monacoEditor;
|
|
121
|
+
const model = monacoEditor.getModel();
|
|
108
122
|
|
|
109
123
|
disposable.addDispose(
|
|
110
124
|
monacoEditor.onWillChangeModel((e) => {
|
|
111
125
|
if (!e.oldModelUrl) {
|
|
112
126
|
return;
|
|
113
127
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
|
|
129
|
+
const urlString = e.oldModelUrl.toString();
|
|
130
|
+
this.storeState(urlString);
|
|
131
|
+
|
|
132
|
+
this.destroyPreviewer();
|
|
118
133
|
}),
|
|
119
134
|
);
|
|
120
135
|
|
|
@@ -127,16 +142,16 @@ export class InlineDiffHandler extends IAIMonacoContribHandler {
|
|
|
127
142
|
}),
|
|
128
143
|
);
|
|
129
144
|
|
|
130
|
-
|
|
131
|
-
|
|
145
|
+
if (model) {
|
|
146
|
+
disposable.addDispose(
|
|
147
|
+
model.onWillDispose(() => {
|
|
148
|
+
const uriString = model.uri.toString();
|
|
149
|
+
this.destroyPreviewer(uriString);
|
|
150
|
+
}),
|
|
151
|
+
);
|
|
152
|
+
}
|
|
132
153
|
|
|
133
|
-
|
|
134
|
-
const leadingWhitespaceMatch = crossCode.match(/^\s*/);
|
|
135
|
-
const indent = leadingWhitespaceMatch ? leadingWhitespaceMatch[0] : ' ';
|
|
136
|
-
return answer
|
|
137
|
-
.split('\n')
|
|
138
|
-
.map((line) => `${indent}${line}`)
|
|
139
|
-
.join('\n');
|
|
154
|
+
return disposable;
|
|
140
155
|
}
|
|
141
156
|
|
|
142
157
|
showPreviewerByStream(
|
|
@@ -195,87 +210,60 @@ export class InlineDiffHandler extends IAIMonacoContribHandler {
|
|
|
195
210
|
}
|
|
196
211
|
|
|
197
212
|
createDiffPreviewer(monacoEditor: monaco.ICodeEditor, selection: monaco.Selection, options?: IDiffPreviewerOptions) {
|
|
198
|
-
let previewer: BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler>;
|
|
199
|
-
|
|
200
213
|
const inlineDiffMode = this.preferenceService.getValid<EInlineDiffPreviewMode>(
|
|
201
214
|
AINativeSettingSectionsId.InlineDiffPreviewMode,
|
|
202
215
|
EInlineDiffPreviewMode.inlineLive,
|
|
203
216
|
);
|
|
217
|
+
|
|
218
|
+
this.destroyPreviewer();
|
|
219
|
+
|
|
204
220
|
if (inlineDiffMode === EInlineDiffPreviewMode.sideBySide) {
|
|
205
|
-
previewer = this.injector.get(SideBySideInlineDiffWidget, [monacoEditor
|
|
221
|
+
this.previewer = this.injector.get(SideBySideInlineDiffWidget, [monacoEditor]);
|
|
206
222
|
} else {
|
|
207
|
-
previewer = this.injector.get(LiveInlineDiffPreviewer, [monacoEditor
|
|
223
|
+
this.previewer = this.injector.get(LiveInlineDiffPreviewer, [monacoEditor]);
|
|
208
224
|
}
|
|
209
225
|
|
|
210
|
-
previewer.
|
|
226
|
+
this.previewer.create(selection, options);
|
|
227
|
+
this.previewer.show(selection.startLineNumber - 1, selection.endLineNumber - selection.startLineNumber + 2);
|
|
211
228
|
|
|
212
|
-
|
|
229
|
+
this.listenPreviewer(this.previewer);
|
|
213
230
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (currentModel) {
|
|
217
|
-
currentModel.onWillDispose(() => {
|
|
218
|
-
previewer.dispose();
|
|
219
|
-
});
|
|
220
|
-
}
|
|
231
|
+
return this.previewer;
|
|
232
|
+
}
|
|
221
233
|
|
|
222
|
-
|
|
223
|
-
|
|
234
|
+
private listenPreviewer(previewer: BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler> | undefined) {
|
|
235
|
+
if (!previewer) {
|
|
236
|
+
return;
|
|
224
237
|
}
|
|
225
238
|
|
|
226
|
-
this._editorsStore.set(monacoEditor, previewer);
|
|
227
|
-
|
|
228
239
|
if (previewer instanceof LiveInlineDiffPreviewer) {
|
|
229
240
|
previewer.addDispose(
|
|
230
|
-
previewer.onPartialEditEvent((event) => {
|
|
241
|
+
previewer.onPartialEditEvent!((event) => {
|
|
231
242
|
this._onPartialEditEvent.fire(event);
|
|
232
243
|
}),
|
|
233
244
|
);
|
|
234
245
|
}
|
|
235
246
|
|
|
236
247
|
previewer.addDispose(previewer.onLineCount((lineCount) => this._onMaxLineCount.fire(lineCount)));
|
|
237
|
-
return previewer;
|
|
238
248
|
}
|
|
239
249
|
|
|
240
|
-
getPreviewer(
|
|
241
|
-
|
|
242
|
-
): BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler> | undefined {
|
|
243
|
-
return this._editorsStore.get(monacoEditor);
|
|
250
|
+
getPreviewer(): BaseInlineDiffPreviewer<InlineDiffWidget | InlineStreamDiffHandler> | undefined {
|
|
251
|
+
return this.previewer;
|
|
244
252
|
}
|
|
245
253
|
|
|
246
|
-
handleAction(
|
|
247
|
-
|
|
248
|
-
if (diffPreviewer) {
|
|
249
|
-
diffPreviewer.handleAction(action);
|
|
250
|
-
}
|
|
254
|
+
handleAction(action: EResultKind): void {
|
|
255
|
+
this.previewer?.handleAction(action);
|
|
251
256
|
}
|
|
252
257
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
this.
|
|
258
|
+
destroyPreviewer(uriString?: string) {
|
|
259
|
+
this.previewer?.dispose();
|
|
260
|
+
this.previewer = undefined;
|
|
261
|
+
if (uriString) {
|
|
262
|
+
this._previewerNodeStore.delete(uriString);
|
|
258
263
|
}
|
|
259
264
|
}
|
|
260
265
|
|
|
261
|
-
revealFirstDiff(
|
|
262
|
-
|
|
263
|
-
if (diffPreviewer) {
|
|
264
|
-
diffPreviewer.revealFirstDiff();
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
private async groupCloseHandler(e: EditorGroupCloseEvent) {
|
|
269
|
-
const uriString = e.payload.resource.uri.toString();
|
|
270
|
-
|
|
271
|
-
const previewer = this._editorsStore.get(e.payload.group.codeEditor.monacoEditor);
|
|
272
|
-
|
|
273
|
-
if (previewer) {
|
|
274
|
-
if (previewer.disposeWhenEditorClosed && previewer.isModel(uriString)) {
|
|
275
|
-
previewer.dispose();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
this._store.delete(uriString);
|
|
266
|
+
revealFirstDiff() {
|
|
267
|
+
this.previewer?.revealFirstDiff();
|
|
280
268
|
}
|
|
281
269
|
}
|
|
@@ -88,6 +88,7 @@ export class InlineInputChatWidget extends AIInlineContentWidget {
|
|
|
88
88
|
@Autowired(InlineInputChatService)
|
|
89
89
|
private inlineInputChatService: InlineInputChatService;
|
|
90
90
|
|
|
91
|
+
allowEditorOverflow = true;
|
|
91
92
|
positionPreference = [ContentWidgetPositionPreference.ABOVE];
|
|
92
93
|
|
|
93
94
|
override dispose(): void {
|
|
@@ -74,8 +74,8 @@ export class InlineInputHandler extends Disposable {
|
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
if (strategy === ERunStrategy.PREVIEW && handler.
|
|
78
|
-
const previewResponse = await handler.
|
|
77
|
+
if (strategy === ERunStrategy.PREVIEW && handler.providePreviewStrategy) {
|
|
78
|
+
const previewResponse = await handler.providePreviewStrategy(monacoEditor, value, this.cancelIndicator.token);
|
|
79
79
|
|
|
80
80
|
if (CancelResponse.is(previewResponse)) {
|
|
81
81
|
widget.launchChatStatus(EInlineChatStatus.READY);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
|
|
2
|
-
import { Disposable, Emitter, Event, FRAME_THREE, sleep } from '@opensumi/ide-core-browser';
|
|
2
|
+
import { Disposable, Emitter, Event, FRAME_THREE, Schemes, Uri, randomString, sleep } from '@opensumi/ide-core-browser';
|
|
3
3
|
import { ISingleEditOperation } from '@opensumi/ide-editor';
|
|
4
4
|
import { ICodeEditor, ITextModel, Range, Selection } from '@opensumi/ide-monaco';
|
|
5
5
|
import { StandaloneServices } from '@opensumi/ide-monaco/lib/browser/monaco-api/services';
|
|
@@ -11,13 +11,11 @@ import { LineTokens } from '@opensumi/monaco-editor-core/esm/vs/editor/common/to
|
|
|
11
11
|
import { UndoRedoGroup } from '@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo';
|
|
12
12
|
|
|
13
13
|
import { IDecorationSerializableState } from '../../model/enhanceDecorationsCollection';
|
|
14
|
+
import { IDiffPreviewerOptions, IInlineDiffPreviewerNode } from '../inline-diff/inline-diff-previewer';
|
|
14
15
|
|
|
15
16
|
import { InlineStreamDiffComputer } from './inline-stream-diff-computer';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
LivePreviewDiffDecorationModel,
|
|
19
|
-
SerializableState,
|
|
20
|
-
} from './live-preview.decoration';
|
|
17
|
+
import { IRemovedWidgetState } from './live-preview.component';
|
|
18
|
+
import { ILivePreviewDiffDecorationSnapshotData, LivePreviewDiffDecorationModel } from './live-preview.decoration';
|
|
21
19
|
|
|
22
20
|
interface IRangeChangeData {
|
|
23
21
|
removedTextLines: string[];
|
|
@@ -43,36 +41,72 @@ export enum EComputerMode {
|
|
|
43
41
|
default = 'default',
|
|
44
42
|
}
|
|
45
43
|
|
|
44
|
+
export interface IInlineStreamDiffSnapshotData {
|
|
45
|
+
rawOriginalTextLines: string[];
|
|
46
|
+
rawOriginalTextLinesTokens: LineTokens[];
|
|
47
|
+
undoRedoGroup: UndoRedoGroup;
|
|
48
|
+
decorationSnapshotData: ILivePreviewDiffDecorationSnapshotData;
|
|
49
|
+
previewerOptions: IDiffPreviewerOptions;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const inlineStreamDiffComputer = new InlineStreamDiffComputer();
|
|
53
|
+
|
|
46
54
|
@Injectable({ multiple: true })
|
|
47
|
-
export class InlineStreamDiffHandler extends Disposable {
|
|
55
|
+
export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPreviewerNode {
|
|
48
56
|
@Autowired(INJECTOR_TOKEN)
|
|
49
57
|
private readonly injector: Injector;
|
|
50
58
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
private rawOriginalTextLinesTokens: LineTokens[] = [];
|
|
59
|
+
protected readonly _onDidEditChange = this.registerDispose(new Emitter<void>());
|
|
60
|
+
public readonly onDidEditChange: Event<void> = this._onDidEditChange.event;
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
public previewerOptions: IDiffPreviewerOptions;
|
|
56
63
|
|
|
57
|
-
private
|
|
64
|
+
private livePreviewDiffDecorationModel: LivePreviewDiffDecorationModel;
|
|
58
65
|
private originalModel: ITextModel;
|
|
59
|
-
private
|
|
66
|
+
private virtualModel: ITextModel;
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
// Parts that require snapshots
|
|
69
|
+
private rawOriginalTextLines: string[];
|
|
70
|
+
private rawOriginalTextLinesTokens: LineTokens[] = [];
|
|
71
|
+
private undoRedoGroup: UndoRedoGroup;
|
|
63
72
|
|
|
64
|
-
constructor(private readonly monacoEditor: ICodeEditor
|
|
73
|
+
constructor(private readonly monacoEditor: ICodeEditor) {
|
|
65
74
|
super();
|
|
66
75
|
|
|
67
76
|
this.undoRedoGroup = new UndoRedoGroup();
|
|
68
77
|
|
|
69
78
|
const modelService = StandaloneServices.get(IModelService);
|
|
70
|
-
this.virtualModel = modelService.createModel(
|
|
79
|
+
this.virtualModel = modelService.createModel(
|
|
80
|
+
'',
|
|
81
|
+
null,
|
|
82
|
+
Uri.from({
|
|
83
|
+
scheme: Schemes.inMemory,
|
|
84
|
+
path: 'inline-stream-diff/' + randomString(8),
|
|
85
|
+
}),
|
|
86
|
+
true,
|
|
87
|
+
);
|
|
71
88
|
this.originalModel = this.monacoEditor.getModel()!;
|
|
72
89
|
|
|
90
|
+
this.livePreviewDiffDecorationModel = this.injector.get(LivePreviewDiffDecorationModel, [this.monacoEditor]);
|
|
91
|
+
this.addDispose(this.livePreviewDiffDecorationModel);
|
|
92
|
+
this.addDispose(this.virtualModel);
|
|
93
|
+
|
|
94
|
+
// 将 diff handler 和 decoration model 的生命周期绑定在一起
|
|
95
|
+
const dispose = this.livePreviewDiffDecorationModel.onDispose(() => {
|
|
96
|
+
this.dispose();
|
|
97
|
+
dispose.dispose();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setPreviewerOptions(options: IDiffPreviewerOptions): void {
|
|
102
|
+
this.previewerOptions = options;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
initialize(selection: Selection): void {
|
|
73
106
|
const eol = this.originalModel.getEOL();
|
|
74
|
-
const startPosition =
|
|
75
|
-
const endPosition =
|
|
107
|
+
const startPosition = selection.getStartPosition();
|
|
108
|
+
const endPosition = selection.getEndPosition();
|
|
109
|
+
|
|
76
110
|
this.rawOriginalTextLines = this.originalModel
|
|
77
111
|
.getValueInRange(Range.fromPositions(startPosition, endPosition))
|
|
78
112
|
.split(eol);
|
|
@@ -84,16 +118,52 @@ export class InlineStreamDiffHandler extends Disposable {
|
|
|
84
118
|
return lineTokens;
|
|
85
119
|
});
|
|
86
120
|
|
|
87
|
-
|
|
121
|
+
const zone = LineRange.fromRangeInclusive(
|
|
122
|
+
Range.fromPositions(
|
|
123
|
+
{ lineNumber: selection.startLineNumber, column: 1 },
|
|
124
|
+
{ lineNumber: selection.endLineNumber, column: Number.MAX_SAFE_INTEGER },
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
this.livePreviewDiffDecorationModel.initialize(zone);
|
|
88
129
|
}
|
|
89
130
|
|
|
90
|
-
private
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
131
|
+
private _snapshotStore: IInlineStreamDiffSnapshotData | undefined;
|
|
132
|
+
restoreSnapshot(snapshot: IInlineStreamDiffSnapshotData): void {
|
|
133
|
+
this._snapshotStore = snapshot;
|
|
134
|
+
const {
|
|
135
|
+
rawOriginalTextLines,
|
|
136
|
+
rawOriginalTextLinesTokens,
|
|
137
|
+
undoRedoGroup,
|
|
138
|
+
decorationSnapshotData,
|
|
139
|
+
previewerOptions,
|
|
140
|
+
} = snapshot;
|
|
95
141
|
|
|
96
|
-
this.
|
|
142
|
+
this.setPreviewerOptions(previewerOptions);
|
|
143
|
+
|
|
144
|
+
this.rawOriginalTextLines = rawOriginalTextLines;
|
|
145
|
+
this.rawOriginalTextLinesTokens = rawOriginalTextLinesTokens;
|
|
146
|
+
this.undoRedoGroup = undoRedoGroup;
|
|
147
|
+
|
|
148
|
+
this.livePreviewDiffDecorationModel.initialize(decorationSnapshotData.zone);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
get currentSnapshotStore(): IInlineStreamDiffSnapshotData | undefined {
|
|
152
|
+
return this._snapshotStore;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
restoreDecorationSnapshot(decorationSnapshotData: ILivePreviewDiffDecorationSnapshotData): void {
|
|
156
|
+
this.livePreviewDiffDecorationModel.restoreSnapshot(decorationSnapshotData);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
createSnapshot(): IInlineStreamDiffSnapshotData {
|
|
160
|
+
return {
|
|
161
|
+
rawOriginalTextLines: this.rawOriginalTextLines,
|
|
162
|
+
rawOriginalTextLinesTokens: this.rawOriginalTextLinesTokens,
|
|
163
|
+
undoRedoGroup: this.undoRedoGroup,
|
|
164
|
+
decorationSnapshotData: this.livePreviewDiffDecorationModel.createSnapshot(),
|
|
165
|
+
previewerOptions: this.previewerOptions,
|
|
166
|
+
};
|
|
97
167
|
}
|
|
98
168
|
|
|
99
169
|
get onPartialEditWidgetListChange() {
|
|
@@ -106,7 +176,7 @@ export class InlineStreamDiffHandler extends Disposable {
|
|
|
106
176
|
computerMode: EComputerMode = EComputerMode.default,
|
|
107
177
|
): IComputeDiffData {
|
|
108
178
|
const computeResult = (
|
|
109
|
-
computerMode === EComputerMode.default ?
|
|
179
|
+
computerMode === EComputerMode.default ? inlineStreamDiffComputer : linesDiffComputers.getLegacy()
|
|
110
180
|
).computeDiff(originalTextLines, newTextLines, {
|
|
111
181
|
computeMoves: false,
|
|
112
182
|
maxComputationTimeMs: 200,
|
|
@@ -184,10 +254,6 @@ export class InlineStreamDiffHandler extends Disposable {
|
|
|
184
254
|
};
|
|
185
255
|
}
|
|
186
256
|
|
|
187
|
-
public getZone(): LineRange {
|
|
188
|
-
return this.livePreviewDiffDecorationModel.getZone();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
257
|
private calculateAddedDecorationCollectionState(diffModel: IComputeDiffData): IDecorationSerializableState[] {
|
|
192
258
|
const zone = this.getZone();
|
|
193
259
|
|
|
@@ -211,7 +277,6 @@ export class InlineStreamDiffHandler extends Disposable {
|
|
|
211
277
|
|
|
212
278
|
private renderPartialEditWidgets(diffModel: IComputeDiffData): void {
|
|
213
279
|
const decorationRange = this.calculateAddedDecorationCollectionState(diffModel);
|
|
214
|
-
|
|
215
280
|
this.livePreviewDiffDecorationModel.touchPartialEditWidgets(decorationRange.map((v) => v.startPosition.lineNumber));
|
|
216
281
|
}
|
|
217
282
|
|
|
@@ -226,7 +291,7 @@ export class InlineStreamDiffHandler extends Disposable {
|
|
|
226
291
|
|
|
227
292
|
let preRemovedLen: number = 0;
|
|
228
293
|
|
|
229
|
-
const states = [] as
|
|
294
|
+
const states = [] as IRemovedWidgetState[];
|
|
230
295
|
|
|
231
296
|
for (const change of changes) {
|
|
232
297
|
const { removedTextLines, removedLinesOriginalRange, addedRange } = change;
|
|
@@ -255,12 +320,10 @@ export class InlineStreamDiffHandler extends Disposable {
|
|
|
255
320
|
* 一旦撤销到最顶层则关闭当前的 inline diff
|
|
256
321
|
*/
|
|
257
322
|
private pushStackElement(): void {
|
|
258
|
-
this.livePreviewDiffDecorationModel.
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
},
|
|
263
|
-
group: this.undoRedoGroup,
|
|
323
|
+
const stack = this.livePreviewDiffDecorationModel.createEditStackElement(this.undoRedoGroup);
|
|
324
|
+
stack.attachModel(this.livePreviewDiffDecorationModel);
|
|
325
|
+
stack.registerUndo((decorationModel) => {
|
|
326
|
+
decorationModel.dispose();
|
|
264
327
|
});
|
|
265
328
|
}
|
|
266
329
|
|
|
@@ -440,21 +503,21 @@ export class InlineStreamDiffHandler extends Disposable {
|
|
|
440
503
|
return this.livePreviewDiffDecorationModel.onPartialEditEvent;
|
|
441
504
|
}
|
|
442
505
|
|
|
443
|
-
serializeState(): SerializableState {
|
|
444
|
-
return this.livePreviewDiffDecorationModel.serializeState();
|
|
445
|
-
}
|
|
446
|
-
restoreState(state: SerializableState): void {
|
|
447
|
-
this.livePreviewDiffDecorationModel.restoreSerializedState(state);
|
|
448
|
-
}
|
|
449
506
|
acceptAll(): void {
|
|
450
507
|
this.livePreviewDiffDecorationModel.acceptUnProcessed();
|
|
451
508
|
this.dispose();
|
|
452
509
|
}
|
|
510
|
+
|
|
453
511
|
rejectAll(): void {
|
|
454
512
|
this.livePreviewDiffDecorationModel.discardUnProcessed();
|
|
455
513
|
this.dispose();
|
|
456
514
|
}
|
|
515
|
+
|
|
457
516
|
revealFirstDiff() {
|
|
458
517
|
this.livePreviewDiffDecorationModel.revealFirstDiff();
|
|
459
518
|
}
|
|
519
|
+
|
|
520
|
+
getZone(): LineRange {
|
|
521
|
+
return this.livePreviewDiffDecorationModel.getZone();
|
|
522
|
+
}
|
|
460
523
|
}
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
width: 1e6px;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
@line-height: 18px;
|
|
38
|
+
|
|
37
39
|
.inline_diff_accept_partial_widget_container {
|
|
38
40
|
width: 100%;
|
|
39
41
|
|
|
@@ -42,9 +44,9 @@
|
|
|
42
44
|
display: flex;
|
|
43
45
|
border-radius: 4px;
|
|
44
46
|
overflow: hidden;
|
|
45
|
-
margin-right:
|
|
46
|
-
max-height:
|
|
47
|
-
height:
|
|
47
|
+
margin-right: 12px;
|
|
48
|
+
max-height: @line-height;
|
|
49
|
+
height: @line-height;
|
|
48
50
|
align-items: center;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -53,16 +55,17 @@
|
|
|
53
55
|
border: none;
|
|
54
56
|
font-size: 12px;
|
|
55
57
|
cursor: pointer;
|
|
56
|
-
padding: 2px;
|
|
58
|
+
padding: 2px 6px;
|
|
59
|
+
height: @line-height;
|
|
57
60
|
|
|
58
61
|
&.accept_btn {
|
|
59
62
|
background-color: var(--aiNative-inlineDiffAcceptPartialEdit);
|
|
60
|
-
color:
|
|
63
|
+
color: var(--aiNative-inlineDiffAcceptPartialEdit-foreground);
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
&.discard_btn {
|
|
64
67
|
background-color: var(--aiNative-inlineDiffDiscardPartialEdit);
|
|
65
|
-
color:
|
|
68
|
+
color: var(--aiNative-inlineDiffAcceptPartialEdit-foreground);
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ITextModel, Uri } from '@opensumi/ide-monaco';
|
|
2
|
+
import {
|
|
3
|
+
IResourceUndoRedoElement,
|
|
4
|
+
UndoRedoElementType,
|
|
5
|
+
} from '@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo';
|
|
6
|
+
|
|
7
|
+
import { LivePreviewDiffDecorationModel } from './live-preview.decoration';
|
|
8
|
+
|
|
9
|
+
export class LivePreviewUndoRedoStackElement implements IResourceUndoRedoElement {
|
|
10
|
+
private decorationModel: LivePreviewDiffDecorationModel;
|
|
11
|
+
|
|
12
|
+
get type(): UndoRedoElementType.Resource {
|
|
13
|
+
return UndoRedoElementType.Resource;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get label(): string {
|
|
17
|
+
return 'Live.Preview.UndoRedo';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get code(): string {
|
|
21
|
+
return 'Live.Preview.UndoRedo';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get resource(): Uri {
|
|
25
|
+
return this.model.uri;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
confirmBeforeUndo = false;
|
|
29
|
+
|
|
30
|
+
constructor(private readonly model: ITextModel) {}
|
|
31
|
+
|
|
32
|
+
attachModel(newDecorationModel: LivePreviewDiffDecorationModel): void {
|
|
33
|
+
this.decorationModel = newDecorationModel;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private _undo: (model: LivePreviewDiffDecorationModel) => void;
|
|
37
|
+
registerUndo(undo: (model: LivePreviewDiffDecorationModel) => void): void {
|
|
38
|
+
this._undo = undo;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
undo(): void | Promise<void> {
|
|
42
|
+
this._undo?.(this.decorationModel);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private _redo: (model: LivePreviewDiffDecorationModel) => void;
|
|
46
|
+
registerRedo(redo: (model: LivePreviewDiffDecorationModel) => void): void {
|
|
47
|
+
this._redo = redo;
|
|
48
|
+
}
|
|
49
|
+
redo() {
|
|
50
|
+
this._redo?.(this.decorationModel);
|
|
51
|
+
}
|
|
52
|
+
}
|