@opensumi/ide-ai-native 3.4.4-next-1728985193.0 → 3.4.4
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.map +1 -1
- package/lib/browser/ai-core.contribution.js +14 -14
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +4 -4
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatMarkdown.d.ts.map +1 -1
- package/lib/browser/components/ChatMarkdown.js +21 -38
- package/lib/browser/components/ChatMarkdown.js.map +1 -1
- package/lib/browser/components/ChatReply.d.ts.map +1 -1
- package/lib/browser/components/ChatReply.js +4 -4
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/contrib/base/index.d.ts +1 -0
- package/lib/browser/contrib/base/index.d.ts.map +1 -1
- package/lib/browser/contrib/base/index.js +5 -1
- package/lib/browser/contrib/base/index.js.map +1 -1
- package/lib/browser/contrib/inline-completions/prompt/prompt.d.ts +3 -3
- package/lib/browser/contrib/inline-completions/prompt/prompt.d.ts.map +1 -1
- package/lib/browser/contrib/inline-completions/prompt/prompt.js.map +1 -1
- package/lib/browser/contrib/inline-completions/prompt/tokenizer.d.ts +1 -1
- package/lib/browser/contrib/inline-completions/prompt/tokenizer.d.ts.map +1 -1
- package/lib/browser/contrib/inline-completions/prompt/tokenizer.js +3 -2
- package/lib/browser/contrib/inline-completions/prompt/tokenizer.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +7 -7
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/problem-fix/problem-fix.controller.d.ts.map +1 -1
- package/lib/browser/contrib/problem-fix/problem-fix.controller.js +3 -4
- package/lib/browser/contrib/problem-fix/problem-fix.controller.js.map +1 -1
- package/lib/browser/contrib/terminal/decoration/terminal-decoration.d.ts +1 -1
- package/lib/browser/contrib/terminal/decoration/terminal-decoration.d.ts.map +1 -1
- package/lib/browser/contrib/terminal/decoration/terminal-decoration.js.map +1 -1
- package/lib/browser/contrib/terminal/ps1-terminal.service.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.d.ts +0 -1
- 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 +24 -26
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +0 -4
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +5 -7
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-hint/inline-hint.controller.js +6 -6
- package/lib/browser/widget/inline-hint/inline-hint.controller.js.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.js +4 -4
- package/lib/browser/widget/inline-input/inline-input.controller.js.map +1 -1
- 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 +0 -5
- 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 +0 -9
- 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 +3 -10
- 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 +1 -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 +18 -43
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/package.json +24 -24
- package/src/browser/ai-core.contribution.ts +14 -15
- package/src/browser/chat/chat.view.tsx +4 -5
- package/src/browser/components/ChatMarkdown.tsx +42 -50
- package/src/browser/components/ChatReply.tsx +16 -6
- package/src/browser/contrib/base/index.ts +7 -1
- package/src/browser/contrib/inline-completions/prompt/prompt.ts +5 -9
- package/src/browser/contrib/inline-completions/prompt/tokenizer.ts +3 -2
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +7 -7
- package/src/browser/contrib/problem-fix/problem-fix.controller.ts +3 -5
- package/src/browser/contrib/terminal/ai-terminal.service.ts +1 -1
- package/src/browser/contrib/terminal/decoration/terminal-decoration.tsx +1 -1
- package/src/browser/contrib/terminal/ps1-terminal.service.tsx +1 -1
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +35 -33
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +0 -4
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +6 -10
- package/src/browser/widget/inline-hint/inline-hint.controller.ts +6 -6
- package/src/browser/widget/inline-input/inline-input.controller.ts +4 -4
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +0 -6
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +0 -15
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +18 -54
|
@@ -83,59 +83,47 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
83
83
|
mount(): IDisposable {
|
|
84
84
|
this.inlineDiffController = InlineDiffController.get(this.monacoEditor)!;
|
|
85
85
|
|
|
86
|
-
this.doContribute();
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private disposeAllWidget() {
|
|
91
|
-
[this.aiInlineContentWidget, this.aiInlineChatDisposable, this.aiInlineChatOperationDisposable].forEach(
|
|
92
|
-
(widget) => {
|
|
93
|
-
widget?.dispose();
|
|
94
|
-
},
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
this.inlineChatInUsing = false;
|
|
98
|
-
this.cancelToken();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public doContribute(): IDisposable {
|
|
102
86
|
if (!this.monacoEditor) {
|
|
103
|
-
return this;
|
|
87
|
+
return this.featureDisposable;
|
|
104
88
|
}
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.disposables.push(
|
|
90
|
+
this.featureDisposable.addDispose(
|
|
109
91
|
this.aiInlineChatService.onInlineChatVisible((value: boolean) => {
|
|
110
92
|
if (value) {
|
|
111
|
-
this.showInlineChat(monacoEditor);
|
|
93
|
+
this.showInlineChat(this.monacoEditor);
|
|
112
94
|
} else {
|
|
113
95
|
this.cancelToken();
|
|
114
96
|
this.disposeAllWidget();
|
|
115
97
|
}
|
|
116
98
|
}),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
this.featureDisposable.addDispose(
|
|
117
102
|
this.codeActionService.onCodeActionRun(({ id, range }) => {
|
|
118
103
|
const currentEditor = this.workbenchEditorService.currentEditor;
|
|
119
104
|
|
|
120
105
|
// 可能存在两个 editor 但 uri 是同一个的情况,所以需要根据 editor 的 id 来判断
|
|
121
|
-
if (currentEditor?.getId() !== monacoEditor!.getId()) {
|
|
106
|
+
if (currentEditor?.getId() !== this.monacoEditor!.getId()) {
|
|
122
107
|
return;
|
|
123
108
|
}
|
|
124
109
|
|
|
125
|
-
monacoEditor.setSelection(range);
|
|
126
|
-
this.showInlineChat(monacoEditor);
|
|
110
|
+
this.monacoEditor.setSelection(range);
|
|
111
|
+
this.showInlineChat(this.monacoEditor);
|
|
127
112
|
if (this.aiInlineContentWidget) {
|
|
128
113
|
this.aiInlineContentWidget.clickActionId(id, 'codeAction');
|
|
129
114
|
}
|
|
130
115
|
}),
|
|
131
|
-
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
this.featureDisposable.addDispose(
|
|
119
|
+
this.monacoEditor.onWillChangeModel(() => {
|
|
132
120
|
this.disposeAllWidget();
|
|
133
121
|
}),
|
|
134
122
|
);
|
|
135
123
|
|
|
136
124
|
let needShowInlineChat = false;
|
|
137
|
-
this.
|
|
138
|
-
monacoEditor.onMouseDown((event: monaco.IEditorMouseEvent) => {
|
|
125
|
+
this.featureDisposable.addDispose(
|
|
126
|
+
this.monacoEditor.onMouseDown((event: monaco.IEditorMouseEvent) => {
|
|
139
127
|
const target = event.target;
|
|
140
128
|
const detail = (target as any).detail;
|
|
141
129
|
|
|
@@ -149,7 +137,10 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
149
137
|
this.disposeAllWidget();
|
|
150
138
|
}
|
|
151
139
|
}),
|
|
152
|
-
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
this.featureDisposable.addDispose(
|
|
143
|
+
this.monacoEditor.onMouseUp((event: monaco.IEditorMouseEvent) => {
|
|
153
144
|
const target = event.target;
|
|
154
145
|
const detail = (target as any).detail;
|
|
155
146
|
if (detail && typeof detail === 'string' && detail === AIInlineChatContentWidgetId) {
|
|
@@ -164,7 +155,7 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
164
155
|
AINativeSettingSectionsId.InlineChatAutoVisible,
|
|
165
156
|
true,
|
|
166
157
|
);
|
|
167
|
-
this.
|
|
158
|
+
this.featureDisposable.addDispose(
|
|
168
159
|
this.preferenceService.onSpecificPreferenceChange(
|
|
169
160
|
AINativeSettingSectionsId.InlineChatAutoVisible,
|
|
170
161
|
({ newValue }) => {
|
|
@@ -173,9 +164,9 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
173
164
|
),
|
|
174
165
|
);
|
|
175
166
|
|
|
176
|
-
this.
|
|
167
|
+
this.featureDisposable.addDispose(
|
|
177
168
|
Event.debounce(
|
|
178
|
-
Event.any<any>(monacoEditor.onDidChangeCursorSelection, monacoEditor.onMouseUp),
|
|
169
|
+
Event.any<any>(this.monacoEditor.onDidChangeCursorSelection, this.monacoEditor.onMouseUp),
|
|
179
170
|
(_, e) => e,
|
|
180
171
|
100,
|
|
181
172
|
)(() => {
|
|
@@ -189,11 +180,22 @@ export class InlineChatEditorController extends BaseAIMonacoEditorController {
|
|
|
189
180
|
return;
|
|
190
181
|
}
|
|
191
182
|
|
|
192
|
-
this.showInlineChat(monacoEditor);
|
|
183
|
+
this.showInlineChat(this.monacoEditor);
|
|
193
184
|
}),
|
|
194
185
|
);
|
|
195
186
|
|
|
196
|
-
return this;
|
|
187
|
+
return this.featureDisposable;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private disposeAllWidget() {
|
|
191
|
+
[this.aiInlineContentWidget, this.aiInlineChatDisposable, this.aiInlineChatOperationDisposable].forEach(
|
|
192
|
+
(widget) => {
|
|
193
|
+
widget?.dispose();
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
this.inlineChatInUsing = false;
|
|
198
|
+
this.cancelToken();
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
protected showInlineContentWidget(monacoEditor: monaco.ICodeEditor, selection: monaco.Selection): void {
|
|
@@ -19,10 +19,6 @@ import { InlineDiffWidget } from './inline-diff-widget';
|
|
|
19
19
|
|
|
20
20
|
export interface IDiffPreviewerOptions {
|
|
21
21
|
disposeWhenEditorClosed: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* 是否隐藏接受部分编辑的 widget,用于只展示 diff 的场景
|
|
24
|
-
*/
|
|
25
|
-
hideAcceptPartialEditWidget?: boolean;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
export interface IInlineDiffPreviewerNode extends IDisposable {
|
|
@@ -53,7 +53,7 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
53
53
|
private _previewerNodeStore = new Map<string, InlineStreamDiffHandler | null>();
|
|
54
54
|
|
|
55
55
|
mount(): IDisposable {
|
|
56
|
-
this.
|
|
56
|
+
this.featureDisposable.addDispose(
|
|
57
57
|
this.eventBus.on(EditorGroupCloseEvent, (e: EditorGroupCloseEvent) => {
|
|
58
58
|
const uriString = e.payload.resource.uri.toString();
|
|
59
59
|
const node = this.getStoredState(uriString);
|
|
@@ -66,7 +66,7 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
66
66
|
|
|
67
67
|
this.registerInlineDiffFeature(this.monacoEditor);
|
|
68
68
|
|
|
69
|
-
return this;
|
|
69
|
+
return this.featureDisposable;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
storeState(key: string) {
|
|
@@ -110,12 +110,10 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
registerInlineDiffFeature(monacoEditor: monaco.ICodeEditor):
|
|
114
|
-
const disposable = new Disposable();
|
|
115
|
-
|
|
113
|
+
registerInlineDiffFeature(monacoEditor: monaco.ICodeEditor): void {
|
|
116
114
|
const model = monacoEditor.getModel();
|
|
117
115
|
|
|
118
|
-
|
|
116
|
+
this.featureDisposable.addDispose(
|
|
119
117
|
monacoEditor.onWillChangeModel((e) => {
|
|
120
118
|
if (!e.oldModelUrl) {
|
|
121
119
|
return;
|
|
@@ -128,7 +126,7 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
128
126
|
}),
|
|
129
127
|
);
|
|
130
128
|
|
|
131
|
-
|
|
129
|
+
this.featureDisposable.addDispose(
|
|
132
130
|
monacoEditor.onDidChangeModel((e) => {
|
|
133
131
|
if (!e.newModelUrl) {
|
|
134
132
|
return;
|
|
@@ -138,15 +136,13 @@ export class InlineDiffController extends BaseAIMonacoEditorController {
|
|
|
138
136
|
);
|
|
139
137
|
|
|
140
138
|
if (model) {
|
|
141
|
-
|
|
139
|
+
this.featureDisposable.addDispose(
|
|
142
140
|
model.onWillDispose(() => {
|
|
143
141
|
const uriString = model.uri.toString();
|
|
144
142
|
this.destroyPreviewer(uriString);
|
|
145
143
|
}),
|
|
146
144
|
);
|
|
147
145
|
}
|
|
148
|
-
|
|
149
|
-
return disposable;
|
|
150
146
|
}
|
|
151
147
|
|
|
152
148
|
showPreviewerByStream(
|
|
@@ -76,14 +76,14 @@ export class InlineHintController extends BaseAIMonacoEditorController {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
this.addDispose(
|
|
79
|
+
this.featureDisposable.addDispose(
|
|
80
80
|
monacoEditor.onDidChangeCursorPosition((e: monaco.editor.ICursorPositionChangedEvent) => {
|
|
81
81
|
hideHint();
|
|
82
82
|
showHint(e.position);
|
|
83
83
|
}),
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
this.addDispose(
|
|
86
|
+
this.featureDisposable.addDispose(
|
|
87
87
|
monacoEditor.onDidFocusEditorWidget(() => {
|
|
88
88
|
const currentPosition = monacoEditor.getPosition();
|
|
89
89
|
|
|
@@ -94,13 +94,13 @@ export class InlineHintController extends BaseAIMonacoEditorController {
|
|
|
94
94
|
}),
|
|
95
95
|
);
|
|
96
96
|
|
|
97
|
-
this.addDispose(
|
|
97
|
+
this.featureDisposable.addDispose(
|
|
98
98
|
monacoEditor.onDidBlurEditorWidget(() => {
|
|
99
99
|
hideHint();
|
|
100
100
|
}),
|
|
101
101
|
);
|
|
102
102
|
|
|
103
|
-
this.addDispose(
|
|
103
|
+
this.featureDisposable.addDispose(
|
|
104
104
|
this.inlineCompletionsService.onVisibleCompletion((v) => {
|
|
105
105
|
if (v) {
|
|
106
106
|
hideHint();
|
|
@@ -108,8 +108,8 @@ export class InlineHintController extends BaseAIMonacoEditorController {
|
|
|
108
108
|
}),
|
|
109
109
|
);
|
|
110
110
|
|
|
111
|
-
this.addDispose(hintDisposable);
|
|
111
|
+
this.featureDisposable.addDispose(hintDisposable);
|
|
112
112
|
|
|
113
|
-
return this;
|
|
113
|
+
return this.featureDisposable;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -133,7 +133,7 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
133
133
|
inputDisposable.dispose();
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
this.addDispose(
|
|
136
|
+
this.featureDisposable.addDispose(
|
|
137
137
|
this.inlineInputChatService.onInteractiveInputVisibleInPosition((position) => {
|
|
138
138
|
hideInput();
|
|
139
139
|
|
|
@@ -144,7 +144,7 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
144
144
|
);
|
|
145
145
|
|
|
146
146
|
const showInput = (position: monaco.Position, monacoEditor: ICodeEditor) => {
|
|
147
|
-
this.addDispose(
|
|
147
|
+
this.featureDisposable.addDispose(
|
|
148
148
|
monacoEditor.onWillChangeModel(() => {
|
|
149
149
|
hideInput();
|
|
150
150
|
}),
|
|
@@ -270,8 +270,8 @@ export class InlineInputController extends BaseAIMonacoEditorController {
|
|
|
270
270
|
inputDisposable.addDispose(inlineInputChatWidget);
|
|
271
271
|
};
|
|
272
272
|
|
|
273
|
-
this.addDispose(inputDisposable);
|
|
273
|
+
this.featureDisposable.addDispose(inputDisposable);
|
|
274
274
|
|
|
275
|
-
return this;
|
|
275
|
+
return this.featureDisposable;
|
|
276
276
|
}
|
|
277
277
|
}
|
|
@@ -101,12 +101,6 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
101
101
|
|
|
102
102
|
setPreviewerOptions(options: IDiffPreviewerOptions): void {
|
|
103
103
|
this.previewerOptions = options;
|
|
104
|
-
|
|
105
|
-
this.livePreviewDiffDecorationModel.setPreviewerOptions({
|
|
106
|
-
partialEditWidgetOptions: {
|
|
107
|
-
hideAcceptPartialEditWidget: options.hideAcceptPartialEditWidget,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
104
|
}
|
|
111
105
|
|
|
112
106
|
initialize(selection: Selection): void {
|
|
@@ -124,13 +124,6 @@ const PartialEditComponent = (props: {
|
|
|
124
124
|
);
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
export interface IPartialEditWidgetOptions {
|
|
128
|
-
/**
|
|
129
|
-
* In some case, we don't want to show the accept and reject button
|
|
130
|
-
*/
|
|
131
|
-
hideAcceptPartialEditWidget?: boolean;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
127
|
@Injectable({ multiple: true })
|
|
135
128
|
export class AcceptPartialEditWidget extends ReactInlineContentWidget {
|
|
136
129
|
static ID = 'AcceptPartialEditWidgetID';
|
|
@@ -149,10 +142,6 @@ export class AcceptPartialEditWidget extends ReactInlineContentWidget {
|
|
|
149
142
|
|
|
150
143
|
positionPreference = [ContentWidgetPositionPreference.EXACT];
|
|
151
144
|
|
|
152
|
-
constructor(protected readonly editor: ICodeEditor, protected editWidgetOptions?: IPartialEditWidgetOptions) {
|
|
153
|
-
super(editor);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
145
|
public addedLinesCount: number = 0;
|
|
157
146
|
public deletedLinesCount: number = 0;
|
|
158
147
|
public status: IWidgetStatus = 'pending';
|
|
@@ -177,10 +166,6 @@ export class AcceptPartialEditWidget extends ReactInlineContentWidget {
|
|
|
177
166
|
}
|
|
178
167
|
|
|
179
168
|
public renderView(): React.ReactNode {
|
|
180
|
-
if (this.editWidgetOptions?.hideAcceptPartialEditWidget) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
169
|
const keyStrings = this.getSequenceKeyStrings();
|
|
185
170
|
if (!keyStrings) {
|
|
186
171
|
return;
|
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
AddedRangeDecoration,
|
|
30
30
|
EPartialEdit,
|
|
31
31
|
IPartialEditEvent,
|
|
32
|
-
IPartialEditWidgetOptions,
|
|
33
32
|
IRemovedWidgetState,
|
|
34
33
|
IRemovedZoneWidgetOptions,
|
|
35
34
|
ITextLinesTokens,
|
|
@@ -54,10 +53,6 @@ export interface ITotalCodeInfo {
|
|
|
54
53
|
unresolvedChangedLinesCount: number;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
export interface IModelOptions {
|
|
58
|
-
partialEditWidgetOptions?: IPartialEditWidgetOptions;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
56
|
@Injectable({ multiple: true })
|
|
62
57
|
export class LivePreviewDiffDecorationModel extends Disposable {
|
|
63
58
|
@Autowired(INJECTOR_TOKEN)
|
|
@@ -81,16 +76,12 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
81
76
|
public readonly onPartialEditWidgetListChange: Event<AcceptPartialEditWidget[]> =
|
|
82
77
|
this._onPartialEditWidgetListChange.event;
|
|
83
78
|
|
|
84
|
-
protected options: IModelOptions = {
|
|
85
|
-
partialEditWidgetOptions: {},
|
|
86
|
-
};
|
|
87
|
-
|
|
88
79
|
protected model: ITextModel;
|
|
89
80
|
|
|
90
81
|
// Parts that require snapshots
|
|
91
82
|
private addedRangeDec: EnhanceDecorationsCollection;
|
|
92
83
|
private partialEditWidgetList: AcceptPartialEditWidget[] = [];
|
|
93
|
-
private removedZoneWidgets: RemovedZoneWidget
|
|
84
|
+
private removedZoneWidgets: Array<RemovedZoneWidget> = [];
|
|
94
85
|
private zone: LineRange;
|
|
95
86
|
|
|
96
87
|
constructor(private readonly monacoEditor: ICodeEditor) {
|
|
@@ -515,29 +506,17 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
515
506
|
return newElement;
|
|
516
507
|
}
|
|
517
508
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
const unresolvedStatus = { added: 0, deleted: 0, changed: 0 };
|
|
530
|
-
partialEditWidgetList.forEach((v, idx) => {
|
|
531
|
-
if (v.status === 'pending') {
|
|
532
|
-
const addedDec = addedDecList[idx];
|
|
533
|
-
const removedWidget = removedWidgetList[idx];
|
|
534
|
-
const addedLinesCount = addedDec?.length || 0;
|
|
535
|
-
const deletedLinesCount = removedWidget?.height || 0;
|
|
536
|
-
unresolvedStatus.added += addedLinesCount;
|
|
537
|
-
unresolvedStatus.deleted += deletedLinesCount;
|
|
538
|
-
unresolvedStatus.changed += Math.max(addedLinesCount, deletedLinesCount);
|
|
539
|
-
}
|
|
540
|
-
});
|
|
509
|
+
/**
|
|
510
|
+
* 获取当前编辑器的代码采纳状态
|
|
511
|
+
* 1. 已经采纳的代码信息
|
|
512
|
+
* 2. 还未处理的代码信息
|
|
513
|
+
*/
|
|
514
|
+
getTotalCodeInfo(): ITotalCodeInfo {
|
|
515
|
+
const resolvedList = this.partialEditWidgetList.filter((w) => w.isAccepted);
|
|
516
|
+
const unresolvedList = this.partialEditWidgetList.filter((w) => w.isPending);
|
|
517
|
+
|
|
518
|
+
const resolvedStatus = caculate(resolvedList);
|
|
519
|
+
const unresolvedStatus = caculate(unresolvedList);
|
|
541
520
|
|
|
542
521
|
return {
|
|
543
522
|
totalAddedLinesCount: resolvedStatus.added,
|
|
@@ -548,6 +527,11 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
548
527
|
unresolvedChangedLinesCount: unresolvedStatus.changed,
|
|
549
528
|
};
|
|
550
529
|
|
|
530
|
+
// 代码除了新增和删除行,还需要统计变更行
|
|
531
|
+
// 1. 新增 N 行 => N
|
|
532
|
+
// 2. 删除 N 行 => N
|
|
533
|
+
// 3. 新增 M 行,删除 N 行 => max(M, N)
|
|
534
|
+
// 综上所述,变更行数 = sum(list.map(item => max(新增行数, 删除行数)))
|
|
551
535
|
function caculate(list: AcceptPartialEditWidget[]) {
|
|
552
536
|
const result = { added: 0, deleted: 0, changed: 0 };
|
|
553
537
|
list.forEach((widget) => {
|
|
@@ -561,19 +545,6 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
561
545
|
}
|
|
562
546
|
}
|
|
563
547
|
|
|
564
|
-
/**
|
|
565
|
-
* 获取当前编辑器的代码采纳状态
|
|
566
|
-
* 1. 已经采纳的代码信息
|
|
567
|
-
* 2. 还未处理的代码信息
|
|
568
|
-
*/
|
|
569
|
-
getTotalCodeInfo(): ITotalCodeInfo {
|
|
570
|
-
const partialEditWidgetList = this.partialEditWidgetList;
|
|
571
|
-
const addedDecList = this.addedRangeDec.getDecorations();
|
|
572
|
-
const removedWidgetList = this.removedZoneWidgets;
|
|
573
|
-
|
|
574
|
-
return LivePreviewDiffDecorationModel.computeCodeInfo(partialEditWidgetList, addedDecList, removedWidgetList);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
548
|
/**
|
|
578
549
|
* 记录 partial edit widget 与 added range 的映射关系(主要用于位置计算)
|
|
579
550
|
*/
|
|
@@ -604,10 +575,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
604
575
|
}
|
|
605
576
|
|
|
606
577
|
private createPartialEditWidget(lineNumber: number): AcceptPartialEditWidget {
|
|
607
|
-
const acceptPartialEditWidget = this.injector.get(AcceptPartialEditWidget, [
|
|
608
|
-
this.monacoEditor,
|
|
609
|
-
this.options.partialEditWidgetOptions,
|
|
610
|
-
]);
|
|
578
|
+
const acceptPartialEditWidget = this.injector.get(AcceptPartialEditWidget, [this.monacoEditor]);
|
|
611
579
|
acceptPartialEditWidget.show({ position: { lineNumber, column: 1 } });
|
|
612
580
|
|
|
613
581
|
const disposable = acceptPartialEditWidget.onDispose(() => {
|
|
@@ -734,8 +702,4 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
734
702
|
}
|
|
735
703
|
}
|
|
736
704
|
}
|
|
737
|
-
|
|
738
|
-
setPreviewerOptions(options: IModelOptions) {
|
|
739
|
-
this.options = options;
|
|
740
|
-
}
|
|
741
705
|
}
|