@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
|
@@ -1,281 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var AcceptPartialEditWidget_1;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.LivePreviewDiffDecorationModel =
|
|
3
|
+
exports.LivePreviewDiffDecorationModel = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
|
-
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
7
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
8
|
-
const client_1 = tslib_1.__importDefault(require("react-dom/client"));
|
|
9
5
|
const di_1 = require("@opensumi/di");
|
|
10
6
|
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
|
|
11
|
-
const command_1 = require("@opensumi/ide-core-browser/lib/ai-native/command");
|
|
12
7
|
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
13
8
|
const ide_monaco_1 = require("@opensumi/ide-monaco");
|
|
14
|
-
const BaseInlineContentWidget_1 = require("@opensumi/ide-monaco/lib/browser/ai-native/BaseInlineContentWidget");
|
|
15
9
|
const services_1 = require("@opensumi/ide-monaco/lib/browser/monaco-api/services");
|
|
16
|
-
const editor_1 = require("@opensumi/ide-monaco/lib/browser/monaco-exports/editor");
|
|
17
|
-
const editorOptions_1 = require("@opensumi/monaco-editor-core/esm/vs/editor/common/config/editorOptions");
|
|
18
10
|
const editOperation_1 = require("@opensumi/monaco-editor-core/esm/vs/editor/common/core/editOperation");
|
|
19
|
-
const lineRange_1 = require("@opensumi/monaco-editor-core/esm/vs/editor/common/core/lineRange");
|
|
20
11
|
const textModel_1 = require("@opensumi/monaco-editor-core/esm/vs/editor/common/model/textModel");
|
|
21
|
-
const zoneWidget_1 = require("@opensumi/monaco-editor-core/esm/vs/editor/contrib/zoneWidget/browser/zoneWidget");
|
|
22
12
|
const undoRedo_1 = require("@opensumi/monaco-editor-core/esm/vs/platform/undoRedo/common/undoRedo");
|
|
23
13
|
const ai_native_contextkey_service_1 = require("../../contextkey/ai-native.contextkey.service");
|
|
24
14
|
const enhanceDecorationsCollection_1 = require("../../model/enhanceDecorationsCollection");
|
|
25
|
-
const index_1 = require("../ghost-text-widget/index");
|
|
26
15
|
const inline_stream_diff_module_less_1 = tslib_1.__importDefault(require("./inline-stream-diff.module.less"));
|
|
27
16
|
const inline_stream_diff_service_1 = require("./inline-stream-diff.service");
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const PendingRangeDecoration = 'pending-range-decoration';
|
|
31
|
-
var EPartialEdit;
|
|
32
|
-
(function (EPartialEdit) {
|
|
33
|
-
EPartialEdit["accept"] = "accept";
|
|
34
|
-
EPartialEdit["discard"] = "discard";
|
|
35
|
-
})(EPartialEdit = exports.EPartialEdit || (exports.EPartialEdit = {}));
|
|
36
|
-
const PartialEditComponent = (props) => {
|
|
37
|
-
const { keyStrings, onAccept, onDiscard, editor } = props;
|
|
38
|
-
const [scrollLeft, setScrollLeft] = react_1.default.useState(0);
|
|
39
|
-
const handleAccept = (0, react_1.useCallback)(() => {
|
|
40
|
-
onAccept === null || onAccept === void 0 ? void 0 : onAccept();
|
|
41
|
-
}, [onAccept]);
|
|
42
|
-
const handleDiscard = (0, react_1.useCallback)(() => {
|
|
43
|
-
onDiscard === null || onDiscard === void 0 ? void 0 : onDiscard();
|
|
44
|
-
}, [onDiscard]);
|
|
45
|
-
(0, ide_core_browser_1.useDisposable)(() => editor.onDidScrollChange((event) => {
|
|
46
|
-
const { scrollLeftChanged, scrollLeft } = event;
|
|
47
|
-
if (scrollLeftChanged) {
|
|
48
|
-
setScrollLeft(scrollLeft);
|
|
49
|
-
}
|
|
50
|
-
}), [editor]);
|
|
51
|
-
return (react_1.default.createElement("div", { className: inline_stream_diff_module_less_1.default.inline_diff_accept_partial_widget_container, style: { marginLeft: scrollLeft + 'px' } },
|
|
52
|
-
react_1.default.createElement("div", { className: inline_stream_diff_module_less_1.default.content },
|
|
53
|
-
react_1.default.createElement("span", { className: (0, classnames_1.default)(inline_stream_diff_module_less_1.default.accept_btn, inline_stream_diff_module_less_1.default.btn), onClick: handleAccept }, keyStrings.acceptSequence),
|
|
54
|
-
react_1.default.createElement("span", { className: (0, classnames_1.default)(inline_stream_diff_module_less_1.default.discard_btn, inline_stream_diff_module_less_1.default.btn), onClick: handleDiscard }, keyStrings.discardSequence))));
|
|
55
|
-
};
|
|
56
|
-
let AcceptPartialEditWidget = AcceptPartialEditWidget_1 = class AcceptPartialEditWidget extends BaseInlineContentWidget_1.ReactInlineContentWidget {
|
|
57
|
-
constructor() {
|
|
58
|
-
super(...arguments);
|
|
59
|
-
this._onAccept = this.registerDispose(new ide_core_common_1.Emitter());
|
|
60
|
-
this.onAccept = this._onAccept.event;
|
|
61
|
-
this._onDiscard = this.registerDispose(new ide_core_common_1.Emitter());
|
|
62
|
-
this.onDiscard = this._onDiscard.event;
|
|
63
|
-
this.positionPreference = [editor_1.ContentWidgetPositionPreference.EXACT];
|
|
64
|
-
this.addedLinesCount = 0;
|
|
65
|
-
this.deletedLinesCount = 0;
|
|
66
|
-
this.status = 'pending';
|
|
67
|
-
}
|
|
68
|
-
getSequenceKeyStrings() {
|
|
69
|
-
let keybindings = this.keybindingRegistry.getKeybindingsForCommand(command_1.AI_INLINE_DIFF_PARTIAL_EDIT.id);
|
|
70
|
-
keybindings = keybindings.sort((a, b) => b.args - a.args);
|
|
71
|
-
if (!keybindings || (keybindings.length !== 2 && keybindings.some((k) => (0, ide_core_common_1.isUndefined)(k.resolved)))) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
acceptSequence: this.keybindingRegistry.acceleratorForSequence(keybindings[0].resolved, '')[0],
|
|
76
|
-
discardSequence: this.keybindingRegistry.acceleratorForSequence(keybindings[1].resolved, '')[0],
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
renderView() {
|
|
80
|
-
const keyStrings = this.getSequenceKeyStrings();
|
|
81
|
-
if (!keyStrings) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
return (react_1.default.createElement(PartialEditComponent, { keyStrings: keyStrings, onAccept: () => this._onAccept.fire(), onDiscard: () => this._onDiscard.fire(), editor: this.editor }));
|
|
85
|
-
}
|
|
86
|
-
id() {
|
|
87
|
-
if (!this._id) {
|
|
88
|
-
this._id = `${AcceptPartialEditWidget_1.ID}_${(0, ide_core_common_1.uuid)(4)}`;
|
|
89
|
-
}
|
|
90
|
-
return this._id;
|
|
91
|
-
}
|
|
92
|
-
getClassName() {
|
|
93
|
-
return inline_stream_diff_module_less_1.default.accept_partial_edit_widget_id;
|
|
94
|
-
}
|
|
95
|
-
recordDecorationId(id) {
|
|
96
|
-
this._decorationId = id;
|
|
97
|
-
}
|
|
98
|
-
getDecorationId() {
|
|
99
|
-
return this._decorationId;
|
|
100
|
-
}
|
|
101
|
-
resume() {
|
|
102
|
-
this.status = 'pending';
|
|
103
|
-
this.addedLinesCount = 0;
|
|
104
|
-
this.deletedLinesCount = 0;
|
|
105
|
-
super.resume();
|
|
106
|
-
}
|
|
107
|
-
accept(addedLinesCount, deletedLinesCount) {
|
|
108
|
-
this.status = 'accept';
|
|
109
|
-
this.addedLinesCount = addedLinesCount;
|
|
110
|
-
this.deletedLinesCount = deletedLinesCount;
|
|
111
|
-
super.hide();
|
|
112
|
-
}
|
|
113
|
-
get isAccepted() {
|
|
114
|
-
return this.status === 'accept';
|
|
115
|
-
}
|
|
116
|
-
discard(addedLinesCount, deletedLinesCount) {
|
|
117
|
-
this.status = 'discard';
|
|
118
|
-
this.addedLinesCount = addedLinesCount;
|
|
119
|
-
this.deletedLinesCount = deletedLinesCount;
|
|
120
|
-
super.hide();
|
|
121
|
-
}
|
|
122
|
-
get isRejected() {
|
|
123
|
-
return this.status === 'discard';
|
|
124
|
-
}
|
|
125
|
-
serializeState() {
|
|
126
|
-
return {
|
|
127
|
-
addedLinesCount: this.addedLinesCount,
|
|
128
|
-
deletedLinesCount: this.deletedLinesCount,
|
|
129
|
-
status: this.status,
|
|
130
|
-
lineNumber: this.getPosition().position.lineNumber,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
restoreSerializedState(state) {
|
|
134
|
-
if (state.status === 'accept') {
|
|
135
|
-
this.accept(state.addedLinesCount, state.deletedLinesCount);
|
|
136
|
-
}
|
|
137
|
-
else if (state.status === 'discard') {
|
|
138
|
-
this.discard(state.addedLinesCount, state.deletedLinesCount);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this.resume();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
AcceptPartialEditWidget.ID = 'AcceptPartialEditWidgetID';
|
|
146
|
-
tslib_1.__decorate([
|
|
147
|
-
(0, di_1.Autowired)(ide_core_browser_1.KeybindingRegistry),
|
|
148
|
-
tslib_1.__metadata("design:type", Object)
|
|
149
|
-
], AcceptPartialEditWidget.prototype, "keybindingRegistry", void 0);
|
|
150
|
-
AcceptPartialEditWidget = AcceptPartialEditWidget_1 = tslib_1.__decorate([
|
|
151
|
-
(0, di_1.Injectable)({ multiple: true })
|
|
152
|
-
], AcceptPartialEditWidget);
|
|
153
|
-
exports.AcceptPartialEditWidget = AcceptPartialEditWidget;
|
|
154
|
-
const RemovedWidgetComponent = ({ dom, editor }) => {
|
|
155
|
-
const ref = react_1.default.useRef(null);
|
|
156
|
-
const [scrollLeft, setScrollLeft] = react_1.default.useState(0);
|
|
157
|
-
const [marginWidth, setMarginWidth] = react_1.default.useState(0);
|
|
158
|
-
(0, react_1.useEffect)(() => {
|
|
159
|
-
if (dom && ref && ref.current) {
|
|
160
|
-
ref.current.appendChild(dom);
|
|
161
|
-
}
|
|
162
|
-
}, [dom, ref]);
|
|
163
|
-
(0, ide_core_browser_1.useDisposable)(() => editor.onDidScrollChange((event) => {
|
|
164
|
-
const { scrollLeftChanged, scrollLeft } = event;
|
|
165
|
-
if (scrollLeftChanged) {
|
|
166
|
-
setScrollLeft(scrollLeft);
|
|
167
|
-
}
|
|
168
|
-
}), [editor]);
|
|
169
|
-
(0, ide_core_browser_1.useDisposable)(() => {
|
|
170
|
-
setMarginWidth(editor.getOption(editorOptions_1.EditorOption.layoutInfo).contentLeft);
|
|
171
|
-
return editor.onDidChangeConfiguration((event) => {
|
|
172
|
-
if (event.hasChanged(editorOptions_1.EditorOption.layoutInfo)) {
|
|
173
|
-
setMarginWidth(editor.getOption(editorOptions_1.EditorOption.layoutInfo).contentLeft);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}, [editor]);
|
|
177
|
-
return (react_1.default.createElement("div", { className: inline_stream_diff_module_less_1.default.inline_diff_remove_zone_fixed_box, style: { marginLeft: marginWidth + 'px' } },
|
|
178
|
-
react_1.default.createElement("div", { className: inline_stream_diff_module_less_1.default.inline_diff_remove_zone, ref: ref, style: { marginLeft: -scrollLeft + 'px' } })));
|
|
179
|
-
};
|
|
180
|
-
class RemovedZoneWidget extends zoneWidget_1.ZoneWidget {
|
|
181
|
-
get isHidden() {
|
|
182
|
-
return this._hidden;
|
|
183
|
-
}
|
|
184
|
-
constructor(editor, textLines, options) {
|
|
185
|
-
super(editor, options);
|
|
186
|
-
this.textLines = textLines;
|
|
187
|
-
this._hidden = false;
|
|
188
|
-
}
|
|
189
|
-
_fillContainer(container) {
|
|
190
|
-
container.classList.add(inline_stream_diff_module_less_1.default.inline_diff_remove_zone_widget_container);
|
|
191
|
-
this.root = client_1.default.createRoot(container);
|
|
192
|
-
}
|
|
193
|
-
getRemovedTextLines() {
|
|
194
|
-
return this.textLines.map((v) => v.text);
|
|
195
|
-
}
|
|
196
|
-
get height() {
|
|
197
|
-
return this.textLines.length;
|
|
198
|
-
}
|
|
199
|
-
getLastPosition() {
|
|
200
|
-
return this.recordPositionData.position;
|
|
201
|
-
}
|
|
202
|
-
serializeState() {
|
|
203
|
-
return {
|
|
204
|
-
textLines: this.textLines,
|
|
205
|
-
position: this.getLastPosition(),
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
hide() {
|
|
209
|
-
var _a;
|
|
210
|
-
if (this._viewZone && this.position) {
|
|
211
|
-
this.recordPositionData = {
|
|
212
|
-
position: this.position,
|
|
213
|
-
heightInLines: (_a = this._viewZone) === null || _a === void 0 ? void 0 : _a.heightInLines,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
this._hidden = true;
|
|
217
|
-
super.hide();
|
|
218
|
-
}
|
|
219
|
-
resume() {
|
|
220
|
-
if (this.recordPositionData) {
|
|
221
|
-
this.show(this.recordPositionData.position, this.recordPositionData.heightInLines);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
show(pos, heightInLines) {
|
|
225
|
-
this.recordPositionData = { position: pos, heightInLines };
|
|
226
|
-
this._hidden = false;
|
|
227
|
-
super.show(pos, heightInLines);
|
|
228
|
-
}
|
|
229
|
-
revealRange() { }
|
|
230
|
-
create() {
|
|
231
|
-
super.create();
|
|
232
|
-
const dom = document.createElement('div');
|
|
233
|
-
(0, index_1.renderLines)(dom, this.editor.getOption(editorOptions_1.EditorOption.tabIndex), this.textLines.map(({ text: content, lineTokens }) => ({
|
|
234
|
-
content,
|
|
235
|
-
decorations: [],
|
|
236
|
-
lineTokens,
|
|
237
|
-
})), this.editor.getOptions());
|
|
238
|
-
this.root.render(react_1.default.createElement(RemovedWidgetComponent, { dom: dom, editor: this.editor }));
|
|
239
|
-
}
|
|
240
|
-
dispose() {
|
|
241
|
-
this.root.unmount();
|
|
242
|
-
super.dispose();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
17
|
+
const live_preview_stack_1 = require("./live-preview-stack");
|
|
18
|
+
const live_preview_component_1 = require("./live-preview.component");
|
|
245
19
|
let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extends ide_core_common_1.Disposable {
|
|
246
|
-
constructor(monacoEditor
|
|
20
|
+
constructor(monacoEditor) {
|
|
247
21
|
super();
|
|
248
22
|
this.monacoEditor = monacoEditor;
|
|
249
|
-
this.selection = selection;
|
|
250
23
|
this._onPartialEditEvent = this.registerDispose(new ide_core_common_1.Emitter());
|
|
251
24
|
this.onPartialEditEvent = this._onPartialEditEvent.event;
|
|
252
|
-
this.partialEditWidgetList = [];
|
|
253
|
-
this.removedZoneWidgets = [];
|
|
254
25
|
this._onPartialEditWidgetListChange = this.registerDispose(new ide_core_common_1.Emitter());
|
|
255
26
|
this.onPartialEditWidgetListChange = this._onPartialEditWidgetListChange.event;
|
|
27
|
+
this.partialEditWidgetList = [];
|
|
28
|
+
this.removedZoneWidgets = [];
|
|
256
29
|
this.model = this.monacoEditor.getModel();
|
|
30
|
+
this.undoRedoService = services_1.StandaloneServices.get(undoRedo_1.IUndoRedoService);
|
|
257
31
|
this.activeLineDec = this.monacoEditor.createDecorationsCollection();
|
|
258
32
|
this.pendingRangeDec = this.monacoEditor.createDecorationsCollection();
|
|
259
|
-
this.addedRangeDec = new enhanceDecorationsCollection_1.EnhanceDecorationsCollection(this.monacoEditor);
|
|
260
33
|
this.aiNativeContextKey = this.injector.get(ai_native_contextkey_service_1.AINativeContextKey, [this.monacoEditor.contextKeyService]);
|
|
261
|
-
this.undoRedoService = services_1.StandaloneServices.get(undoRedo_1.IUndoRedoService);
|
|
262
|
-
this.updateSelection(selection);
|
|
263
|
-
this.addDispose(this.addedRangeDec.onDidDecorationsChange((newAddedRangeDec) => {
|
|
264
|
-
const inlineDiffPartialEditsIsVisible = this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.get();
|
|
265
|
-
if (inlineDiffPartialEditsIsVisible) {
|
|
266
|
-
this.partialEditWidgetList.forEach((widget) => {
|
|
267
|
-
const addedWidget = newAddedRangeDec.find((a) => widget.getDecorationId() === a.id);
|
|
268
|
-
if (addedWidget) {
|
|
269
|
-
const range = addedWidget.getRange();
|
|
270
|
-
/**
|
|
271
|
-
* 重新定位 added decoration 与 partial edit widget 的位置
|
|
272
|
-
*/
|
|
273
|
-
widget.setOptions({ position: { lineNumber: range.startLineNumber, column: 1 } });
|
|
274
|
-
widget.layoutContentWidget();
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}));
|
|
279
34
|
this.addDispose(this.inlineStreamDiffService.onAcceptDiscardPartialEdit((isAccept) => {
|
|
280
35
|
const currentPosition = this.monacoEditor.getPosition();
|
|
281
36
|
/**
|
|
@@ -292,7 +47,24 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
292
47
|
return distanceToPa - distanceToPb;
|
|
293
48
|
});
|
|
294
49
|
if (widget.length > 0) {
|
|
295
|
-
this.handlePartialEditAction(isAccept ? EPartialEdit.accept : EPartialEdit.discard, widget[0]);
|
|
50
|
+
this.handlePartialEditAction(isAccept ? live_preview_component_1.EPartialEdit.accept : live_preview_component_1.EPartialEdit.discard, widget[0]);
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
this.addedRangeDec = new enhanceDecorationsCollection_1.EnhanceDecorationsCollection(this.monacoEditor);
|
|
54
|
+
this.addDispose(this.addedRangeDec.onDidDecorationsChange((newAddedRangeDec) => {
|
|
55
|
+
const inlineDiffPartialEditsIsVisible = this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.get();
|
|
56
|
+
if (inlineDiffPartialEditsIsVisible) {
|
|
57
|
+
this.partialEditWidgetList.forEach((widget) => {
|
|
58
|
+
const addedWidget = newAddedRangeDec.find((a) => widget.getDecorationId() === a.id);
|
|
59
|
+
if (addedWidget) {
|
|
60
|
+
const range = addedWidget.getRange();
|
|
61
|
+
/**
|
|
62
|
+
* 重新定位 added decoration 与 partial edit widget 的位置
|
|
63
|
+
*/
|
|
64
|
+
widget.setOptions({ position: { lineNumber: range.startLineNumber, column: 1 } });
|
|
65
|
+
widget.layoutContentWidget();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
296
68
|
}
|
|
297
69
|
}));
|
|
298
70
|
this.addDispose(ide_core_common_1.Disposable.create(() => {
|
|
@@ -306,21 +78,78 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
306
78
|
this.clearRemovedWidgets();
|
|
307
79
|
this.clearPartialEditWidgetList();
|
|
308
80
|
}
|
|
309
|
-
|
|
310
|
-
this.
|
|
311
|
-
|
|
81
|
+
initialize(zone) {
|
|
82
|
+
this.updateZone(zone);
|
|
83
|
+
}
|
|
84
|
+
restoreSnapshot(snapshot) {
|
|
85
|
+
const { addedDecList, removedWidgetList, zone, editStackSnapshot, partialEditWidgetList: snapshotPartialEditWidgetList, } = snapshot;
|
|
86
|
+
// restore zone
|
|
87
|
+
this.updateZone(zone);
|
|
88
|
+
// restore added
|
|
89
|
+
this.addedRangeDec.set(addedDecList);
|
|
90
|
+
// restore removed
|
|
91
|
+
this.clearRemovedWidgets();
|
|
92
|
+
removedWidgetList.forEach((widget) => {
|
|
93
|
+
const position = widget.getLastPosition();
|
|
94
|
+
if (position) {
|
|
95
|
+
this.showRemovedWidgetByLineNumber(position.lineNumber, widget.textLines, {
|
|
96
|
+
isHidden: widget.isHidden,
|
|
97
|
+
recordPosition: widget.getLastPosition(),
|
|
98
|
+
undoRedoGroup: widget.group,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
// restore partial edit widget
|
|
103
|
+
this.clearPartialEditWidgetList();
|
|
104
|
+
snapshotPartialEditWidgetList.forEach((snapshotWidget) => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
const lineNumber = (_b = (_a = snapshotWidget.getPosition()) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.lineNumber;
|
|
107
|
+
if (lineNumber) {
|
|
108
|
+
const newPartialEditWidget = this.createPartialEditWidget(lineNumber);
|
|
109
|
+
if (snapshotWidget.status === 'accept') {
|
|
110
|
+
newPartialEditWidget.accept(snapshotWidget.addedLinesCount, snapshotWidget.deletedLinesCount);
|
|
111
|
+
}
|
|
112
|
+
else if (snapshotWidget.status === 'discard') {
|
|
113
|
+
newPartialEditWidget.discard(snapshotWidget.addedLinesCount, snapshotWidget.deletedLinesCount);
|
|
114
|
+
}
|
|
115
|
+
newPartialEditWidget.setGroup(snapshotWidget.group);
|
|
116
|
+
this.partialEditWidgetList.push(newPartialEditWidget);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
this.firePartialEditWidgetList();
|
|
120
|
+
this.recordPartialEditWidgetWithAddedDec();
|
|
121
|
+
// restore undo/redo stack
|
|
122
|
+
const uri = this.model.uri;
|
|
123
|
+
this.undoRedoService.restoreSnapshot(editStackSnapshot);
|
|
124
|
+
const elements = this.undoRedoService.getElements(uri);
|
|
125
|
+
elements.future.concat(elements.past).forEach((node) => {
|
|
126
|
+
if (node instanceof live_preview_stack_1.LivePreviewUndoRedoStackElement) {
|
|
127
|
+
// 在每次 restore 的时候需要将当前的类重新指向到 undo/redo 的 stack 中
|
|
128
|
+
node.attachModel(this);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
createSnapshot() {
|
|
133
|
+
return {
|
|
134
|
+
addedDecList: this.addedRangeDec.getDecorations(),
|
|
135
|
+
partialEditWidgetList: this.partialEditWidgetList,
|
|
136
|
+
removedWidgetList: this.removedZoneWidgets,
|
|
137
|
+
editStackSnapshot: this.undoRedoService.createSnapshot(this.model.uri),
|
|
138
|
+
zone: this.zone,
|
|
139
|
+
};
|
|
312
140
|
}
|
|
313
|
-
showRemovedWidgetByLineNumber(lineNumber, texts) {
|
|
141
|
+
showRemovedWidgetByLineNumber(lineNumber, texts, options) {
|
|
314
142
|
const position = new ide_monaco_1.Position(lineNumber, 1);
|
|
315
143
|
const heightInLines = texts.length;
|
|
316
|
-
const widget = new RemovedZoneWidget(this.monacoEditor, texts, {
|
|
317
|
-
showInHiddenAreas: true,
|
|
318
|
-
showFrame: false,
|
|
319
|
-
showArrow: false,
|
|
320
|
-
});
|
|
144
|
+
const widget = new live_preview_component_1.RemovedZoneWidget(this.monacoEditor, texts, Object.assign(Object.assign({}, options), { showInHiddenAreas: true, showFrame: false, showArrow: false }));
|
|
321
145
|
widget.create();
|
|
322
|
-
widget.show(position, heightInLines);
|
|
323
146
|
this.removedZoneWidgets.push(widget);
|
|
147
|
+
if (options.isHidden) {
|
|
148
|
+
widget.hide();
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
widget.show(position, heightInLines);
|
|
152
|
+
}
|
|
324
153
|
}
|
|
325
154
|
updateZone(newZone) {
|
|
326
155
|
this.zone = newZone;
|
|
@@ -335,15 +164,12 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
335
164
|
range: ide_monaco_1.Range.fromPositions({
|
|
336
165
|
lineNumber: zone.startLineNumber + lineNumber - 1,
|
|
337
166
|
column: 0,
|
|
338
|
-
}, {
|
|
339
|
-
lineNumber: zone.startLineNumber + lineNumber - 1,
|
|
340
|
-
column: Number.MAX_SAFE_INTEGER,
|
|
341
167
|
}),
|
|
342
168
|
options: textModel_1.ModelDecorationOptions.register({
|
|
343
|
-
description: ActiveLineDecoration,
|
|
169
|
+
description: live_preview_component_1.ActiveLineDecoration,
|
|
344
170
|
isWholeLine: true,
|
|
345
171
|
className: inline_stream_diff_module_less_1.default.inline_diff_current,
|
|
346
|
-
zIndex: ide_core_browser_1.StackingLevel.
|
|
172
|
+
zIndex: ide_core_browser_1.StackingLevel.Workbench,
|
|
347
173
|
}),
|
|
348
174
|
},
|
|
349
175
|
]);
|
|
@@ -364,7 +190,7 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
364
190
|
addedDec.hide();
|
|
365
191
|
}
|
|
366
192
|
if (removedWidget) {
|
|
367
|
-
const position = removedWidget.
|
|
193
|
+
const position = removedWidget.getLastPosition();
|
|
368
194
|
const eol = this.model.getEOL();
|
|
369
195
|
const lines = removedWidget.getRemovedTextLines();
|
|
370
196
|
deletedLinesCount = lines.length;
|
|
@@ -386,50 +212,74 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
386
212
|
/**
|
|
387
213
|
* added widget 通常是在 removed widget 的下面一行的位置
|
|
388
214
|
*/
|
|
389
|
-
const removedWidget = this.removedZoneWidgets.find((w) =>
|
|
215
|
+
const removedWidget = this.removedZoneWidgets.find((w) => w.getLastPosition().lineNumber === Math.max(1, position.lineNumber - 1));
|
|
390
216
|
const addedDec = this.addedRangeDec.getDecorationByLineNumber(position.lineNumber);
|
|
391
217
|
const addedLinesCount = (addedDec === null || addedDec === void 0 ? void 0 : addedDec.length) || 0;
|
|
392
218
|
const deletedLinesCount = (removedWidget === null || removedWidget === void 0 ? void 0 : removedWidget.height) || 0;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
219
|
+
// 将 partial widget 的所有操作和代码变更放在单独的 undo/redo 堆栈组里面
|
|
220
|
+
const group = new undoRedo_1.UndoRedoGroup();
|
|
221
|
+
// 并将此刻的 group 信息记录到每个 widget/decoration 中
|
|
222
|
+
widget.setGroup(group);
|
|
223
|
+
removedWidget === null || removedWidget === void 0 ? void 0 : removedWidget.setGroup(group);
|
|
224
|
+
addedDec === null || addedDec === void 0 ? void 0 : addedDec.setGroup(group);
|
|
225
|
+
/**
|
|
226
|
+
* 在 undo/redo 的 stack 中,原本的 widget 和 decoration 信息已经是旧的数据了,所以不能直接拿旧的数据进行 resume 或 accept
|
|
227
|
+
* 需要根据 group 信息和当前实例的 LivePreviewDiffDecorationModel 对象重新找到 widget 和 decoration
|
|
228
|
+
*/
|
|
229
|
+
const findPartialWidgetByGroup = (model) => model.partialEditWidgetList.find((widget) => widget.group === group);
|
|
230
|
+
const findRemovedWidgetByGroup = (model) => model.removedZoneWidgets.find((widget) => widget.group === group);
|
|
231
|
+
const findAddedRangeDecByGroup = (model) => model.addedRangeDec.getDecorationByGroup(group);
|
|
232
|
+
const discard = (decorationModel) => {
|
|
233
|
+
const removedWidget = findRemovedWidgetByGroup(decorationModel);
|
|
396
234
|
removedWidget === null || removedWidget === void 0 ? void 0 : removedWidget.hide();
|
|
397
|
-
|
|
398
|
-
const discard = () => {
|
|
399
|
-
const operation = this.doDiscardPartialWidget(widget, addedDec, removedWidget);
|
|
235
|
+
const addedDec = findAddedRangeDecByGroup(decorationModel);
|
|
400
236
|
addedDec === null || addedDec === void 0 ? void 0 : addedDec.hide();
|
|
401
|
-
|
|
237
|
+
const partialEditWidget = findPartialWidgetByGroup(decorationModel);
|
|
238
|
+
const operation = this.doDiscardPartialWidget(partialEditWidget, addedDec, removedWidget);
|
|
402
239
|
return operation;
|
|
403
240
|
};
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
241
|
+
const accpet = (decorationModel) => {
|
|
242
|
+
const partialEditWidget = findPartialWidgetByGroup(decorationModel);
|
|
243
|
+
partialEditWidget === null || partialEditWidget === void 0 ? void 0 : partialEditWidget.accept(addedLinesCount, deletedLinesCount);
|
|
244
|
+
const removedWidget = findRemovedWidgetByGroup(decorationModel);
|
|
245
|
+
removedWidget === null || removedWidget === void 0 ? void 0 : removedWidget.hide();
|
|
246
|
+
const addedDec = findAddedRangeDecByGroup(decorationModel);
|
|
247
|
+
addedDec === null || addedDec === void 0 ? void 0 : addedDec.hide();
|
|
248
|
+
};
|
|
249
|
+
const resume = (decorationModel) => {
|
|
250
|
+
const partialEditWidget = findPartialWidgetByGroup(decorationModel);
|
|
251
|
+
partialEditWidget === null || partialEditWidget === void 0 ? void 0 : partialEditWidget.resume();
|
|
252
|
+
const removedWidget = findRemovedWidgetByGroup(decorationModel);
|
|
407
253
|
removedWidget === null || removedWidget === void 0 ? void 0 : removedWidget.resume();
|
|
254
|
+
const addedDec = findAddedRangeDecByGroup(decorationModel);
|
|
255
|
+
addedDec === null || addedDec === void 0 ? void 0 : addedDec.resume();
|
|
408
256
|
};
|
|
409
|
-
/**
|
|
410
|
-
* 将 partial widget 的所有操作和代码变更放在单独的 undo/redo 堆栈组里面
|
|
411
|
-
*/
|
|
412
|
-
const group = new undoRedo_1.UndoRedoGroup();
|
|
413
257
|
switch (type) {
|
|
414
|
-
case EPartialEdit.accept:
|
|
415
|
-
accpet();
|
|
258
|
+
case live_preview_component_1.EPartialEdit.accept:
|
|
259
|
+
accpet(this);
|
|
416
260
|
if (isPushStack) {
|
|
417
|
-
this.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
261
|
+
const stack = this.createEditStackElement(group);
|
|
262
|
+
stack.attachModel(this);
|
|
263
|
+
stack.registerUndo((model) => {
|
|
264
|
+
resume(model);
|
|
265
|
+
});
|
|
266
|
+
stack.registerRedo((model) => {
|
|
267
|
+
accpet(model);
|
|
421
268
|
});
|
|
422
269
|
}
|
|
423
270
|
break;
|
|
424
|
-
case EPartialEdit.discard:
|
|
271
|
+
case live_preview_component_1.EPartialEdit.discard:
|
|
425
272
|
{
|
|
426
|
-
const op = discard();
|
|
273
|
+
const op = discard(this);
|
|
427
274
|
if (op) {
|
|
428
275
|
if (isPushStack) {
|
|
429
|
-
this.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
276
|
+
const stack = this.createEditStackElement(group);
|
|
277
|
+
stack.attachModel(this);
|
|
278
|
+
stack.registerUndo((model) => {
|
|
279
|
+
resume(model);
|
|
280
|
+
});
|
|
281
|
+
stack.registerRedo((model) => {
|
|
282
|
+
discard(model);
|
|
433
283
|
});
|
|
434
284
|
}
|
|
435
285
|
model.pushStackElement();
|
|
@@ -448,7 +298,17 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
448
298
|
} }, this.getTotalCodeCount());
|
|
449
299
|
this.monacoEditor.focus();
|
|
450
300
|
this._onPartialEditEvent.fire(event);
|
|
301
|
+
this.firePartialEditWidgetList();
|
|
302
|
+
}
|
|
303
|
+
firePartialEditWidgetList() {
|
|
451
304
|
this._onPartialEditWidgetListChange.fire(this.partialEditWidgetList);
|
|
305
|
+
const visiableLists = this.partialEditWidgetList.filter((widget) => !widget.isHidden);
|
|
306
|
+
this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.set(visiableLists.length !== 0);
|
|
307
|
+
}
|
|
308
|
+
createEditStackElement(group) {
|
|
309
|
+
const newElement = new live_preview_stack_1.LivePreviewUndoRedoStackElement(this.model);
|
|
310
|
+
this.undoRedoService.pushElement(newElement, group);
|
|
311
|
+
return newElement;
|
|
452
312
|
}
|
|
453
313
|
getTotalCodeCount() {
|
|
454
314
|
const list = this.partialEditWidgetList.filter((w) => w.isAccepted);
|
|
@@ -475,58 +335,37 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
475
335
|
acceptUnProcessed() {
|
|
476
336
|
const showingWidgets = this.partialEditWidgetList.filter((widget) => !widget.isHidden);
|
|
477
337
|
showingWidgets.forEach((widget) => {
|
|
478
|
-
this.handlePartialEditAction(EPartialEdit.accept, widget, false);
|
|
338
|
+
this.handlePartialEditAction(live_preview_component_1.EPartialEdit.accept, widget, false);
|
|
479
339
|
});
|
|
480
340
|
}
|
|
481
341
|
discardUnProcessed() {
|
|
482
342
|
const showingWidgets = this.partialEditWidgetList.filter((widget) => !widget.isHidden);
|
|
483
343
|
showingWidgets.forEach((widget) => {
|
|
484
|
-
this.handlePartialEditAction(EPartialEdit.discard, widget, false);
|
|
344
|
+
this.handlePartialEditAction(live_preview_component_1.EPartialEdit.discard, widget, false);
|
|
485
345
|
});
|
|
486
346
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
},
|
|
505
|
-
}, group);
|
|
347
|
+
createPartialEditWidget(lineNumber) {
|
|
348
|
+
const acceptPartialEditWidget = this.injector.get(live_preview_component_1.AcceptPartialEditWidget, [this.monacoEditor]);
|
|
349
|
+
acceptPartialEditWidget.show({ position: { lineNumber, column: 1 } });
|
|
350
|
+
const disposable = acceptPartialEditWidget.onDispose(() => {
|
|
351
|
+
const id = acceptPartialEditWidget.getId();
|
|
352
|
+
this.partialEditWidgetList = this.partialEditWidgetList.filter((p) => p.getId() !== id);
|
|
353
|
+
disposable.dispose();
|
|
354
|
+
});
|
|
355
|
+
acceptPartialEditWidget.addDispose([
|
|
356
|
+
acceptPartialEditWidget.onAccept(() => {
|
|
357
|
+
this.handlePartialEditAction(live_preview_component_1.EPartialEdit.accept, acceptPartialEditWidget);
|
|
358
|
+
}),
|
|
359
|
+
acceptPartialEditWidget.onDiscard(() => {
|
|
360
|
+
this.handlePartialEditAction(live_preview_component_1.EPartialEdit.discard, acceptPartialEditWidget);
|
|
361
|
+
}),
|
|
362
|
+
]);
|
|
363
|
+
return acceptPartialEditWidget;
|
|
506
364
|
}
|
|
507
|
-
touchPartialEditWidgets(
|
|
365
|
+
touchPartialEditWidgets(lineNumbers) {
|
|
508
366
|
this.clearPartialEditWidgetList();
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
const acceptPartialEditWidget = this.injector.get(AcceptPartialEditWidget, [this.monacoEditor]);
|
|
512
|
-
acceptPartialEditWidget.show({ position: { lineNumber, column: 1 } });
|
|
513
|
-
dispoable.addDispose(acceptPartialEditWidget.onDispose(() => {
|
|
514
|
-
const id = acceptPartialEditWidget.getId();
|
|
515
|
-
this.partialEditWidgetList = this.partialEditWidgetList.filter((p) => p.getId() !== id);
|
|
516
|
-
dispoable.dispose();
|
|
517
|
-
}));
|
|
518
|
-
acceptPartialEditWidget.addDispose([
|
|
519
|
-
acceptPartialEditWidget.onAccept(() => {
|
|
520
|
-
this.handlePartialEditAction(EPartialEdit.accept, acceptPartialEditWidget);
|
|
521
|
-
}),
|
|
522
|
-
acceptPartialEditWidget.onDiscard(() => {
|
|
523
|
-
this.handlePartialEditAction(EPartialEdit.discard, acceptPartialEditWidget);
|
|
524
|
-
}),
|
|
525
|
-
]);
|
|
526
|
-
this.partialEditWidgetList.push(acceptPartialEditWidget);
|
|
527
|
-
});
|
|
528
|
-
this._onPartialEditWidgetListChange.fire(this.partialEditWidgetList);
|
|
529
|
-
this.aiNativeContextKey.inlineDiffPartialEditsIsVisible.set(true);
|
|
367
|
+
this.partialEditWidgetList = lineNumbers.map((lineNumber) => this.createPartialEditWidget(lineNumber));
|
|
368
|
+
this.firePartialEditWidgetList();
|
|
530
369
|
}
|
|
531
370
|
touchAddedRange(ranges) {
|
|
532
371
|
this.addedRangeDec.set(ranges.map((r) => {
|
|
@@ -542,11 +381,11 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
542
381
|
return {
|
|
543
382
|
length,
|
|
544
383
|
range,
|
|
384
|
+
isHidden: length === 0,
|
|
545
385
|
options: textModel_1.ModelDecorationOptions.register({
|
|
546
|
-
description: AddedRangeDecoration,
|
|
386
|
+
description: live_preview_component_1.AddedRangeDecoration,
|
|
547
387
|
isWholeLine: true,
|
|
548
388
|
className,
|
|
549
|
-
// stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
|
550
389
|
}),
|
|
551
390
|
};
|
|
552
391
|
}));
|
|
@@ -555,7 +394,7 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
555
394
|
touchRemovedWidget(states) {
|
|
556
395
|
this.clearRemovedWidgets();
|
|
557
396
|
states.forEach(({ textLines, position }) => {
|
|
558
|
-
this.showRemovedWidgetByLineNumber(position.lineNumber, textLines);
|
|
397
|
+
this.showRemovedWidgetByLineNumber(position.lineNumber, textLines, {});
|
|
559
398
|
});
|
|
560
399
|
}
|
|
561
400
|
touchPendingRange(range) {
|
|
@@ -570,7 +409,7 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
570
409
|
column: Number.MAX_SAFE_INTEGER,
|
|
571
410
|
}),
|
|
572
411
|
options: textModel_1.ModelDecorationOptions.register({
|
|
573
|
-
description: PendingRangeDecoration,
|
|
412
|
+
description: live_preview_component_1.PendingRangeDecoration,
|
|
574
413
|
isWholeLine: true,
|
|
575
414
|
className: inline_stream_diff_module_less_1.default.inline_diff_pending_range,
|
|
576
415
|
}),
|
|
@@ -599,36 +438,13 @@ let LivePreviewDiffDecorationModel = class LivePreviewDiffDecorationModel extend
|
|
|
599
438
|
});
|
|
600
439
|
this.removedZoneWidgets = [];
|
|
601
440
|
}
|
|
602
|
-
serializeState() {
|
|
603
|
-
const addedState = this.addedRangeDec.serializeState();
|
|
604
|
-
const removedTextLines = this.removedZoneWidgets.filter((v) => !v.isHidden).map((w) => w.serializeState());
|
|
605
|
-
const widgets = this.partialEditWidgetList.map((w) => w.serializeState());
|
|
606
|
-
const state = {
|
|
607
|
-
addedState,
|
|
608
|
-
removedTextLines,
|
|
609
|
-
widgets,
|
|
610
|
-
selection: this.selection,
|
|
611
|
-
};
|
|
612
|
-
return state;
|
|
613
|
-
}
|
|
614
|
-
restoreSerializedState(state) {
|
|
615
|
-
this.clear();
|
|
616
|
-
this.touchAddedRange(state.addedState);
|
|
617
|
-
const widgetLineNumber = state.widgets.map((w) => w.lineNumber);
|
|
618
|
-
this.touchPartialEditWidgets(widgetLineNumber);
|
|
619
|
-
widgetLineNumber.forEach((range, index) => {
|
|
620
|
-
const widget = this.partialEditWidgetList[index];
|
|
621
|
-
if (widget) {
|
|
622
|
-
widget.restoreSerializedState(state.widgets[index]);
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
this.touchRemovedWidget(state.removedTextLines);
|
|
626
|
-
}
|
|
627
441
|
revealFirstDiff() {
|
|
628
442
|
const first = this.removedZoneWidgets[0];
|
|
629
443
|
if (first) {
|
|
630
444
|
const pos = first.getLastPosition();
|
|
631
|
-
|
|
445
|
+
if (pos) {
|
|
446
|
+
this.monacoEditor.revealLineInCenterIfOutsideViewport(pos.lineNumber);
|
|
447
|
+
}
|
|
632
448
|
}
|
|
633
449
|
}
|
|
634
450
|
};
|
|
@@ -642,7 +458,7 @@ tslib_1.__decorate([
|
|
|
642
458
|
], LivePreviewDiffDecorationModel.prototype, "inlineStreamDiffService", void 0);
|
|
643
459
|
LivePreviewDiffDecorationModel = tslib_1.__decorate([
|
|
644
460
|
(0, di_1.Injectable)({ multiple: true }),
|
|
645
|
-
tslib_1.__metadata("design:paramtypes", [Object
|
|
461
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
646
462
|
], LivePreviewDiffDecorationModel);
|
|
647
463
|
exports.LivePreviewDiffDecorationModel = LivePreviewDiffDecorationModel;
|
|
648
464
|
//# sourceMappingURL=live-preview.decoration.js.map
|