@opensumi/ide-editor 2.27.3-rc-1712113547.0 → 2.27.3-rc-1712755288.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/editor-collection.service.js +4 -4
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/merge-editor/merge-editor.provider.d.ts.map +1 -1
- package/lib/browser/merge-editor/merge-editor.provider.js.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.d.ts +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.js +8 -18
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.js.map +1 -1
- package/lib/browser/preference/converter.d.ts.map +1 -1
- package/lib/browser/preference/converter.js +21 -9
- package/lib/browser/preference/converter.js.map +1 -1
- package/lib/browser/preference/schema.d.ts +2 -1
- package/lib/browser/preference/schema.d.ts.map +1 -1
- package/lib/browser/preference/schema.js +5 -2
- package/lib/browser/preference/schema.js.map +1 -1
- package/lib/browser/types.d.ts +4 -0
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts +17 -3
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +80 -7
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/editor.d.ts +8 -2
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js +3 -1
- package/lib/common/editor.js.map +1 -1
- package/package.json +14 -14
- package/src/browser/editor-collection.service.ts +5 -5
- package/src/browser/merge-editor/merge-editor.provider.ts +0 -1
- package/src/browser/monaco-contrib/tokenizer/textmate.service.ts +6 -16
- package/src/browser/preference/converter.ts +19 -9
- package/src/browser/preference/schema.ts +6 -2
- package/src/browser/types.ts +5 -0
- package/src/browser/workbench-editor.service.ts +89 -8
- package/src/common/editor.ts +8 -3
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
localize,
|
|
8
8
|
} from '@opensumi/ide-core-browser';
|
|
9
9
|
|
|
10
|
+
import { ShowLightbulbIconMode } from '../types';
|
|
11
|
+
|
|
10
12
|
export const USUAL_WORD_SEPARATORS = '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?';
|
|
11
13
|
|
|
12
14
|
const DEFAULT_WINDOWS_FONT_FAMILY = "Consolas, 'Courier New', monospace";
|
|
@@ -233,7 +235,7 @@ export const EDITOR_DEFAULTS = {
|
|
|
233
235
|
addExtraSpaceOnTop: true,
|
|
234
236
|
},
|
|
235
237
|
colorDecorators: true,
|
|
236
|
-
lightbulbEnabled:
|
|
238
|
+
lightbulbEnabled: ShowLightbulbIconMode.On,
|
|
237
239
|
codeActionsOnSave: {},
|
|
238
240
|
codeActionsOnSaveTimeout: 750,
|
|
239
241
|
},
|
|
@@ -1382,8 +1384,10 @@ const monacoEditorSchema: PreferenceSchemaProperties = {
|
|
|
1382
1384
|
description: '%editor.configuration.colorDecorators%',
|
|
1383
1385
|
},
|
|
1384
1386
|
'editor.lightbulb.enabled': {
|
|
1385
|
-
type: '
|
|
1387
|
+
type: 'string',
|
|
1386
1388
|
default: EDITOR_DEFAULTS.contribInfo.lightbulbEnabled,
|
|
1389
|
+
enum: [ShowLightbulbIconMode.Off, ShowLightbulbIconMode.OnCode, ShowLightbulbIconMode.On],
|
|
1390
|
+
enumDescriptions: [],
|
|
1387
1391
|
description: '%editor.configuration.lightbulb.enabled%',
|
|
1388
1392
|
},
|
|
1389
1393
|
'editor.maxTokenizationLineLength': {
|
package/src/browser/types.ts
CHANGED
|
@@ -48,6 +48,11 @@ export interface IEditorComponent<MetaData = any> {
|
|
|
48
48
|
|
|
49
49
|
// 渲染模式 默认为 ONE_PER_GROUP
|
|
50
50
|
renderMode?: EditorComponentRenderMode;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 有关该 component 的额外信息
|
|
54
|
+
*/
|
|
55
|
+
metadata?: Record<string, any>;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
export type EditorSide = 'bottom' | 'top';
|
|
@@ -250,8 +250,10 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
|
|
|
250
250
|
return this.editorGroups.reduce((pre, cur) => pre + cur.calcDirtyCount(countedUris), 0);
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
private editorGroupIdGen = 0;
|
|
254
|
+
|
|
253
255
|
createEditorGroup(): EditorGroup {
|
|
254
|
-
const editorGroup = this.injector.get(EditorGroup, [this.generateRandomEditorGroupName()]);
|
|
256
|
+
const editorGroup = this.injector.get(EditorGroup, [this.generateRandomEditorGroupName(), this.editorGroupIdGen++]);
|
|
255
257
|
this.editorGroups.push(editorGroup);
|
|
256
258
|
const currentWatchDisposer = new Disposable(
|
|
257
259
|
editorGroup.onDidEditorGroupBodyChanged(() => {
|
|
@@ -661,6 +663,12 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
661
663
|
_onDidEditorGroupTabChanged = new EventEmitter<void>();
|
|
662
664
|
onDidEditorGroupTabChanged: Event<void> = this._onDidEditorGroupTabChanged.event;
|
|
663
665
|
|
|
666
|
+
/**
|
|
667
|
+
* 当编辑器的tab部分发生变更
|
|
668
|
+
*/
|
|
669
|
+
_onDidEditorGroupTabOperation = new EventEmitter<IResourceTabOperation>();
|
|
670
|
+
onDidEditorGroupTabOperation: Event<IResourceTabOperation> = this._onDidEditorGroupTabOperation.event;
|
|
671
|
+
|
|
664
672
|
/**
|
|
665
673
|
* 当编辑器的主体部分发生变更
|
|
666
674
|
*/
|
|
@@ -758,7 +766,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
758
766
|
|
|
759
767
|
private _currentOrPreviousFocusedEditor: IEditor | null;
|
|
760
768
|
|
|
761
|
-
constructor(public readonly name: string) {
|
|
769
|
+
constructor(public readonly name: string, public readonly groupId: number) {
|
|
762
770
|
super();
|
|
763
771
|
this.eventBus.on(ResizeEvent, (e: ResizeEvent) => {
|
|
764
772
|
if (e.payload.slotLocation === getSlotLocation('@opensumi/ide-editor', this.config.layoutConfig)) {
|
|
@@ -1351,6 +1359,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1351
1359
|
} else {
|
|
1352
1360
|
const oldOpenType = this._currentOpenType;
|
|
1353
1361
|
const oldResource = this._currentResource;
|
|
1362
|
+
let tabOperationToFire: IResourceTabOperation | null = null;
|
|
1354
1363
|
let resource: IResource | null | undefined = this.resources.find((r) => r.uri.toString() === uri.toString());
|
|
1355
1364
|
if (!resource) {
|
|
1356
1365
|
// open new resource
|
|
@@ -1372,13 +1381,28 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1372
1381
|
if (options && options.index !== undefined && options.index < this.resources.length) {
|
|
1373
1382
|
replaceResource = this.resources[options.index];
|
|
1374
1383
|
this.resources.splice(options.index, 0, resource);
|
|
1384
|
+
tabOperationToFire = {
|
|
1385
|
+
type: 'open',
|
|
1386
|
+
resource,
|
|
1387
|
+
index: options.index,
|
|
1388
|
+
};
|
|
1375
1389
|
} else {
|
|
1376
1390
|
if (this.currentResource) {
|
|
1377
1391
|
const currentIndex = this.resources.indexOf(this.currentResource);
|
|
1378
1392
|
this.resources.splice(currentIndex + 1, 0, resource);
|
|
1393
|
+
tabOperationToFire = {
|
|
1394
|
+
type: 'open',
|
|
1395
|
+
resource,
|
|
1396
|
+
index: currentIndex + 1,
|
|
1397
|
+
};
|
|
1379
1398
|
replaceResource = this.currentResource;
|
|
1380
1399
|
} else {
|
|
1381
1400
|
this.resources.push(resource);
|
|
1401
|
+
tabOperationToFire = {
|
|
1402
|
+
type: 'open',
|
|
1403
|
+
resource,
|
|
1404
|
+
index: this.resources.length - 1,
|
|
1405
|
+
};
|
|
1382
1406
|
}
|
|
1383
1407
|
}
|
|
1384
1408
|
if (previewMode) {
|
|
@@ -1418,7 +1442,13 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1418
1442
|
}, 60);
|
|
1419
1443
|
this.notifyTabChanged();
|
|
1420
1444
|
this.notifyBodyChanged();
|
|
1421
|
-
|
|
1445
|
+
try {
|
|
1446
|
+
await this.displayResourceComponent(resource, options);
|
|
1447
|
+
} finally {
|
|
1448
|
+
if (tabOperationToFire) {
|
|
1449
|
+
this._onDidEditorGroupTabOperation.fire(tabOperationToFire);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1422
1452
|
this._currentOrPreviousFocusedEditor = this.currentEditor;
|
|
1423
1453
|
|
|
1424
1454
|
clearTimeout(delayTimer);
|
|
@@ -1765,6 +1795,10 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1765
1795
|
}
|
|
1766
1796
|
}
|
|
1767
1797
|
|
|
1798
|
+
public getLastOpenType(resource: IResource) {
|
|
1799
|
+
return this.cachedResourcesActiveOpenTypes.get(resource.uri.toString());
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1768
1802
|
private async resolveOpenType(
|
|
1769
1803
|
resource: IResource,
|
|
1770
1804
|
options: IResourceOpenOptions,
|
|
@@ -1793,16 +1827,21 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1793
1827
|
treatAsNotCurrent?: boolean;
|
|
1794
1828
|
force?: boolean;
|
|
1795
1829
|
} = {},
|
|
1796
|
-
) {
|
|
1830
|
+
): Promise<boolean> {
|
|
1797
1831
|
const index = this.resources.findIndex((r) => r.uri.toString() === uri.toString());
|
|
1798
1832
|
if (index !== -1) {
|
|
1799
1833
|
const resource = this.resources[index];
|
|
1800
1834
|
if (!force) {
|
|
1801
1835
|
if (!(await this.shouldClose(resource))) {
|
|
1802
|
-
return;
|
|
1836
|
+
return false;
|
|
1803
1837
|
}
|
|
1804
1838
|
}
|
|
1805
1839
|
this.resources.splice(index, 1);
|
|
1840
|
+
this._onDidEditorGroupTabOperation.fire({
|
|
1841
|
+
type: 'close',
|
|
1842
|
+
resource,
|
|
1843
|
+
index,
|
|
1844
|
+
});
|
|
1806
1845
|
this.eventBus.fire(
|
|
1807
1846
|
new EditorGroupCloseEvent({
|
|
1808
1847
|
group: this,
|
|
@@ -1853,6 +1892,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1853
1892
|
}
|
|
1854
1893
|
this.availableOpenTypes = [];
|
|
1855
1894
|
}
|
|
1895
|
+
return true;
|
|
1856
1896
|
}
|
|
1857
1897
|
|
|
1858
1898
|
private removeResouceFromActiveComponents(resource: IResource) {
|
|
@@ -1914,15 +1954,21 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1914
1954
|
/**
|
|
1915
1955
|
* 关闭全部
|
|
1916
1956
|
*/
|
|
1917
|
-
async closeAll() {
|
|
1957
|
+
async closeAll(): Promise<boolean> {
|
|
1918
1958
|
for (const resource of this.resources) {
|
|
1919
1959
|
if (!(await this.shouldClose(resource))) {
|
|
1920
|
-
return;
|
|
1960
|
+
return false;
|
|
1921
1961
|
}
|
|
1922
1962
|
}
|
|
1923
1963
|
const closed = this.resources.splice(0, this.resources.length);
|
|
1924
|
-
|
|
1964
|
+
// reverse, 发送事件需要从后往前
|
|
1965
|
+
closed.reverse().forEach((resource, index) => {
|
|
1925
1966
|
this.clearResourceOnClose(resource);
|
|
1967
|
+
this._onDidEditorGroupTabOperation.fire({
|
|
1968
|
+
type: 'close',
|
|
1969
|
+
resource,
|
|
1970
|
+
index,
|
|
1971
|
+
});
|
|
1926
1972
|
});
|
|
1927
1973
|
this.activeComponents.clear();
|
|
1928
1974
|
if (this.workbenchEditorService.editorGroups.length > 1) {
|
|
@@ -1930,6 +1976,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1930
1976
|
}
|
|
1931
1977
|
this.previewURI = null;
|
|
1932
1978
|
this.backToEmpty();
|
|
1979
|
+
return true;
|
|
1933
1980
|
}
|
|
1934
1981
|
|
|
1935
1982
|
/**
|
|
@@ -1966,6 +2013,13 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1966
2013
|
}
|
|
1967
2014
|
}
|
|
1968
2015
|
this.resources.splice(index + 1);
|
|
2016
|
+
resourcesToClose.reverse().forEach((resource, i) => {
|
|
2017
|
+
this._onDidEditorGroupTabOperation.fire({
|
|
2018
|
+
type: 'close',
|
|
2019
|
+
resource,
|
|
2020
|
+
index: index + 1 + (resourcesToClose.length - 1 - i),
|
|
2021
|
+
});
|
|
2022
|
+
});
|
|
1969
2023
|
for (const resource of resourcesToClose) {
|
|
1970
2024
|
this.clearResourceOnClose(resource);
|
|
1971
2025
|
}
|
|
@@ -1992,7 +2046,15 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1992
2046
|
return;
|
|
1993
2047
|
}
|
|
1994
2048
|
}
|
|
2049
|
+
const oldResources = this.resources;
|
|
1995
2050
|
this.resources = [this.resources[index]];
|
|
2051
|
+
resourcesToClose.reverse().forEach((resource) => {
|
|
2052
|
+
this._onDidEditorGroupTabOperation.fire({
|
|
2053
|
+
type: 'close',
|
|
2054
|
+
resource,
|
|
2055
|
+
index: oldResources.indexOf(resource),
|
|
2056
|
+
});
|
|
2057
|
+
});
|
|
1996
2058
|
for (const resource of resourcesToClose) {
|
|
1997
2059
|
this.clearResourceOnClose(resource);
|
|
1998
2060
|
}
|
|
@@ -2063,10 +2125,22 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
2063
2125
|
if (sourceIndex > targetIndex) {
|
|
2064
2126
|
this.resources.splice(sourceIndex, 1);
|
|
2065
2127
|
this.resources.splice(targetIndex, 0, sourceResource);
|
|
2128
|
+
this._onDidEditorGroupTabOperation.fire({
|
|
2129
|
+
type: 'move',
|
|
2130
|
+
resource: sourceResource,
|
|
2131
|
+
oldIndex: sourceIndex,
|
|
2132
|
+
index: targetIndex,
|
|
2133
|
+
});
|
|
2066
2134
|
await this.open(uri, { preview: false });
|
|
2067
2135
|
} else if (sourceIndex < targetIndex) {
|
|
2068
2136
|
this.resources.splice(targetIndex + 1, 0, sourceResource);
|
|
2069
2137
|
this.resources.splice(sourceIndex, 1);
|
|
2138
|
+
this._onDidEditorGroupTabOperation.fire({
|
|
2139
|
+
type: 'move',
|
|
2140
|
+
resource: sourceResource,
|
|
2141
|
+
oldIndex: sourceIndex,
|
|
2142
|
+
index: targetIndex,
|
|
2143
|
+
});
|
|
2070
2144
|
await this.open(uri, { preview: false });
|
|
2071
2145
|
}
|
|
2072
2146
|
}
|
|
@@ -2318,3 +2392,10 @@ function findSuitableOpenType(
|
|
|
2318
2392
|
function openTypeSimilar(a: IEditorOpenType, b: IEditorOpenType) {
|
|
2319
2393
|
return a.type === b.type && (a.type !== EditorOpenType.component || a.componentId === b.componentId);
|
|
2320
2394
|
}
|
|
2395
|
+
|
|
2396
|
+
export interface IResourceTabOperation {
|
|
2397
|
+
type: 'open' | 'close' | 'move';
|
|
2398
|
+
resource: IResource;
|
|
2399
|
+
oldIndex?: number;
|
|
2400
|
+
index: number;
|
|
2401
|
+
}
|
package/src/common/editor.ts
CHANGED
|
@@ -27,7 +27,7 @@ import type { EOL, ICodeEditor as IMonacoCodeEditor } from '@opensumi/ide-monaco
|
|
|
27
27
|
import type { IEditorOptions } from '@opensumi/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
|
|
28
28
|
import type { ITextModel, ITextModelUpdateOptions } from '@opensumi/monaco-editor-core/esm/vs/editor/common/model';
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
export { ShowLightbulbIconMode } from '@opensumi/ide-monaco';
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* editorDocumentModel is a wrapped concept for monaco's textModel
|
|
@@ -386,8 +386,9 @@ export interface IEditorGroup {
|
|
|
386
386
|
/**
|
|
387
387
|
* 关闭指定的 uri 的 tab, 如果存在的话
|
|
388
388
|
* @param uri
|
|
389
|
+
* @return 是否成功关闭,不存在的话返回 true
|
|
389
390
|
*/
|
|
390
|
-
close(uri: URI): Promise<
|
|
391
|
+
close(uri: URI): Promise<boolean>;
|
|
391
392
|
|
|
392
393
|
getState(): IEditorGroupState;
|
|
393
394
|
|
|
@@ -395,7 +396,11 @@ export interface IEditorGroup {
|
|
|
395
396
|
|
|
396
397
|
saveAll(): Promise<void>;
|
|
397
398
|
|
|
398
|
-
|
|
399
|
+
/**
|
|
400
|
+
* 关闭指定所有的 tab
|
|
401
|
+
* @return 是否成功关闭
|
|
402
|
+
*/
|
|
403
|
+
closeAll(): Promise<boolean>;
|
|
399
404
|
|
|
400
405
|
/**
|
|
401
406
|
* 保存当前的 tab 的文件 (如果它能被保存的话)
|