@opensumi/ide-ai-native 3.7.1-next-1739774311.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
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { Injectable } from '@opensumi/di';
|
|
2
2
|
import { AINativeSettingSectionsId, ECodeEditsSourceTyping, IDisposable } from '@opensumi/ide-core-common';
|
|
3
|
-
import { ICursorPositionChangedEvent,
|
|
4
|
-
import {
|
|
5
|
-
autorunDelta,
|
|
6
|
-
derived,
|
|
7
|
-
derivedHandleChanges,
|
|
8
|
-
observableFromEvent,
|
|
9
|
-
onObservableChange,
|
|
10
|
-
} from '@opensumi/ide-monaco/lib/common/observable';
|
|
11
|
-
|
|
12
|
-
import { IntelligentCompletionsController } from '../intelligent-completions.controller';
|
|
3
|
+
import { ICursorPositionChangedEvent, Position } from '@opensumi/ide-monaco';
|
|
13
4
|
|
|
14
5
|
import { BaseCodeEditsSource } from './base';
|
|
15
6
|
|
|
@@ -18,137 +9,39 @@ export interface ILineChangeData {
|
|
|
18
9
|
preLineNumber?: number;
|
|
19
10
|
}
|
|
20
11
|
|
|
21
|
-
const DEPRECATED_LIMIT = 5;
|
|
22
|
-
const CONTENT_CHANGE_VALID_TIME = 60 * 1000;
|
|
23
|
-
|
|
24
12
|
@Injectable({ multiple: true })
|
|
25
13
|
export class LineChangeCodeEditsSource extends BaseCodeEditsSource {
|
|
26
|
-
public priority =
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 在当前文件,计算弃用上次 edit 时的次数是否超过了阈值 {@link DEPRECATED_LIMIT} 次,超过则不会触发
|
|
30
|
-
* 1. 直接 esc 弃用
|
|
31
|
-
* 2. 用户再次移动光标位置致使补全消失也视为弃用
|
|
32
|
-
*/
|
|
33
|
-
private readonly deprecatedStore = new Map<string, number>();
|
|
34
|
-
|
|
35
|
-
private readonly positionChangeObs = observableFromEvent<ICursorPositionChangedEvent>(
|
|
36
|
-
this,
|
|
37
|
-
this.monacoEditor.onDidChangeCursorPosition,
|
|
38
|
-
(event: ICursorPositionChangedEvent) => event,
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
private readonly contentChangeObs = observableFromEvent<IModelContentChangedEvent>(
|
|
42
|
-
this,
|
|
43
|
-
this.monacoEditor.onDidChangeModelContent,
|
|
44
|
-
(event: IModelContentChangedEvent) => event,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
private readonly latestContentChangeTimeObs = derivedHandleChanges(
|
|
48
|
-
{
|
|
49
|
-
owner: this,
|
|
50
|
-
createEmptyChangeSummary: () => ({ latestContentChangeTime: 0 }),
|
|
51
|
-
handleChange: (context, changeSummary) => {
|
|
52
|
-
if (context.didChange(this.contentChangeObs)) {
|
|
53
|
-
changeSummary.latestContentChangeTime = Date.now();
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
(reader, changeSummary) => {
|
|
59
|
-
this.contentChangeObs.read(reader);
|
|
60
|
-
return changeSummary.latestContentChangeTime;
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
private readonly isAllowTriggerObs = derived((reader) => {
|
|
65
|
-
this.positionChangeObs.read(reader);
|
|
66
|
-
const latestContentChangeTime = this.latestContentChangeTimeObs.read(reader);
|
|
67
|
-
|
|
68
|
-
const isLineChangeEnabled = this.preferenceService.getValid(AINativeSettingSectionsId.CodeEditsLineChange, false);
|
|
14
|
+
public priority = 2;
|
|
69
15
|
|
|
70
|
-
|
|
71
|
-
* 配置开关
|
|
72
|
-
*/
|
|
73
|
-
if (!isLineChangeEnabled) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 弃用次数规则的限制
|
|
79
|
-
*/
|
|
80
|
-
const deprecatedCount = this.deprecatedStore.get(this.model?.id || '');
|
|
81
|
-
if (deprecatedCount && deprecatedCount >= DEPRECATED_LIMIT) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 1. 未编辑过代码不触发
|
|
87
|
-
* 2. 编辑过代码后,60 内没有再次编辑也不触发
|
|
88
|
-
*/
|
|
89
|
-
if (
|
|
90
|
-
latestContentChangeTime === 0 ||
|
|
91
|
-
(latestContentChangeTime && Date.now() - latestContentChangeTime > CONTENT_CHANGE_VALID_TIME)
|
|
92
|
-
) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return true;
|
|
97
|
-
});
|
|
16
|
+
private prePosition = this.monacoEditor.getPosition();
|
|
98
17
|
|
|
99
18
|
public mount(): IDisposable {
|
|
100
19
|
this.addDispose(
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const prePosition = lastValue?.position;
|
|
108
|
-
const currentPosition = newValue?.position;
|
|
109
|
-
if (prePosition && prePosition.lineNumber !== currentPosition?.lineNumber) {
|
|
110
|
-
this.setBean({
|
|
111
|
-
typing: ECodeEditsSourceTyping.LineChange,
|
|
112
|
-
data: {
|
|
113
|
-
[ECodeEditsSourceTyping.LineChange]: {
|
|
114
|
-
preLineNumber: prePosition.lineNumber,
|
|
115
|
-
currentLineNumber: currentPosition.lineNumber,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
});
|
|
20
|
+
this.monacoEditor.onDidChangeCursorPosition((event: ICursorPositionChangedEvent) => {
|
|
21
|
+
const currentPosition = event.position;
|
|
22
|
+
if (this.prePosition && this.prePosition.lineNumber !== currentPosition.lineNumber) {
|
|
23
|
+
this.doTrigger(currentPosition);
|
|
24
|
+
this.prePosition = currentPosition;
|
|
119
25
|
}
|
|
120
26
|
}),
|
|
121
27
|
);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
122
30
|
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
if (discard) {
|
|
126
|
-
this.addDispose(
|
|
127
|
-
onObservableChange(discard, (isValid: boolean) => {
|
|
128
|
-
const modelId = this.model?.id;
|
|
129
|
-
if (!modelId || !isValid) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const count = this.deprecatedStore.get(modelId) || 0;
|
|
134
|
-
this.deprecatedStore.set(modelId, count + 1);
|
|
135
|
-
}),
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (accept) {
|
|
140
|
-
this.addDispose(
|
|
141
|
-
onObservableChange(accept, () => {
|
|
142
|
-
const modelId = this.model?.id;
|
|
143
|
-
if (!modelId) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
31
|
+
protected doTrigger(position: Position) {
|
|
32
|
+
const isLineChangeEnabled = this.preferenceService.getValid(AINativeSettingSectionsId.CodeEditsLineChange, false);
|
|
146
33
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
);
|
|
34
|
+
if (!isLineChangeEnabled || !position) {
|
|
35
|
+
return;
|
|
150
36
|
}
|
|
151
37
|
|
|
152
|
-
|
|
38
|
+
this.setBean({
|
|
39
|
+
typing: ECodeEditsSourceTyping.LineChange,
|
|
40
|
+
position,
|
|
41
|
+
data: {
|
|
42
|
+
preLineNumber: this.prePosition?.lineNumber,
|
|
43
|
+
currentLineNumber: position.lineNumber,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
153
46
|
}
|
|
154
47
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { Injectable } from '@opensumi/di';
|
|
2
|
-
import {
|
|
1
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
+
import {
|
|
3
|
+
AINativeSettingSectionsId,
|
|
4
|
+
ECodeEditsSourceTyping,
|
|
5
|
+
Event,
|
|
6
|
+
FRAME_THREE,
|
|
7
|
+
IDisposable,
|
|
8
|
+
} from '@opensumi/ide-core-common';
|
|
3
9
|
import { ICursorPositionChangedEvent, IPosition, Position } from '@opensumi/ide-monaco';
|
|
4
10
|
import { URI } from '@opensumi/ide-monaco/lib/browser/monaco-api';
|
|
5
|
-
import {
|
|
11
|
+
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
6
12
|
import { StandaloneServices } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
7
13
|
import {
|
|
8
14
|
IMarker,
|
|
@@ -14,6 +20,7 @@ import {
|
|
|
14
20
|
import { BaseCodeEditsSource } from './base';
|
|
15
21
|
|
|
16
22
|
export interface ILinterErrorData {
|
|
23
|
+
relativeWorkspacePath: string;
|
|
17
24
|
errors: Array<IMarkerErrorData>;
|
|
18
25
|
}
|
|
19
26
|
|
|
@@ -51,19 +58,22 @@ namespace MarkerErrorData {
|
|
|
51
58
|
|
|
52
59
|
@Injectable({ multiple: true })
|
|
53
60
|
export class LintErrorCodeEditsSource extends BaseCodeEditsSource {
|
|
54
|
-
public priority =
|
|
61
|
+
public priority = 1;
|
|
62
|
+
|
|
63
|
+
@Autowired(IWorkspaceService)
|
|
64
|
+
private readonly workspaceService: IWorkspaceService;
|
|
55
65
|
|
|
56
66
|
public mount(): IDisposable {
|
|
57
|
-
|
|
58
|
-
this,
|
|
59
|
-
this.monacoEditor.onDidChangeCursorPosition,
|
|
60
|
-
(event: ICursorPositionChangedEvent) => event,
|
|
61
|
-
);
|
|
67
|
+
let prePosition = this.monacoEditor.getPosition();
|
|
62
68
|
|
|
63
69
|
this.addDispose(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
// 仅在光标的行号发生变化时,才触发
|
|
71
|
+
Event.debounce(
|
|
72
|
+
this.monacoEditor.onDidChangeCursorPosition,
|
|
73
|
+
(_, e) => e,
|
|
74
|
+
FRAME_THREE,
|
|
75
|
+
)(async (event: ICursorPositionChangedEvent) => {
|
|
76
|
+
const currentPosition = event.position;
|
|
67
77
|
|
|
68
78
|
// 如果是 selection 则不触发
|
|
69
79
|
const selection = this.monacoEditor.getSelection();
|
|
@@ -71,16 +81,16 @@ export class LintErrorCodeEditsSource extends BaseCodeEditsSource {
|
|
|
71
81
|
return;
|
|
72
82
|
}
|
|
73
83
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.doTrigger(currentPosition);
|
|
84
|
+
if (prePosition && prePosition.lineNumber !== currentPosition.lineNumber) {
|
|
85
|
+
await this.doTrigger(currentPosition);
|
|
77
86
|
}
|
|
87
|
+
prePosition = currentPosition;
|
|
78
88
|
}),
|
|
79
89
|
);
|
|
80
90
|
return this;
|
|
81
91
|
}
|
|
82
92
|
|
|
83
|
-
protected doTrigger(position: Position) {
|
|
93
|
+
protected async doTrigger(position: Position) {
|
|
84
94
|
const isLintErrorsEnabled = this.preferenceService.getValid(AINativeSettingSectionsId.CodeEditsLintErrors, false);
|
|
85
95
|
|
|
86
96
|
if (!isLintErrorsEnabled || !this.model) {
|
|
@@ -94,12 +104,14 @@ export class LintErrorCodeEditsSource extends BaseCodeEditsSource {
|
|
|
94
104
|
markers = markers.filter((marker) => Math.abs(marker.startLineNumber - position.lineNumber) <= 1);
|
|
95
105
|
|
|
96
106
|
if (markers.length) {
|
|
107
|
+
const relativeWorkspacePath = await this.workspaceService.asRelativePath(resource.path);
|
|
108
|
+
|
|
97
109
|
this.setBean({
|
|
98
110
|
typing: ECodeEditsSourceTyping.LinterErrors,
|
|
111
|
+
position,
|
|
99
112
|
data: {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
113
|
+
relativeWorkspacePath: relativeWorkspacePath?.path ?? resource.path,
|
|
114
|
+
errors: markers.map((marker) => MarkerErrorData.toData(marker)),
|
|
103
115
|
},
|
|
104
116
|
});
|
|
105
117
|
}
|
package/src/browser/index.ts
CHANGED
|
@@ -46,7 +46,7 @@ import { LanguageParserService } from './languages/service';
|
|
|
46
46
|
import { AINativePreferencesContribution } from './preferences';
|
|
47
47
|
import { AINativeCoreContribution } from './types';
|
|
48
48
|
import { InlineChatFeatureRegistry } from './widget/inline-chat/inline-chat.feature.registry';
|
|
49
|
-
import {
|
|
49
|
+
import { AIInlineChatService } from './widget/inline-chat/inline-chat.service';
|
|
50
50
|
import { InlineDiffService } from './widget/inline-diff';
|
|
51
51
|
|
|
52
52
|
@Injectable()
|
|
@@ -90,7 +90,7 @@ export class AINativeModule extends BrowserModule {
|
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
token: IAIInlineChatService,
|
|
93
|
-
useClass:
|
|
93
|
+
useClass: AIInlineChatService,
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
token: IChatManagerService,
|
|
@@ -29,12 +29,7 @@ export class WasmModuleManager {
|
|
|
29
29
|
|
|
30
30
|
async initParser() {
|
|
31
31
|
const baseUrl = await this.resolvedResourceUriDeferred.promise;
|
|
32
|
-
|
|
33
|
-
if (baseUrl.endsWith('/')) {
|
|
34
|
-
wasmPath = `${baseUrl}tree-sitter.wasm`;
|
|
35
|
-
} else {
|
|
36
|
-
wasmPath = `${baseUrl}/tree-sitter.wasm`;
|
|
37
|
-
}
|
|
32
|
+
const wasmPath = `${baseUrl}/tree-sitter.wasm`;
|
|
38
33
|
if (!this.parserInitialized) {
|
|
39
34
|
await Parser.init({
|
|
40
35
|
locateFile: () => wasmPath,
|
|
@@ -50,12 +45,7 @@ export class WasmModuleManager {
|
|
|
50
45
|
const deferred = new Deferred<ArrayBuffer>();
|
|
51
46
|
this.cachedRuntime.set(language, deferred);
|
|
52
47
|
const baseUrl = await this.resolvedResourceUriDeferred.promise;
|
|
53
|
-
|
|
54
|
-
if (baseUrl.endsWith('/')) {
|
|
55
|
-
wasmUrl = `${baseUrl}tree-sitter-${language}.wasm`;
|
|
56
|
-
} else {
|
|
57
|
-
wasmUrl = `${baseUrl}/tree-sitter-${language}.wasm`;
|
|
58
|
-
}
|
|
48
|
+
const wasmUrl = `${baseUrl}/tree-sitter-${language}.wasm`;
|
|
59
49
|
fetch(wasmUrl)
|
|
60
50
|
.then((res) => res.arrayBuffer())
|
|
61
51
|
.then((buffer) => {
|
|
@@ -10,14 +10,11 @@ export const AILayout = () => {
|
|
|
10
10
|
const { layout } = getStorageValue();
|
|
11
11
|
const designLayoutConfig = useInjectable(DesignLayoutConfig);
|
|
12
12
|
|
|
13
|
-
const defaultRightSize = useMemo(
|
|
14
|
-
() => (designLayoutConfig.useMergeRightWithLeftPanel ? 0 : 49),
|
|
15
|
-
[designLayoutConfig.useMergeRightWithLeftPanel],
|
|
16
|
-
);
|
|
13
|
+
const defaultRightSize = useMemo(() => designLayoutConfig.useMergeRightWithLeftPanel ? 0 : 49, [designLayoutConfig.useMergeRightWithLeftPanel]);
|
|
17
14
|
|
|
18
15
|
return (
|
|
19
16
|
<BoxPanel direction='top-to-bottom'>
|
|
20
|
-
<SlotRenderer id='top' defaultSize={layout.top?.currentId ? layout.top?.size ||
|
|
17
|
+
<SlotRenderer id='top' defaultSize={layout.top?.currentId ? layout.top?.size || 35 : 0} slot='top' />
|
|
21
18
|
<SplitPanel
|
|
22
19
|
id='main-horizontal-ai'
|
|
23
20
|
flex={1}
|
|
@@ -119,20 +119,20 @@
|
|
|
119
119
|
border: none;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
.header {
|
|
123
|
-
height: 36px;
|
|
124
|
-
display: flex;
|
|
125
|
-
align-items: center;
|
|
126
|
-
justify-content: space-between;
|
|
127
|
-
padding: 0 10px;
|
|
128
|
-
background-color: var(--editorGroupHeader-tabsBackground);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
122
|
.right_slot_container_wrap {
|
|
132
123
|
height: 100%;
|
|
133
124
|
display: flex;
|
|
134
125
|
flex-direction: column;
|
|
135
126
|
|
|
127
|
+
.header {
|
|
128
|
+
height: 36px;
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: space-between;
|
|
132
|
+
padding: 0 10px;
|
|
133
|
+
background-color: var(--editorGroupHeader-tabsBackground);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
136
|
.container {
|
|
137
137
|
flex: 1;
|
|
138
138
|
}
|
|
@@ -174,18 +174,16 @@ export const AIRightTabRenderer = ({
|
|
|
174
174
|
return (
|
|
175
175
|
<ContainerView
|
|
176
176
|
{...props}
|
|
177
|
-
customTitleBar={
|
|
178
|
-
<div className={styles.header}>
|
|
179
|
-
<span className={styles.title}>{options && options.title}</span>
|
|
180
|
-
<div className={styles.side}>
|
|
181
|
-
<EnhancePopover id={'ai_right_panel_header_close'} title={localize('editor.title.context.close')}>
|
|
182
|
-
<EnhanceIcon icon='close' onClick={handleClose} />
|
|
183
|
-
</EnhancePopover>
|
|
184
|
-
</div>
|
|
185
|
-
</div>
|
|
186
|
-
}
|
|
187
177
|
renderContainerWrap={({ children }) => (
|
|
188
178
|
<div className={styles.right_slot_container_wrap}>
|
|
179
|
+
<div className={styles.header}>
|
|
180
|
+
<span className={styles.title}>{options && options.title}</span>
|
|
181
|
+
<div className={styles.side}>
|
|
182
|
+
<EnhancePopover id={'ai_right_panel_header_close'} title={localize('editor.title.context.close')}>
|
|
183
|
+
<EnhanceIcon icon='close' onClick={handleClose} />
|
|
184
|
+
</EnhancePopover>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
189
187
|
<div className={styles.container}>{children}</div>
|
|
190
188
|
</div>
|
|
191
189
|
)}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { Disposable, Emitter, Event, isDefined, isUndefined
|
|
1
|
+
import { Disposable, Emitter, Event, isDefined, isUndefined } from '@opensumi/ide-core-common';
|
|
2
2
|
import {
|
|
3
3
|
ICodeEditor,
|
|
4
4
|
IContentSizeChangedEvent,
|
|
5
5
|
IModelDecorationOptions,
|
|
6
|
+
IModelDecorationsChangeAccessor,
|
|
6
7
|
IModelDeltaDecoration,
|
|
7
8
|
IPosition,
|
|
8
9
|
IRange,
|
|
9
10
|
ITextModel,
|
|
11
|
+
Range,
|
|
10
12
|
} from '@opensumi/ide-monaco';
|
|
13
|
+
import { space } from '@opensumi/ide-utils/lib/strings';
|
|
11
14
|
import { UndoRedoGroup } from '@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo';
|
|
12
15
|
|
|
16
|
+
import styles from './styles.module.less';
|
|
17
|
+
|
|
13
18
|
export interface IDecorationSerializableState {
|
|
14
19
|
startPosition: IPosition;
|
|
15
20
|
endPosition: IPosition;
|
|
@@ -23,10 +28,8 @@ interface IDeltaData extends IModelDeltaDecoration {
|
|
|
23
28
|
|
|
24
29
|
export interface IEnhanceModelDeltaDecoration extends IDeltaData {
|
|
25
30
|
id: string;
|
|
26
|
-
decorationId: string;
|
|
27
31
|
isHidden: boolean;
|
|
28
32
|
readonly editorDecoration: IModelDeltaDecoration;
|
|
29
|
-
show(): void;
|
|
30
33
|
hide(): void;
|
|
31
34
|
resume(): void;
|
|
32
35
|
getRange(): IRange;
|
|
@@ -44,13 +47,12 @@ export interface IDeltaDecorationsOptions {
|
|
|
44
47
|
group?: UndoRedoGroup;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
48
51
|
length: number;
|
|
49
52
|
range: IRange;
|
|
50
53
|
options: IModelDecorationOptions;
|
|
51
54
|
|
|
52
55
|
private resumeRange: IRange;
|
|
53
|
-
private _decorationId: string;
|
|
54
56
|
private _group: UndoRedoGroup;
|
|
55
57
|
|
|
56
58
|
private _hidden = false;
|
|
@@ -70,10 +72,6 @@ export class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
70
72
|
return this.metadata.id;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
get decorationId(): string {
|
|
74
|
-
return this._decorationId;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
75
|
get editorDecoration(): IModelDeltaDecoration {
|
|
78
76
|
return this.metadata.editorDecoration;
|
|
79
77
|
}
|
|
@@ -110,6 +108,25 @@ export class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
110
108
|
this._group = group;
|
|
111
109
|
}
|
|
112
110
|
|
|
111
|
+
private changeVisibility(newClassName: string, newRange: Range): void {
|
|
112
|
+
if (!this.options.className) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const classList = this.options.className
|
|
117
|
+
.split(space)
|
|
118
|
+
.filter((s) => s !== styles.hidden && s !== styles.visible)
|
|
119
|
+
.filter(Boolean);
|
|
120
|
+
classList.push(newClassName);
|
|
121
|
+
|
|
122
|
+
this.options.className = classList.join(space);
|
|
123
|
+
|
|
124
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
125
|
+
accessor.changeDecorationOptions(this.id, this.options);
|
|
126
|
+
accessor.changeDecoration(this.id, newRange);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
113
130
|
setRange(newRange: IRange): void {
|
|
114
131
|
this.range = newRange;
|
|
115
132
|
}
|
|
@@ -119,45 +136,28 @@ export class DeltaDecorations implements IEnhanceModelDeltaDecoration {
|
|
|
119
136
|
}
|
|
120
137
|
|
|
121
138
|
dispose(): void {
|
|
122
|
-
this.hide();
|
|
123
139
|
this.deltaData.dispose?.();
|
|
124
140
|
}
|
|
125
141
|
|
|
126
|
-
show(): void {
|
|
127
|
-
this.codeEditor.changeDecorations((accessor) => {
|
|
128
|
-
this._decorationId = accessor.addDecoration(this.range, this.options);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
142
|
hide(): void {
|
|
133
143
|
this.resumeRange = this.range;
|
|
134
144
|
this._hidden = true;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
}
|
|
145
|
+
const startPosition = { lineNumber: this.range.startLineNumber, column: 1 };
|
|
146
|
+
const newRange = Range.fromPositions(startPosition);
|
|
147
|
+
this.changeVisibility(styles.hidden, newRange);
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
resume(): void {
|
|
143
|
-
if (!this._hidden) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
151
|
this._hidden = false;
|
|
148
|
-
this.
|
|
149
|
-
this._decorationId = accessor.addDecoration(this.resumeRange, this.options);
|
|
150
|
-
});
|
|
152
|
+
this.changeVisibility(styles.visible, Range.lift(this.resumeRange));
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
|
|
154
|
-
export class EnhanceDecorationsCollection
|
|
155
|
-
|
|
156
|
-
> extends Disposable {
|
|
157
|
-
private deltaDecorations: T[] = [];
|
|
156
|
+
export class EnhanceDecorationsCollection extends Disposable {
|
|
157
|
+
private deltaDecorations: IEnhanceModelDeltaDecoration[] = [];
|
|
158
158
|
|
|
159
|
-
protected readonly _onDidDecorationsChange = this.registerDispose(new Emitter<
|
|
160
|
-
public readonly onDidDecorationsChange: Event<
|
|
159
|
+
protected readonly _onDidDecorationsChange = this.registerDispose(new Emitter<IEnhanceModelDeltaDecoration[]>());
|
|
160
|
+
public readonly onDidDecorationsChange: Event<IEnhanceModelDeltaDecoration[]> = this._onDidDecorationsChange.event;
|
|
161
161
|
|
|
162
162
|
private get model(): ITextModel {
|
|
163
163
|
return this.codeEditor.getModel()!;
|
|
@@ -182,11 +182,11 @@ export class EnhanceDecorationsCollection<
|
|
|
182
182
|
private flush(): void {
|
|
183
183
|
this.deltaDecorations = this.deltaDecorations.map((d) => {
|
|
184
184
|
const {
|
|
185
|
-
|
|
185
|
+
id,
|
|
186
186
|
editorDecoration: { range },
|
|
187
187
|
} = d;
|
|
188
188
|
|
|
189
|
-
const newRange = this.model.getDecorationRange(
|
|
189
|
+
const newRange = this.model.getDecorationRange(id);
|
|
190
190
|
d.setRange(newRange ?? range);
|
|
191
191
|
|
|
192
192
|
return d;
|
|
@@ -196,51 +196,66 @@ export class EnhanceDecorationsCollection<
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
private delete(id: string): void {
|
|
199
|
-
this.
|
|
199
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
200
|
+
accessor.removeDecoration(id);
|
|
201
|
+
|
|
202
|
+
this.deltaDecorations = this.deltaDecorations.filter((d) => d.id !== id);
|
|
203
|
+
});
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
protected createDecorations(metaData: IDeltaDecorationsOptions) {
|
|
203
|
-
return new DeltaDecorations(metaData)
|
|
207
|
+
return new DeltaDecorations(metaData);
|
|
204
208
|
}
|
|
205
209
|
|
|
206
|
-
set(
|
|
210
|
+
set(
|
|
211
|
+
decorations: (IModelDeltaDecoration &
|
|
212
|
+
Partial<Pick<IEnhanceModelDeltaDecoration, 'length' | 'isHidden' | 'group'>>)[],
|
|
213
|
+
): void {
|
|
207
214
|
this.clear();
|
|
208
215
|
|
|
209
|
-
this.
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
id,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
216
|
+
this.codeEditor.changeDecorations((accessor: IModelDecorationsChangeAccessor) => {
|
|
217
|
+
const newDecorations: IEnhanceModelDeltaDecoration[] = [];
|
|
218
|
+
|
|
219
|
+
for (const decoration of decorations) {
|
|
220
|
+
const id = accessor.addDecoration(decoration.range, decoration.options);
|
|
221
|
+
newDecorations.push(
|
|
222
|
+
this.createDecorations({
|
|
223
|
+
id,
|
|
224
|
+
editorDecoration: decoration,
|
|
225
|
+
codeEditor: this.codeEditor,
|
|
226
|
+
isHidden: decoration.isHidden,
|
|
227
|
+
group: decoration.group,
|
|
228
|
+
deltaData: {
|
|
229
|
+
dispose: () => this.delete(id),
|
|
230
|
+
length: decoration.length,
|
|
231
|
+
},
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
this.deltaDecorations = newDecorations;
|
|
227
237
|
});
|
|
228
238
|
}
|
|
229
239
|
|
|
230
|
-
getDecorations():
|
|
240
|
+
getDecorations(): IEnhanceModelDeltaDecoration[] {
|
|
231
241
|
return this.deltaDecorations;
|
|
232
242
|
}
|
|
233
243
|
|
|
234
|
-
getDecorationByGroup(group: UndoRedoGroup):
|
|
244
|
+
getDecorationByGroup(group: UndoRedoGroup): IEnhanceModelDeltaDecoration | undefined {
|
|
235
245
|
return this.deltaDecorations.find((d) => d.group === group);
|
|
236
246
|
}
|
|
237
247
|
|
|
238
|
-
getDecorationByLineNumber(lineNumber: number):
|
|
248
|
+
getDecorationByLineNumber(lineNumber: number): IEnhanceModelDeltaDecoration | undefined {
|
|
239
249
|
return this.deltaDecorations.find((d) => d.getRange().startLineNumber === lineNumber);
|
|
240
250
|
}
|
|
241
251
|
|
|
242
252
|
clear(): void {
|
|
243
|
-
this.
|
|
244
|
-
|
|
253
|
+
this.codeEditor.changeDecorations((accessor) => {
|
|
254
|
+
for (const decoration of this.deltaDecorations) {
|
|
255
|
+
accessor.removeDecoration(decoration.id);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
this.deltaDecorations = [];
|
|
259
|
+
});
|
|
245
260
|
}
|
|
246
261
|
}
|