@theia/plugin-ext 1.33.0 → 1.34.0-next.19
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/common/collections.d.ts +5 -0
- package/lib/common/collections.d.ts.map +1 -0
- package/lib/common/collections.js +40 -0
- package/lib/common/collections.js.map +1 -0
- package/lib/common/plugin-api-rpc-model.d.ts +2 -0
- package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc-model.js.map +1 -1
- package/lib/common/plugin-api-rpc.d.ts +103 -1
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js +12 -8
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/rpc-protocol.d.ts.map +1 -1
- package/lib/common/rpc-protocol.js +3 -4
- package/lib/common/rpc-protocol.js.map +1 -1
- package/lib/common/types.d.ts +5 -1
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js +13 -4
- package/lib/common/types.js.map +1 -1
- package/lib/hosted/node/hosted-plugin-localization-service.d.ts.map +1 -1
- package/lib/hosted/node/hosted-plugin-localization-service.js +2 -2
- package/lib/hosted/node/hosted-plugin-localization-service.js.map +1 -1
- package/lib/hosted/node/plugin-host.d.ts +1 -1
- package/lib/hosted/node/plugin-host.d.ts.map +1 -1
- package/lib/hosted/node/plugin-host.js +1 -2
- package/lib/hosted/node/plugin-host.js.map +1 -1
- package/lib/main/browser/comments/comment-thread-widget.d.ts +1 -0
- package/lib/main/browser/comments/comment-thread-widget.d.ts.map +1 -1
- package/lib/main/browser/comments/comment-thread-widget.js +11 -0
- package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
- package/lib/main/browser/tabs/tabs-main.d.ts +10 -0
- package/lib/main/browser/tabs/tabs-main.d.ts.map +1 -0
- package/lib/main/browser/tabs/tabs-main.js +33 -0
- package/lib/main/browser/tabs/tabs-main.js.map +1 -0
- package/lib/main/browser/terminal-main.d.ts +6 -3
- package/lib/main/browser/terminal-main.d.ts.map +1 -1
- package/lib/main/browser/terminal-main.js +22 -2
- package/lib/main/browser/terminal-main.js.map +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.d.ts +2 -4
- package/lib/main/browser/view/tree-view-decorator-service.d.ts.map +1 -1
- package/lib/main/browser/view/tree-view-decorator-service.js +1 -2
- package/lib/main/browser/view/tree-view-decorator-service.js.map +1 -1
- package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts +1 -1
- package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts.map +1 -1
- package/lib/plugin/comments.js +2 -0
- package/lib/plugin/comments.js.map +1 -1
- package/lib/plugin/languages/code-action.d.ts.map +1 -1
- package/lib/plugin/languages/code-action.js +8 -8
- package/lib/plugin/languages/code-action.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +15 -1
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/preference-registry.d.ts.map +1 -1
- package/lib/plugin/preference-registry.js +4 -2
- package/lib/plugin/preference-registry.js.map +1 -1
- package/lib/plugin/tabs.d.ts +23 -0
- package/lib/plugin/tabs.d.ts.map +1 -0
- package/lib/plugin/tabs.js +362 -0
- package/lib/plugin/tabs.js.map +1 -0
- package/lib/plugin/terminal-ext.d.ts.map +1 -1
- package/lib/plugin/terminal-ext.js +13 -1
- package/lib/plugin/terminal-ext.js.map +1 -1
- package/lib/plugin/type-converters.d.ts +4 -0
- package/lib/plugin/type-converters.d.ts.map +1 -1
- package/lib/plugin/type-converters.js +53 -43
- package/lib/plugin/type-converters.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +50 -1
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +80 -10
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +25 -25
- package/src/common/collections.ts +37 -0
- package/src/common/plugin-api-rpc-model.ts +2 -0
- package/src/common/plugin-api-rpc.ts +134 -10
- package/src/common/rpc-protocol.ts +2 -3
- package/src/common/types.ts +15 -4
- package/src/hosted/node/hosted-plugin-localization-service.ts +3 -3
- package/src/hosted/node/plugin-host.ts +1 -2
- package/src/main/browser/comments/comment-thread-widget.tsx +11 -0
- package/src/main/browser/style/comments.css +6 -0
- package/src/main/browser/tabs/tabs-main.ts +42 -0
- package/src/main/browser/terminal-main.ts +23 -4
- package/src/main/browser/view/tree-view-decorator-service.ts +4 -5
- package/src/plugin/comments.ts +2 -0
- package/src/plugin/languages/code-action.ts +8 -8
- package/src/plugin/plugin-context.ts +28 -5
- package/src/plugin/preference-registry.ts +4 -2
- package/src/plugin/tabs.ts +430 -0
- package/src/plugin/terminal-ext.ts +16 -1
- package/src/plugin/type-converters.ts +58 -46
- package/src/plugin/types-impl.ts +53 -8
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as theia from '@theia/plugin';
|
|
18
|
+
import { Emitter } from '@theia/core';
|
|
19
|
+
import { RPCProtocol } from '../common/rpc-protocol';
|
|
20
|
+
import { PLUGIN_RPC_CONTEXT, TabDto, TabGroupDto, TabInputKind, TabModelOperationKind, TabOperation, TabsExt, TabsMain } from '../common/plugin-api-rpc';
|
|
21
|
+
import {
|
|
22
|
+
CustomEditorTabInput,
|
|
23
|
+
InteractiveWindowInput,
|
|
24
|
+
NotebookDiffEditorTabInput,
|
|
25
|
+
NotebookEditorTabInput,
|
|
26
|
+
TerminalEditorTabInput,
|
|
27
|
+
TextDiffTabInput,
|
|
28
|
+
TextMergeTabInput,
|
|
29
|
+
TextTabInput,
|
|
30
|
+
URI,
|
|
31
|
+
WebviewEditorTabInput
|
|
32
|
+
} from './types-impl';
|
|
33
|
+
import { assertIsDefined } from '../common/types';
|
|
34
|
+
import { diffSets } from '../common/collections';
|
|
35
|
+
import { ViewColumn } from './type-converters';
|
|
36
|
+
|
|
37
|
+
/*---------------------------------------------------------------------------------------------
|
|
38
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
39
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
40
|
+
*--------------------------------------------------------------------------------------------*/
|
|
41
|
+
// some code copied and modified from https://github.com/microsoft/vscode/blob/1.71.2/src/vs/workbench/api/common/extHostEditorTabs.ts
|
|
42
|
+
|
|
43
|
+
type AnyTabInput =
|
|
44
|
+
TextTabInput |
|
|
45
|
+
TextDiffTabInput |
|
|
46
|
+
CustomEditorTabInput |
|
|
47
|
+
NotebookEditorTabInput |
|
|
48
|
+
NotebookDiffEditorTabInput |
|
|
49
|
+
WebviewEditorTabInput |
|
|
50
|
+
TerminalEditorTabInput |
|
|
51
|
+
InteractiveWindowInput;
|
|
52
|
+
|
|
53
|
+
class TabExt {
|
|
54
|
+
private tabApiObject: theia.Tab | undefined;
|
|
55
|
+
private tabDto!: TabDto;
|
|
56
|
+
private input: AnyTabInput | undefined;
|
|
57
|
+
private parentGroup: TabGroupExt;
|
|
58
|
+
private readonly activeTabIdGetter: () => string;
|
|
59
|
+
|
|
60
|
+
constructor(dto: TabDto, parentGroup: TabGroupExt, activeTabIdGetter: () => string) {
|
|
61
|
+
this.activeTabIdGetter = activeTabIdGetter;
|
|
62
|
+
this.parentGroup = parentGroup;
|
|
63
|
+
this.acceptDtoUpdate(dto);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get apiObject(): theia.Tab {
|
|
67
|
+
if (!this.tabApiObject) {
|
|
68
|
+
// Don't want to lose reference to parent `this` in the getters
|
|
69
|
+
const that = this;
|
|
70
|
+
const obj: theia.Tab = {
|
|
71
|
+
get isActive(): boolean {
|
|
72
|
+
// We use a getter function here to always ensure at most 1 active tab per group and prevent iteration for being required
|
|
73
|
+
return that.tabDto.id === that.activeTabIdGetter();
|
|
74
|
+
},
|
|
75
|
+
get label(): string {
|
|
76
|
+
return that.tabDto.label;
|
|
77
|
+
},
|
|
78
|
+
get input(): AnyTabInput | undefined {
|
|
79
|
+
return that.input;
|
|
80
|
+
},
|
|
81
|
+
get isDirty(): boolean {
|
|
82
|
+
return that.tabDto.isDirty;
|
|
83
|
+
},
|
|
84
|
+
get isPinned(): boolean {
|
|
85
|
+
return that.tabDto.isPinned;
|
|
86
|
+
},
|
|
87
|
+
get isPreview(): boolean {
|
|
88
|
+
return that.tabDto.isPreview;
|
|
89
|
+
},
|
|
90
|
+
get group(): theia.TabGroup {
|
|
91
|
+
return that.parentGroup.apiObject;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
this.tabApiObject = Object.freeze<theia.Tab>(obj);
|
|
95
|
+
}
|
|
96
|
+
return this.tabApiObject;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get tabId(): string {
|
|
100
|
+
return this.tabDto.id;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
acceptDtoUpdate(tabDto: TabDto): void {
|
|
104
|
+
this.tabDto = tabDto;
|
|
105
|
+
this.input = this.initInput();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private initInput(): AnyTabInput | undefined {
|
|
109
|
+
switch (this.tabDto.input.kind) {
|
|
110
|
+
case TabInputKind.TextInput:
|
|
111
|
+
return new TextTabInput(URI.revive(this.tabDto.input.uri));
|
|
112
|
+
case TabInputKind.TextDiffInput:
|
|
113
|
+
return new TextDiffTabInput(URI.revive(this.tabDto.input.original), URI.revive(this.tabDto.input.modified));
|
|
114
|
+
case TabInputKind.TextMergeInput:
|
|
115
|
+
return new TextMergeTabInput(
|
|
116
|
+
URI.revive(this.tabDto.input.base),
|
|
117
|
+
URI.revive(this.tabDto.input.input1),
|
|
118
|
+
URI.revive(this.tabDto.input.input2),
|
|
119
|
+
URI.revive(this.tabDto.input.result));
|
|
120
|
+
case TabInputKind.CustomEditorInput:
|
|
121
|
+
return new CustomEditorTabInput(URI.revive(this.tabDto.input.uri), this.tabDto.input.viewType);
|
|
122
|
+
case TabInputKind.WebviewEditorInput:
|
|
123
|
+
return new WebviewEditorTabInput(this.tabDto.input.viewType);
|
|
124
|
+
case TabInputKind.NotebookInput:
|
|
125
|
+
return new NotebookEditorTabInput(URI.revive(this.tabDto.input.uri), this.tabDto.input.notebookType);
|
|
126
|
+
case TabInputKind.NotebookDiffInput:
|
|
127
|
+
return new NotebookDiffEditorTabInput(URI.revive(this.tabDto.input.original), URI.revive(this.tabDto.input.modified), this.tabDto.input.notebookType);
|
|
128
|
+
case TabInputKind.TerminalEditorInput:
|
|
129
|
+
return new TerminalEditorTabInput();
|
|
130
|
+
case TabInputKind.InteractiveEditorInput:
|
|
131
|
+
return new InteractiveWindowInput(URI.revive(this.tabDto.input.uri), URI.revive(this.tabDto.input.inputBoxUri));
|
|
132
|
+
default:
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
class TabGroupExt {
|
|
139
|
+
|
|
140
|
+
private tabGroupApiObject: theia.TabGroup | undefined;
|
|
141
|
+
private tabGroupDto: TabGroupDto;
|
|
142
|
+
private tabsArr: TabExt[] = [];
|
|
143
|
+
private activeTabId: string = '';
|
|
144
|
+
private activeGroupIdGetter: () => number | undefined;
|
|
145
|
+
|
|
146
|
+
constructor(dto: TabGroupDto, activeGroupIdGetter: () => number | undefined) {
|
|
147
|
+
this.tabGroupDto = dto;
|
|
148
|
+
this.activeGroupIdGetter = activeGroupIdGetter;
|
|
149
|
+
// Construct all tabs from the given dto
|
|
150
|
+
for (const tabDto of dto.tabs) {
|
|
151
|
+
if (tabDto.isActive) {
|
|
152
|
+
this.activeTabId = tabDto.id;
|
|
153
|
+
}
|
|
154
|
+
this.tabsArr.push(new TabExt(tabDto, this, () => this.getActiveTabId()));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
get apiObject(): theia.TabGroup {
|
|
159
|
+
if (!this.tabGroupApiObject) {
|
|
160
|
+
// Don't want to lose reference to parent `this` in the getters
|
|
161
|
+
const that = this;
|
|
162
|
+
const obj: theia.TabGroup = {
|
|
163
|
+
get isActive(): boolean {
|
|
164
|
+
// We use a getter function here to always ensure at most 1 active group and prevent iteration for being required
|
|
165
|
+
return that.tabGroupDto.groupId === that.activeGroupIdGetter();
|
|
166
|
+
},
|
|
167
|
+
get viewColumn(): theia.ViewColumn {
|
|
168
|
+
return ViewColumn.to(that.tabGroupDto.viewColumn);
|
|
169
|
+
},
|
|
170
|
+
get activeTab(): theia.Tab | undefined {
|
|
171
|
+
return that.tabsArr.find(tab => tab.tabId === that.activeTabId)?.apiObject;
|
|
172
|
+
},
|
|
173
|
+
get tabs(): Readonly<theia.Tab[]> {
|
|
174
|
+
return Object.freeze(that.tabsArr.map(tab => tab.apiObject));
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
this.tabGroupApiObject = Object.freeze<theia.TabGroup>(obj);
|
|
178
|
+
}
|
|
179
|
+
return this.tabGroupApiObject;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
get groupId(): number {
|
|
183
|
+
return this.tabGroupDto.groupId;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
get tabs(): TabExt[] {
|
|
187
|
+
return this.tabsArr;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
acceptGroupDtoUpdate(dto: TabGroupDto): void {
|
|
191
|
+
this.tabGroupDto = dto;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
acceptTabOperation(operation: TabOperation): TabExt {
|
|
195
|
+
// In the open case we add the tab to the group
|
|
196
|
+
if (operation.kind === TabModelOperationKind.TAB_OPEN) {
|
|
197
|
+
const tab = new TabExt(operation.tabDto, this, () => this.getActiveTabId());
|
|
198
|
+
// Insert tab at editor index
|
|
199
|
+
this.tabsArr.splice(operation.index, 0, tab);
|
|
200
|
+
if (operation.tabDto.isActive) {
|
|
201
|
+
this.activeTabId = tab.tabId;
|
|
202
|
+
}
|
|
203
|
+
return tab;
|
|
204
|
+
} else if (operation.kind === TabModelOperationKind.TAB_CLOSE) {
|
|
205
|
+
const tab = this.tabsArr.splice(operation.index, 1)[0];
|
|
206
|
+
if (!tab) {
|
|
207
|
+
throw new Error(`Tab close updated received for index ${operation.index} which does not exist`);
|
|
208
|
+
}
|
|
209
|
+
if (tab.tabId === this.activeTabId) {
|
|
210
|
+
this.activeTabId = '';
|
|
211
|
+
}
|
|
212
|
+
return tab;
|
|
213
|
+
} else if (operation.kind === TabModelOperationKind.TAB_MOVE) {
|
|
214
|
+
if (operation.oldIndex === undefined) {
|
|
215
|
+
throw new Error('Invalid old index on move IPC');
|
|
216
|
+
}
|
|
217
|
+
// Splice to remove at old index and insert at new index === moving the tab
|
|
218
|
+
const tab = this.tabsArr.splice(operation.oldIndex, 1)[0];
|
|
219
|
+
if (!tab) {
|
|
220
|
+
throw new Error(`Tab move updated received for index ${operation.oldIndex} which does not exist`);
|
|
221
|
+
}
|
|
222
|
+
this.tabsArr.splice(operation.index, 0, tab);
|
|
223
|
+
return tab;
|
|
224
|
+
}
|
|
225
|
+
const _tab = this.tabsArr.find(extHostTab => extHostTab.tabId === operation.tabDto.id);
|
|
226
|
+
if (!_tab) {
|
|
227
|
+
throw new Error('INVALID tab');
|
|
228
|
+
}
|
|
229
|
+
if (operation.tabDto.isActive) {
|
|
230
|
+
this.activeTabId = operation.tabDto.id;
|
|
231
|
+
} else if (this.activeTabId === operation.tabDto.id && !operation.tabDto.isActive) {
|
|
232
|
+
// Events aren't guaranteed to be in order so if we receive a dto that matches the active tab id
|
|
233
|
+
// but isn't active we mark the active tab id as empty. This prevent onDidActiveTabChange from
|
|
234
|
+
// firing incorrectly
|
|
235
|
+
this.activeTabId = '';
|
|
236
|
+
}
|
|
237
|
+
_tab.acceptDtoUpdate(operation.tabDto);
|
|
238
|
+
return _tab;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Not a getter since it must be a function to be used as a callback for the tabs
|
|
242
|
+
getActiveTabId(): string {
|
|
243
|
+
return this.activeTabId;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export class TabsExtImpl implements TabsExt {
|
|
248
|
+
declare readonly _serviceBrand: undefined;
|
|
249
|
+
|
|
250
|
+
private readonly proxy: TabsMain;
|
|
251
|
+
private readonly onDidChangeTabs = new Emitter<theia.TabChangeEvent>();
|
|
252
|
+
private readonly onDidChangeTabGroups = new Emitter<theia.TabGroupChangeEvent>();
|
|
253
|
+
|
|
254
|
+
// Have to use ! because this gets initialized via an RPC proxy
|
|
255
|
+
private activeGroupId!: number;
|
|
256
|
+
|
|
257
|
+
private tabGroupArr: TabGroupExt[] = [];
|
|
258
|
+
|
|
259
|
+
private apiObject: theia.TabGroups | undefined;
|
|
260
|
+
|
|
261
|
+
constructor(readonly rpc: RPCProtocol) {
|
|
262
|
+
this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.TABS_MAIN);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
get tabGroups(): theia.TabGroups {
|
|
266
|
+
if (!this.apiObject) {
|
|
267
|
+
const that = this;
|
|
268
|
+
const obj: theia.TabGroups = {
|
|
269
|
+
// never changes -> simple value
|
|
270
|
+
onDidChangeTabGroups: that.onDidChangeTabGroups.event,
|
|
271
|
+
onDidChangeTabs: that.onDidChangeTabs.event,
|
|
272
|
+
// dynamic -> getters
|
|
273
|
+
get all(): Readonly<theia.TabGroup[]> {
|
|
274
|
+
return Object.freeze(that.tabGroupArr.map(group => group.apiObject));
|
|
275
|
+
},
|
|
276
|
+
get activeTabGroup(): theia.TabGroup {
|
|
277
|
+
const activeTabGroupId = that.activeGroupId;
|
|
278
|
+
const activeTabGroup = assertIsDefined(that.tabGroupArr.find(candidate => candidate.groupId === activeTabGroupId)?.apiObject);
|
|
279
|
+
return activeTabGroup;
|
|
280
|
+
},
|
|
281
|
+
close: async (tabOrTabGroup: theia.Tab | readonly theia.Tab[] | theia.TabGroup | readonly theia.TabGroup[], preserveFocus?: boolean) => {
|
|
282
|
+
const tabsOrTabGroups = Array.isArray(tabOrTabGroup) ? tabOrTabGroup : [tabOrTabGroup];
|
|
283
|
+
if (!tabsOrTabGroups.length) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
// Check which type was passed in and call the appropriate close
|
|
287
|
+
// Casting is needed as typescript doesn't seem to infer enough from this
|
|
288
|
+
if (isTabGroup(tabsOrTabGroups[0])) {
|
|
289
|
+
return this._closeGroups(tabsOrTabGroups as theia.TabGroup[], preserveFocus);
|
|
290
|
+
} else {
|
|
291
|
+
return this._closeTabs(tabsOrTabGroups as theia.Tab[], preserveFocus);
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
// move: async (tab: theia.Tab, viewColumn: ViewColumn, index: number, preserveFocus?: boolean) => {
|
|
295
|
+
// const extHostTab = this._findExtHostTabFromApi(tab);
|
|
296
|
+
// if (!extHostTab) {
|
|
297
|
+
// throw new Error('Invalid tab');
|
|
298
|
+
// }
|
|
299
|
+
// this._proxy.$moveTab(extHostTab.tabId, index, typeConverters.ViewColumn.from(viewColumn), preserveFocus);
|
|
300
|
+
// return;
|
|
301
|
+
// }
|
|
302
|
+
};
|
|
303
|
+
this.apiObject = Object.freeze(obj);
|
|
304
|
+
}
|
|
305
|
+
return this.apiObject;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
$acceptEditorTabModel(tabGroups: TabGroupDto[]): void {
|
|
309
|
+
|
|
310
|
+
const groupIdsBefore = new Set(this.tabGroupArr.map(group => group.groupId));
|
|
311
|
+
const groupIdsAfter = new Set(tabGroups.map(dto => dto.groupId));
|
|
312
|
+
const diff = diffSets(groupIdsBefore, groupIdsAfter);
|
|
313
|
+
|
|
314
|
+
const closed: theia.TabGroup[] = this.tabGroupArr.filter(group => diff.removed.includes(group.groupId)).map(group => group.apiObject);
|
|
315
|
+
const opened: theia.TabGroup[] = [];
|
|
316
|
+
const changed: theia.TabGroup[] = [];
|
|
317
|
+
|
|
318
|
+
this.tabGroupArr = tabGroups.map(tabGroup => {
|
|
319
|
+
const group = new TabGroupExt(tabGroup, () => this.activeGroupId);
|
|
320
|
+
if (diff.added.includes(group.groupId)) {
|
|
321
|
+
opened.push(group.apiObject);
|
|
322
|
+
} else {
|
|
323
|
+
changed.push(group.apiObject);
|
|
324
|
+
}
|
|
325
|
+
return group;
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Set the active tab group id
|
|
329
|
+
const activeTabGroupId = assertIsDefined(tabGroups.find(group => group.isActive === true)?.groupId);
|
|
330
|
+
if (activeTabGroupId !== undefined && this.activeGroupId !== activeTabGroupId) {
|
|
331
|
+
this.activeGroupId = activeTabGroupId;
|
|
332
|
+
}
|
|
333
|
+
this.onDidChangeTabGroups.fire(Object.freeze({ opened, closed, changed }));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
$acceptTabGroupUpdate(groupDto: TabGroupDto): void {
|
|
337
|
+
const group = this.tabGroupArr.find(tabGroup => tabGroup.groupId === groupDto.groupId);
|
|
338
|
+
if (!group) {
|
|
339
|
+
throw new Error('Update Group IPC call received before group creation.');
|
|
340
|
+
}
|
|
341
|
+
group.acceptGroupDtoUpdate(groupDto);
|
|
342
|
+
if (groupDto.isActive) {
|
|
343
|
+
this.activeGroupId = groupDto.groupId;
|
|
344
|
+
}
|
|
345
|
+
this.onDidChangeTabGroups.fire(Object.freeze({ changed: [group.apiObject], opened: [], closed: [] }));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
$acceptTabOperation(operation: TabOperation): void {
|
|
349
|
+
const group = this.tabGroupArr.find(tabGroup => tabGroup.groupId === operation.groupId);
|
|
350
|
+
if (!group) {
|
|
351
|
+
throw new Error('Update Tabs IPC call received before group creation.');
|
|
352
|
+
}
|
|
353
|
+
const tab = group.acceptTabOperation(operation);
|
|
354
|
+
|
|
355
|
+
// Construct the tab change event based on the operation
|
|
356
|
+
switch (operation.kind) {
|
|
357
|
+
case TabModelOperationKind.TAB_OPEN:
|
|
358
|
+
this.onDidChangeTabs.fire(Object.freeze({
|
|
359
|
+
opened: [tab.apiObject],
|
|
360
|
+
closed: [],
|
|
361
|
+
changed: []
|
|
362
|
+
}));
|
|
363
|
+
return;
|
|
364
|
+
case TabModelOperationKind.TAB_CLOSE:
|
|
365
|
+
this.onDidChangeTabs.fire(Object.freeze({
|
|
366
|
+
opened: [],
|
|
367
|
+
closed: [tab.apiObject],
|
|
368
|
+
changed: []
|
|
369
|
+
}));
|
|
370
|
+
return;
|
|
371
|
+
case TabModelOperationKind.TAB_MOVE:
|
|
372
|
+
case TabModelOperationKind.TAB_UPDATE:
|
|
373
|
+
this.onDidChangeTabs.fire(Object.freeze({
|
|
374
|
+
opened: [],
|
|
375
|
+
closed: [],
|
|
376
|
+
changed: [tab.apiObject]
|
|
377
|
+
}));
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private _findExtHostTabFromApi(apiTab: theia.Tab): TabExt | undefined {
|
|
383
|
+
for (const group of this.tabGroupArr) {
|
|
384
|
+
for (const tab of group.tabs) {
|
|
385
|
+
if (tab.apiObject === apiTab) {
|
|
386
|
+
return tab;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
private _findExtHostTabGroupFromApi(apiTabGroup: theia.TabGroup): TabGroupExt | undefined {
|
|
394
|
+
return this.tabGroupArr.find(candidate => candidate.apiObject === apiTabGroup);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
private async _closeTabs(tabs: theia.Tab[], preserveFocus?: boolean): Promise<boolean> {
|
|
398
|
+
const extHostTabIds: string[] = [];
|
|
399
|
+
for (const tab of tabs) {
|
|
400
|
+
const extHostTab = this._findExtHostTabFromApi(tab);
|
|
401
|
+
if (!extHostTab) {
|
|
402
|
+
throw new Error('Tab close: Invalid tab not found!');
|
|
403
|
+
}
|
|
404
|
+
extHostTabIds.push(extHostTab.tabId);
|
|
405
|
+
}
|
|
406
|
+
return this.proxy.$closeTab(extHostTabIds, preserveFocus);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
private async _closeGroups(groups: theia.TabGroup[], preserverFoucs?: boolean): Promise<boolean> {
|
|
410
|
+
const extHostGroupIds: number[] = [];
|
|
411
|
+
for (const group of groups) {
|
|
412
|
+
const extHostGroup = this._findExtHostTabGroupFromApi(group);
|
|
413
|
+
if (!extHostGroup) {
|
|
414
|
+
throw new Error('Group close: Invalid group not found!');
|
|
415
|
+
}
|
|
416
|
+
extHostGroupIds.push(extHostGroup.groupId);
|
|
417
|
+
}
|
|
418
|
+
return this.proxy.$closeGroup(extHostGroupIds, preserverFoucs);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// #region Utils
|
|
423
|
+
function isTabGroup(obj: unknown): obj is theia.TabGroup {
|
|
424
|
+
const tabGroup = obj as theia.TabGroup;
|
|
425
|
+
if (tabGroup.tabs !== undefined) {
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
// #endregion
|
|
@@ -85,7 +85,22 @@ export class TerminalServiceExtImpl implements TerminalServiceExt {
|
|
|
85
85
|
shellArgs: shellArgs
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
|
|
89
|
+
let parentId;
|
|
90
|
+
|
|
91
|
+
if (options.location && typeof options.location === 'object' && 'parentTerminal' in options.location) {
|
|
92
|
+
const parentTerminal = options.location.parentTerminal;
|
|
93
|
+
if (parentTerminal instanceof TerminalExtImpl) {
|
|
94
|
+
for (const [k, v] of this._terminals) {
|
|
95
|
+
if (v === parentTerminal) {
|
|
96
|
+
parentId = k;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.proxy.$createTerminal(id, options, parentId, !!pseudoTerminal);
|
|
89
104
|
|
|
90
105
|
let creationOptions: theia.TerminalOptions | theia.ExtensionTerminalOptions = options;
|
|
91
106
|
// make sure to pass ExtensionTerminalOptions as creation options
|
|
@@ -28,6 +28,7 @@ import * as types from './types-impl';
|
|
|
28
28
|
import { UriComponents } from '../common/uri-components';
|
|
29
29
|
import { isReadonlyArray } from '../common/arrays';
|
|
30
30
|
import { MarkdownString as MarkdownStringDTO } from '@theia/core/lib/common/markdown-rendering';
|
|
31
|
+
import { isObject } from '@theia/core/lib/common';
|
|
31
32
|
|
|
32
33
|
const SIDE_GROUP = -2;
|
|
33
34
|
const ACTIVE_GROUP = -1;
|
|
@@ -136,7 +137,7 @@ export function toPosition(position: Position): types.Position {
|
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
function isDecorationOptions(arg: unknown): arg is theia.DecorationOptions {
|
|
139
|
-
return
|
|
140
|
+
return isObject<theia.DecorationOptions>(arg) && typeof arg.range !== 'undefined';
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
export function isDecorationOptionsArr(something: theia.Range[] | theia.DecorationOptions[]): something is theia.DecorationOptions[] {
|
|
@@ -180,9 +181,9 @@ interface Codeblock {
|
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
function isCodeblock(arg: unknown): arg is Codeblock {
|
|
183
|
-
return
|
|
184
|
-
&& typeof
|
|
185
|
-
&& typeof
|
|
184
|
+
return isObject<Codeblock>(arg)
|
|
185
|
+
&& typeof arg.language === 'string'
|
|
186
|
+
&& typeof arg.value === 'string';
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
export function fromMarkdown(markup: theia.MarkdownString | theia.MarkedString): MarkdownStringDTO {
|
|
@@ -677,57 +678,47 @@ export function toSymbolTag(kind: model.SymbolTag): types.SymbolTag {
|
|
|
677
678
|
}
|
|
678
679
|
|
|
679
680
|
export function isModelLocation(arg: unknown): arg is model.Location {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
return !!arg &&
|
|
684
|
-
typeof arg === 'object' &&
|
|
685
|
-
isModelRange((arg as model.Location).range) &&
|
|
686
|
-
isUriComponents((arg as model.Location).uri);
|
|
681
|
+
return isObject<model.Location>(arg) &&
|
|
682
|
+
isModelRange(arg.range) &&
|
|
683
|
+
isUriComponents(arg.uri);
|
|
687
684
|
}
|
|
688
685
|
|
|
689
686
|
export function isModelRange(arg: unknown): arg is model.Range {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
typeof
|
|
693
|
-
typeof
|
|
694
|
-
typeof
|
|
695
|
-
typeof range.endColumn === 'number';
|
|
687
|
+
return isObject<model.Range>(arg) &&
|
|
688
|
+
typeof arg.startLineNumber === 'number' &&
|
|
689
|
+
typeof arg.startColumn === 'number' &&
|
|
690
|
+
typeof arg.endLineNumber === 'number' &&
|
|
691
|
+
typeof arg.endColumn === 'number';
|
|
696
692
|
}
|
|
697
693
|
|
|
698
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
699
694
|
export function isUriComponents(arg: unknown): arg is UriComponents {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
typeof
|
|
703
|
-
typeof
|
|
704
|
-
typeof
|
|
705
|
-
typeof uriComponents.fragment === 'string';
|
|
695
|
+
return isObject<UriComponents>(arg) &&
|
|
696
|
+
typeof arg.scheme === 'string' &&
|
|
697
|
+
typeof arg.path === 'string' &&
|
|
698
|
+
typeof arg.query === 'string' &&
|
|
699
|
+
typeof arg.fragment === 'string';
|
|
706
700
|
}
|
|
707
701
|
|
|
708
702
|
export function isModelCallHierarchyItem(arg: unknown): arg is model.CallHierarchyItem {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
&& isModelRange(
|
|
712
|
-
&&
|
|
713
|
-
&&
|
|
714
|
-
&& !!item.name;
|
|
703
|
+
return isObject<model.CallHierarchyItem>(arg)
|
|
704
|
+
&& isModelRange(arg.range)
|
|
705
|
+
&& isModelRange(arg.selectionRange)
|
|
706
|
+
&& isUriComponents(arg.uri)
|
|
707
|
+
&& !!arg.name;
|
|
715
708
|
}
|
|
716
709
|
|
|
717
710
|
export function isModelCallHierarchyIncomingCall(arg: unknown): arg is model.CallHierarchyIncomingCall {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
'
|
|
721
|
-
|
|
722
|
-
isModelCallHierarchyItem(maybeIncomingCall.from);
|
|
711
|
+
return isObject<model.CallHierarchyIncomingCall>(arg) &&
|
|
712
|
+
'from' in arg &&
|
|
713
|
+
'fromRanges' in arg &&
|
|
714
|
+
isModelCallHierarchyItem(arg.from);
|
|
723
715
|
}
|
|
724
716
|
|
|
725
717
|
export function isModelCallHierarchyOutgoingCall(arg: unknown): arg is model.CallHierarchyOutgoingCall {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
'
|
|
729
|
-
|
|
730
|
-
isModelCallHierarchyItem(maybeOutgoingCall.to);
|
|
718
|
+
return isObject<model.CallHierarchyOutgoingCall>(arg) &&
|
|
719
|
+
'to' in arg &&
|
|
720
|
+
'fromRanges' in arg &&
|
|
721
|
+
isModelCallHierarchyItem(arg.to);
|
|
731
722
|
}
|
|
732
723
|
|
|
733
724
|
export function toLocation(value: model.Location): types.Location {
|
|
@@ -781,12 +772,11 @@ export function toCallHierarchyOutgoingCall(value: model.CallHierarchyOutgoingCa
|
|
|
781
772
|
}
|
|
782
773
|
|
|
783
774
|
export function isModelTypeHierarchyItem(arg: unknown): arg is model.TypeHierarchyItem {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
&& isModelRange(
|
|
787
|
-
&&
|
|
788
|
-
&&
|
|
789
|
-
&& !!item.name;
|
|
775
|
+
return isObject<model.TypeHierarchyItem>(arg)
|
|
776
|
+
&& isModelRange(arg.range)
|
|
777
|
+
&& isModelRange(arg.selectionRange)
|
|
778
|
+
&& isUriComponents(arg.uri)
|
|
779
|
+
&& !!arg.name;
|
|
790
780
|
}
|
|
791
781
|
|
|
792
782
|
export function fromTypeHierarchyItem(item: types.TypeHierarchyItem): model.TypeHierarchyItem {
|
|
@@ -1298,6 +1288,28 @@ export namespace ThemableDecorationAttachmentRenderOptions {
|
|
|
1298
1288
|
}
|
|
1299
1289
|
}
|
|
1300
1290
|
|
|
1291
|
+
export namespace ViewColumn {
|
|
1292
|
+
export function from(column?: theia.ViewColumn): rpc.EditorGroupColumn {
|
|
1293
|
+
if (typeof column === 'number' && column >= types.ViewColumn.One) {
|
|
1294
|
+
return column - 1; // adjust zero index (ViewColumn.ONE => 0)
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
if (column === types.ViewColumn.Beside) {
|
|
1298
|
+
return SIDE_GROUP;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
return ACTIVE_GROUP; // default is always the active group
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
export function to(position: rpc.EditorGroupColumn): theia.ViewColumn {
|
|
1305
|
+
if (typeof position === 'number' && position >= 0) {
|
|
1306
|
+
return position + 1; // adjust to index (ViewColumn.ONE => 1)
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
throw new Error('invalid \'EditorGroupColumn\'');
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1301
1313
|
export function pathOrURIToURI(value: string | URI): URI {
|
|
1302
1314
|
if (typeof value === 'undefined') {
|
|
1303
1315
|
return value;
|