@opensumi/ide-editor 2.12.1-next-079c1930
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/README.md +565 -0
- package/lib/browser/breadcrumb/default.d.ts +28 -0
- package/lib/browser/breadcrumb/default.d.ts.map +1 -0
- package/lib/browser/breadcrumb/default.js +283 -0
- package/lib/browser/breadcrumb/default.js.map +1 -0
- package/lib/browser/breadcrumb/document-symbol.d.ts +36 -0
- package/lib/browser/breadcrumb/document-symbol.d.ts.map +1 -0
- package/lib/browser/breadcrumb/document-symbol.js +161 -0
- package/lib/browser/breadcrumb/document-symbol.js.map +1 -0
- package/lib/browser/breadcrumb/index.d.ts +20 -0
- package/lib/browser/breadcrumb/index.d.ts.map +1 -0
- package/lib/browser/breadcrumb/index.js +90 -0
- package/lib/browser/breadcrumb/index.js.map +1 -0
- package/lib/browser/component/scroll/scroll.d.ts +66 -0
- package/lib/browser/component/scroll/scroll.d.ts.map +1 -0
- package/lib/browser/component/scroll/scroll.js +263 -0
- package/lib/browser/component/scroll/scroll.js.map +1 -0
- package/lib/browser/component/scroll/scroll.module.less +83 -0
- package/lib/browser/component.d.ts +23 -0
- package/lib/browser/component.d.ts.map +1 -0
- package/lib/browser/component.js +165 -0
- package/lib/browser/component.js.map +1 -0
- package/lib/browser/decoration-applier.d.ts +25 -0
- package/lib/browser/decoration-applier.d.ts.map +1 -0
- package/lib/browser/decoration-applier.js +224 -0
- package/lib/browser/decoration-applier.js.map +1 -0
- package/lib/browser/diff/compare.d.ts +14 -0
- package/lib/browser/diff/compare.d.ts.map +1 -0
- package/lib/browser/diff/compare.js +94 -0
- package/lib/browser/diff/compare.js.map +1 -0
- package/lib/browser/diff/index.d.ts +19 -0
- package/lib/browser/diff/index.d.ts.map +1 -0
- package/lib/browser/diff/index.js +92 -0
- package/lib/browser/diff/index.js.map +1 -0
- package/lib/browser/doc-cache/empty-doc-cache.d.ts +12 -0
- package/lib/browser/doc-cache/empty-doc-cache.d.ts.map +1 -0
- package/lib/browser/doc-cache/empty-doc-cache.js +27 -0
- package/lib/browser/doc-cache/empty-doc-cache.js.map +1 -0
- package/lib/browser/doc-cache/index.d.ts +3 -0
- package/lib/browser/doc-cache/index.d.ts.map +1 -0
- package/lib/browser/doc-cache/index.js +6 -0
- package/lib/browser/doc-cache/index.js.map +1 -0
- package/lib/browser/doc-cache/local-storage-cache.d.ts +32 -0
- package/lib/browser/doc-cache/local-storage-cache.d.ts.map +1 -0
- package/lib/browser/doc-cache/local-storage-cache.js +69 -0
- package/lib/browser/doc-cache/local-storage-cache.js.map +1 -0
- package/lib/browser/doc-model/editor-document-error.d.ts +7 -0
- package/lib/browser/doc-model/editor-document-error.d.ts.map +1 -0
- package/lib/browser/doc-model/editor-document-error.js +15 -0
- package/lib/browser/doc-model/editor-document-error.js.map +1 -0
- package/lib/browser/doc-model/editor-document-model-service.d.ts +40 -0
- package/lib/browser/doc-model/editor-document-model-service.d.ts.map +1 -0
- package/lib/browser/doc-model/editor-document-model-service.js +276 -0
- package/lib/browser/doc-model/editor-document-model-service.js.map +1 -0
- package/lib/browser/doc-model/editor-document-model.d.ts +85 -0
- package/lib/browser/doc-model/editor-document-model.d.ts.map +1 -0
- package/lib/browser/doc-model/editor-document-model.js +463 -0
- package/lib/browser/doc-model/editor-document-model.js.map +1 -0
- package/lib/browser/doc-model/editor-document-registry.d.ts +15 -0
- package/lib/browser/doc-model/editor-document-registry.d.ts.map +1 -0
- package/lib/browser/doc-model/editor-document-registry.js +110 -0
- package/lib/browser/doc-model/editor-document-registry.js.map +1 -0
- package/lib/browser/doc-model/editor-is-fn.d.ts +4 -0
- package/lib/browser/doc-model/editor-is-fn.d.ts.map +1 -0
- package/lib/browser/doc-model/editor-is-fn.js +12 -0
- package/lib/browser/doc-model/editor-is-fn.js.map +1 -0
- package/lib/browser/doc-model/main.d.ts +5 -0
- package/lib/browser/doc-model/main.d.ts.map +1 -0
- package/lib/browser/doc-model/main.js +8 -0
- package/lib/browser/doc-model/main.js.map +1 -0
- package/lib/browser/doc-model/override.d.ts +12 -0
- package/lib/browser/doc-model/override.d.ts.map +1 -0
- package/lib/browser/doc-model/override.js +46 -0
- package/lib/browser/doc-model/override.js.map +1 -0
- package/lib/browser/doc-model/save-task.d.ts +19 -0
- package/lib/browser/doc-model/save-task.d.ts.map +1 -0
- package/lib/browser/doc-model/save-task.js +34 -0
- package/lib/browser/doc-model/save-task.js.map +1 -0
- package/lib/browser/doc-model/saveParticipants.d.ts +21 -0
- package/lib/browser/doc-model/saveParticipants.d.ts.map +1 -0
- package/lib/browser/doc-model/saveParticipants.js +133 -0
- package/lib/browser/doc-model/saveParticipants.js.map +1 -0
- package/lib/browser/doc-model/types.d.ts +253 -0
- package/lib/browser/doc-model/types.d.ts.map +1 -0
- package/lib/browser/doc-model/types.js +31 -0
- package/lib/browser/doc-model/types.js.map +1 -0
- package/lib/browser/editor-collection.service.d.ts +137 -0
- package/lib/browser/editor-collection.service.d.ts.map +1 -0
- package/lib/browser/editor-collection.service.js +607 -0
- package/lib/browser/editor-collection.service.js.map +1 -0
- package/lib/browser/editor-opener.d.ts +10 -0
- package/lib/browser/editor-opener.d.ts.map +1 -0
- package/lib/browser/editor-opener.js +51 -0
- package/lib/browser/editor-opener.js.map +1 -0
- package/lib/browser/editor.contribution.d.ts +54 -0
- package/lib/browser/editor.contribution.d.ts.map +1 -0
- package/lib/browser/editor.contribution.js +1059 -0
- package/lib/browser/editor.contribution.js.map +1 -0
- package/lib/browser/editor.decoration.service.d.ts +28 -0
- package/lib/browser/editor.decoration.service.d.ts.map +1 -0
- package/lib/browser/editor.decoration.service.js +216 -0
- package/lib/browser/editor.decoration.service.js.map +1 -0
- package/lib/browser/editor.less +4 -0
- package/lib/browser/editor.module.less +493 -0
- package/lib/browser/editor.override.d.ts +24 -0
- package/lib/browser/editor.override.d.ts.map +1 -0
- package/lib/browser/editor.override.js +85 -0
- package/lib/browser/editor.override.js.map +1 -0
- package/lib/browser/editor.status-bar.service.d.ts +12 -0
- package/lib/browser/editor.status-bar.service.d.ts.map +1 -0
- package/lib/browser/editor.status-bar.service.js +114 -0
- package/lib/browser/editor.status-bar.service.js.map +1 -0
- package/lib/browser/editor.view.d.ts +33 -0
- package/lib/browser/editor.view.d.ts.map +1 -0
- package/lib/browser/editor.view.js +411 -0
- package/lib/browser/editor.view.js.map +1 -0
- package/lib/browser/error.d.ts +14 -0
- package/lib/browser/error.d.ts.map +1 -0
- package/lib/browser/error.js +19 -0
- package/lib/browser/error.js.map +1 -0
- package/lib/browser/feature.d.ts +14 -0
- package/lib/browser/feature.d.ts.map +1 -0
- package/lib/browser/feature.js +56 -0
- package/lib/browser/feature.js.map +1 -0
- package/lib/browser/format/formatterSelect.d.ts +11 -0
- package/lib/browser/format/formatterSelect.d.ts.map +1 -0
- package/lib/browser/format/formatterSelect.js +61 -0
- package/lib/browser/format/formatterSelect.js.map +1 -0
- package/lib/browser/fs-resource/file-tree-set.d.ts +31 -0
- package/lib/browser/fs-resource/file-tree-set.d.ts.map +1 -0
- package/lib/browser/fs-resource/file-tree-set.js +123 -0
- package/lib/browser/fs-resource/file-tree-set.js.map +1 -0
- package/lib/browser/fs-resource/fs-editor-doc.d.ts +47 -0
- package/lib/browser/fs-resource/fs-editor-doc.d.ts.map +1 -0
- package/lib/browser/fs-resource/fs-editor-doc.js +148 -0
- package/lib/browser/fs-resource/fs-editor-doc.js.map +1 -0
- package/lib/browser/fs-resource/fs-resource.d.ts +25 -0
- package/lib/browser/fs-resource/fs-resource.d.ts.map +1 -0
- package/lib/browser/fs-resource/fs-resource.js +211 -0
- package/lib/browser/fs-resource/fs-resource.js.map +1 -0
- package/lib/browser/fs-resource/index.d.ts +12 -0
- package/lib/browser/fs-resource/index.d.ts.map +1 -0
- package/lib/browser/fs-resource/index.js +30 -0
- package/lib/browser/fs-resource/index.js.map +1 -0
- package/lib/browser/grid/grid.service.d.ts +44 -0
- package/lib/browser/grid/grid.service.d.ts.map +1 -0
- package/lib/browser/grid/grid.service.js +255 -0
- package/lib/browser/grid/grid.service.js.map +1 -0
- package/lib/browser/history/index.d.ts +31 -0
- package/lib/browser/history/index.d.ts.map +1 -0
- package/lib/browser/history/index.js +164 -0
- package/lib/browser/history/index.js.map +1 -0
- package/lib/browser/index.d.ts +33 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +212 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/language/diagnostic-collection.d.ts +28 -0
- package/lib/browser/language/diagnostic-collection.d.ts.map +1 -0
- package/lib/browser/language/diagnostic-collection.js +72 -0
- package/lib/browser/language/diagnostic-collection.js.map +1 -0
- package/lib/browser/language/language.service.d.ts +19 -0
- package/lib/browser/language/language.service.d.ts.map +1 -0
- package/lib/browser/language/language.service.js +146 -0
- package/lib/browser/language/language.service.js.map +1 -0
- package/lib/browser/language/workspace-symbol-quickopen.d.ts +43 -0
- package/lib/browser/language/workspace-symbol-quickopen.d.ts.map +1 -0
- package/lib/browser/language/workspace-symbol-quickopen.js +231 -0
- package/lib/browser/language/workspace-symbol-quickopen.js.map +1 -0
- package/lib/browser/menu/editor.context.d.ts +20 -0
- package/lib/browser/menu/editor.context.d.ts.map +1 -0
- package/lib/browser/menu/editor.context.js +139 -0
- package/lib/browser/menu/editor.context.js.map +1 -0
- package/lib/browser/menu/editor.menu.d.ts +13 -0
- package/lib/browser/menu/editor.menu.d.ts.map +1 -0
- package/lib/browser/menu/editor.menu.js +48 -0
- package/lib/browser/menu/editor.menu.js.map +1 -0
- package/lib/browser/menu/title-context.menu.d.ts +13 -0
- package/lib/browser/menu/title-context.menu.d.ts.map +1 -0
- package/lib/browser/menu/title-context.menu.js +55 -0
- package/lib/browser/menu/title-context.menu.js.map +1 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.contribution.d.ts +20 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.contribution.d.ts.map +1 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.contribution.js +64 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.contribution.js.map +1 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.d.ts +35 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.d.ts.map +1 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js +144 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js.map +1 -0
- package/lib/browser/monaco-contrib/command/command.service.d.ts +141 -0
- package/lib/browser/monaco-contrib/command/command.service.d.ts.map +1 -0
- package/lib/browser/monaco-contrib/command/command.service.js +370 -0
- package/lib/browser/monaco-contrib/command/command.service.js.map +1 -0
- package/lib/browser/monaco-contrib/index.d.ts +3 -0
- package/lib/browser/monaco-contrib/index.d.ts.map +1 -0
- package/lib/browser/monaco-contrib/index.js +6 -0
- package/lib/browser/monaco-contrib/index.js.map +1 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate-registry.d.ts +46 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate-registry.d.ts.map +1 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate-registry.js +79 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate-registry.js.map +1 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate-tokenizer.d.ts +58 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate-tokenizer.d.ts.map +1 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate-tokenizer.js +75 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate-tokenizer.js.map +1 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.d.ts +54 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.d.ts.map +1 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.js +596 -0
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.js.map +1 -0
- package/lib/browser/navigation.module.less +86 -0
- package/lib/browser/navigation.view.d.ts +29 -0
- package/lib/browser/navigation.view.d.ts.map +1 -0
- package/lib/browser/navigation.view.js +183 -0
- package/lib/browser/navigation.view.js.map +1 -0
- package/lib/browser/preference/contribution.d.ts +5 -0
- package/lib/browser/preference/contribution.d.ts.map +1 -0
- package/lib/browser/preference/contribution.js +16 -0
- package/lib/browser/preference/contribution.js.map +1 -0
- package/lib/browser/preference/converter.d.ts +34 -0
- package/lib/browser/preference/converter.d.ts.map +1 -0
- package/lib/browser/preference/converter.js +632 -0
- package/lib/browser/preference/converter.js.map +1 -0
- package/lib/browser/preference/schema.d.ts +230 -0
- package/lib/browser/preference/schema.d.ts.map +1 -0
- package/lib/browser/preference/schema.js +1453 -0
- package/lib/browser/preference/schema.js.map +1 -0
- package/lib/browser/preference/util.d.ts +4 -0
- package/lib/browser/preference/util.d.ts.map +1 -0
- package/lib/browser/preference/util.js +13 -0
- package/lib/browser/preference/util.js.map +1 -0
- package/lib/browser/resource.service.d.ts +32 -0
- package/lib/browser/resource.service.d.ts.map +1 -0
- package/lib/browser/resource.service.js +219 -0
- package/lib/browser/resource.service.js.map +1 -0
- package/lib/browser/tab.view.d.ts +12 -0
- package/lib/browser/tab.view.d.ts.map +1 -0
- package/lib/browser/tab.view.js +330 -0
- package/lib/browser/tab.view.js.map +1 -0
- package/lib/browser/types.d.ts +344 -0
- package/lib/browser/types.d.ts.map +1 -0
- package/lib/browser/types.js +94 -0
- package/lib/browser/types.js.map +1 -0
- package/lib/browser/untitled-resource.d.ts +33 -0
- package/lib/browser/untitled-resource.d.ts.map +1 -0
- package/lib/browser/untitled-resource.js +114 -0
- package/lib/browser/untitled-resource.js.map +1 -0
- package/lib/browser/view/editor.react.d.ts +10 -0
- package/lib/browser/view/editor.react.d.ts.map +1 -0
- package/lib/browser/view/editor.react.js +69 -0
- package/lib/browser/view/editor.react.js.map +1 -0
- package/lib/browser/view/react-hook.d.ts +3 -0
- package/lib/browser/view/react-hook.d.ts.map +1 -0
- package/lib/browser/view/react-hook.js +9 -0
- package/lib/browser/view/react-hook.js.map +1 -0
- package/lib/browser/view/suggest-widget.d.ts +8 -0
- package/lib/browser/view/suggest-widget.d.ts.map +1 -0
- package/lib/browser/view/suggest-widget.js +51 -0
- package/lib/browser/view/suggest-widget.js.map +1 -0
- package/lib/browser/view/topPadding.d.ts +6 -0
- package/lib/browser/view/topPadding.d.ts.map +1 -0
- package/lib/browser/view/topPadding.js +18 -0
- package/lib/browser/view/topPadding.js.map +1 -0
- package/lib/browser/workbench-editor.service.d.ts +244 -0
- package/lib/browser/workbench-editor.service.d.ts.map +1 -0
- package/lib/browser/workbench-editor.service.js +1689 -0
- package/lib/browser/workbench-editor.service.js.map +1 -0
- package/lib/common/doc-cache.d.ts +80 -0
- package/lib/common/doc-cache.d.ts.map +1 -0
- package/lib/common/doc-cache.js +39 -0
- package/lib/common/doc-cache.js.map +1 -0
- package/lib/common/editor.d.ts +571 -0
- package/lib/common/editor.d.ts.map +1 -0
- package/lib/common/editor.js +125 -0
- package/lib/common/editor.js.map +1 -0
- package/lib/common/index.d.ts +6 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +9 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/language.d.ts +108 -0
- package/lib/common/language.d.ts.map +1 -0
- package/lib/common/language.js +72 -0
- package/lib/common/language.js.map +1 -0
- package/lib/common/mocks/workbench-editor.service.d.ts +21 -0
- package/lib/common/mocks/workbench-editor.service.d.ts.map +1 -0
- package/lib/common/mocks/workbench-editor.service.js +48 -0
- package/lib/common/mocks/workbench-editor.service.js.map +1 -0
- package/lib/common/resource.d.ts +94 -0
- package/lib/common/resource.d.ts.map +1 -0
- package/lib/common/resource.js +31 -0
- package/lib/common/resource.js.map +1 -0
- package/lib/common/utils.d.ts +3 -0
- package/lib/common/utils.d.ts.map +1 -0
- package/lib/common/utils.js +14 -0
- package/lib/common/utils.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,1059 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorAutoSaveEditorContribution = exports.EditorContribution = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const monaco = (0, tslib_1.__importStar)(require("@opensumi/monaco-editor-core/esm/vs/editor/editor.api"));
|
|
6
|
+
const di_1 = require("@opensumi/di");
|
|
7
|
+
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
|
|
8
|
+
const layout_1 = require("@opensumi/ide-core-browser/lib/layout");
|
|
9
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
10
|
+
const next_1 = require("@opensumi/ide-core-browser/lib/menu/next");
|
|
11
|
+
const const_1 = require("@opensumi/ide-core-common/lib/const");
|
|
12
|
+
const common_1 = require("../common");
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
const workbench_editor_service_1 = require("./workbench-editor.service");
|
|
15
|
+
const editor_status_bar_service_1 = require("./editor.status-bar.service");
|
|
16
|
+
const editor_view_1 = require("./editor.view");
|
|
17
|
+
const history_1 = require("./history");
|
|
18
|
+
const navigation_view_1 = require("./navigation.view");
|
|
19
|
+
const types_2 = require("./doc-model/types");
|
|
20
|
+
const formatterSelect_1 = require("./format/formatterSelect");
|
|
21
|
+
const topPadding_1 = require("./view/topPadding");
|
|
22
|
+
const suggest_widget_1 = require("./view/suggest-widget");
|
|
23
|
+
const editor_override_1 = require("./editor.override");
|
|
24
|
+
const override_1 = require("./doc-model/override");
|
|
25
|
+
const editor_opener_1 = require("./editor-opener");
|
|
26
|
+
const workspace_symbol_quickopen_1 = require("./language/workspace-symbol-quickopen");
|
|
27
|
+
const editor_1 = require("../common/editor");
|
|
28
|
+
const types_3 = require("./doc-model/types");
|
|
29
|
+
let EditorContribution = class EditorContribution {
|
|
30
|
+
registerComponent(registry) {
|
|
31
|
+
registry.register('@opensumi/ide-editor', {
|
|
32
|
+
id: 'ide-editor',
|
|
33
|
+
component: editor_view_1.EditorView,
|
|
34
|
+
});
|
|
35
|
+
registry.register('breadcrumb-menu', {
|
|
36
|
+
id: 'breadcrumb-menu',
|
|
37
|
+
component: navigation_view_1.NavigationMenuContainer,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
registerOverrideService(registry) {
|
|
41
|
+
const codeEditorService = this.injector.get(editor_override_1.MonacoCodeService);
|
|
42
|
+
// Monaco Editor ContextKeyService
|
|
43
|
+
// 经过这个Override, 所有编辑器的 contextKeyService 都是 editorContextKeyService 的孩子
|
|
44
|
+
const globalContextKeyService = this.injector.get(ide_core_browser_1.IContextKeyService);
|
|
45
|
+
const editorContextKeyService = globalContextKeyService.createScoped();
|
|
46
|
+
this.workbenchEditorService.setEditorContextKeyService(editorContextKeyService);
|
|
47
|
+
registry.registerOverrideService(ide_core_browser_1.ServiceNames.CONTEXT_KEY_SERVICE, editorContextKeyService.contextKeyService);
|
|
48
|
+
// Monaco CodeEditorService
|
|
49
|
+
registry.registerOverrideService(ide_core_browser_1.ServiceNames.CODE_EDITOR_SERVICE, codeEditorService);
|
|
50
|
+
// Monaco ContextViewService
|
|
51
|
+
registry.registerOverrideService(ide_core_browser_1.ServiceNames.CONTEXT_VIEW_SERVICE, new editor_override_1.MonacoContextViewService(codeEditorService));
|
|
52
|
+
// Monaco TextModelService
|
|
53
|
+
registry.registerOverrideService(ide_core_browser_1.ServiceNames.TEXT_MODEL_SERVICE, this.injector.get(override_1.MonacoTextModelService));
|
|
54
|
+
}
|
|
55
|
+
registerMonacoDefaultFormattingSelector(register) {
|
|
56
|
+
const formatSelector = this.injector.get(formatterSelect_1.FormattingSelector);
|
|
57
|
+
register(formatSelector.select.bind(formatSelector));
|
|
58
|
+
}
|
|
59
|
+
async interceptOpen(uri) {
|
|
60
|
+
try {
|
|
61
|
+
await this.openerService.open(uri);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
this.logger.error(e);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
onWillStop(app) {
|
|
70
|
+
if ((0, ide_core_browser_1.isElectronRenderer)()) {
|
|
71
|
+
return this.onWillStopElectron();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return this.workbenchEditorService.hasDirty() || !this.cacheProvider.isFlushed();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// editorTitle出现了参数不统一。。
|
|
78
|
+
extractGroupAndUriFromArgs(resource, editorGroup) {
|
|
79
|
+
let group;
|
|
80
|
+
let uri;
|
|
81
|
+
if (resource instanceof ide_core_browser_1.URI) {
|
|
82
|
+
group = editorGroup || this.workbenchEditorService.currentEditorGroup;
|
|
83
|
+
uri = resource || (group && group.currentResource && group.currentResource.uri);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const resourceArgs = resource || {};
|
|
87
|
+
group = resourceArgs.group || this.workbenchEditorService.currentEditorGroup;
|
|
88
|
+
uri = resourceArgs.uri || (group && group.currentResource && group.currentResource.uri);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
group,
|
|
92
|
+
uri,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async onWillStopElectron() {
|
|
96
|
+
for (const group of this.workbenchEditorService.editorGroups) {
|
|
97
|
+
for (const resource of group.resources) {
|
|
98
|
+
if (!await this.resourceService.shouldCloseResource(resource, [])) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!this.cacheProvider.isFlushed()) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
registerKeybindings(keybindings) {
|
|
109
|
+
keybindings.registerKeybinding({
|
|
110
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SAVE_CURRENT.id,
|
|
111
|
+
keybinding: 'ctrlcmd+s',
|
|
112
|
+
});
|
|
113
|
+
keybindings.registerKeybinding({
|
|
114
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CLOSE.id,
|
|
115
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'ctrlcmd+w' : 'alt+shift+w',
|
|
116
|
+
});
|
|
117
|
+
keybindings.registerKeybinding({
|
|
118
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.PREVIOUS.id,
|
|
119
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'alt+cmd+left' : 'ctrlcmd+ctrl+left',
|
|
120
|
+
});
|
|
121
|
+
keybindings.registerKeybinding({
|
|
122
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.NEXT.id,
|
|
123
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'alt+cmd+right' : 'ctrlcmd+ctrl+right',
|
|
124
|
+
});
|
|
125
|
+
keybindings.registerKeybinding({
|
|
126
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.PREVIOUS.id,
|
|
127
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'ctrlcmd+pageup' : 'alt+pageup',
|
|
128
|
+
});
|
|
129
|
+
keybindings.registerKeybinding({
|
|
130
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.NEXT.id,
|
|
131
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'ctrlcmd+pagedown' : 'alt+pagedown',
|
|
132
|
+
});
|
|
133
|
+
keybindings.registerKeybinding({
|
|
134
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.GO_FORWARD.id,
|
|
135
|
+
keybinding: ide_core_common_1.isWindows ? 'alt+right' : 'ctrl+shift+-',
|
|
136
|
+
});
|
|
137
|
+
keybindings.registerKeybinding({
|
|
138
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.GO_BACK.id,
|
|
139
|
+
keybinding: ide_core_common_1.isWindows ? 'alt+left' : 'ctrl+-',
|
|
140
|
+
});
|
|
141
|
+
keybindings.registerKeybinding({
|
|
142
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CHANGE_LANGUAGE.id,
|
|
143
|
+
keybinding: 'ctrlcmd+k m',
|
|
144
|
+
});
|
|
145
|
+
keybindings.registerKeybinding({
|
|
146
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_RIGHT.id,
|
|
147
|
+
keybinding: 'ctrlcmd+\\',
|
|
148
|
+
});
|
|
149
|
+
keybindings.registerKeybinding({
|
|
150
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.NAVIGATE_NEXT.id,
|
|
151
|
+
keybinding: 'ctrlcmd+k ctrlcmd+right',
|
|
152
|
+
});
|
|
153
|
+
keybindings.registerKeybinding({
|
|
154
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.NAVIGATE_PREVIOUS.id,
|
|
155
|
+
keybinding: 'ctrlcmd+k ctrlcmd+left',
|
|
156
|
+
});
|
|
157
|
+
keybindings.registerKeybinding({
|
|
158
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SAVE_ALL.id,
|
|
159
|
+
keybinding: 'alt+ctrlcmd+s',
|
|
160
|
+
});
|
|
161
|
+
keybindings.registerKeybinding({
|
|
162
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CLOSE_ALL_IN_GROUP.id,
|
|
163
|
+
keybinding: 'ctrlcmd+k w',
|
|
164
|
+
});
|
|
165
|
+
keybindings.registerKeybinding({
|
|
166
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CLOSE_ALL.id,
|
|
167
|
+
keybinding: 'ctrlcmd+k ctrlcmd+w',
|
|
168
|
+
});
|
|
169
|
+
keybindings.registerKeybinding({
|
|
170
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.PIN_CURRENT.id,
|
|
171
|
+
keybinding: 'ctrlcmd+k enter',
|
|
172
|
+
});
|
|
173
|
+
keybindings.registerKeybinding({
|
|
174
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.COPY_CURRENT_PATH.id,
|
|
175
|
+
keybinding: 'ctrlcmd+k p',
|
|
176
|
+
});
|
|
177
|
+
keybindings.registerKeybinding({
|
|
178
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.REOPEN_CLOSED.id,
|
|
179
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'ctrlcmd+shift+t' : 'alt+shift+t',
|
|
180
|
+
});
|
|
181
|
+
keybindings.registerKeybinding({
|
|
182
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.NEW_UNTITLED_FILE.id,
|
|
183
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'ctrlcmd+n' : 'alt+n',
|
|
184
|
+
});
|
|
185
|
+
keybindings.registerKeybinding({
|
|
186
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SEARCH_WORKSPACE_SYMBOL.id,
|
|
187
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'ctrlcmd+t' : 'ctrlcmd+o',
|
|
188
|
+
});
|
|
189
|
+
keybindings.registerKeybinding({
|
|
190
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SEARCH_WORKSPACE_SYMBOL_CLASS.id,
|
|
191
|
+
keybinding: (0, ide_core_common_1.isElectronEnv)() ? 'ctrlcmd+alt+t' : 'ctrlcmd+alt+o',
|
|
192
|
+
});
|
|
193
|
+
if ((0, ide_core_common_1.isElectronEnv)()) {
|
|
194
|
+
keybindings.registerKeybinding({
|
|
195
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.NEXT.id,
|
|
196
|
+
keybinding: 'ctrl+tab',
|
|
197
|
+
});
|
|
198
|
+
keybindings.registerKeybinding({
|
|
199
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.PREVIOUS.id,
|
|
200
|
+
keybinding: 'ctrl+shift+tab',
|
|
201
|
+
});
|
|
202
|
+
if (ide_core_common_1.isOSX) {
|
|
203
|
+
keybindings.registerKeybinding({
|
|
204
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.NEXT.id,
|
|
205
|
+
keybinding: 'ctrlcmd+shift+]',
|
|
206
|
+
});
|
|
207
|
+
keybindings.registerKeybinding({
|
|
208
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.PREVIOUS.id,
|
|
209
|
+
keybinding: 'ctrlcmd+shift+[',
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (let i = 1; i < 10; i++) {
|
|
214
|
+
keybindings.registerKeybinding({
|
|
215
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.GO_TO_GROUP.id,
|
|
216
|
+
keybinding: 'ctrlcmd+' + i,
|
|
217
|
+
args: [i],
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
['left', 'up', 'down', 'right'].forEach((direction) => {
|
|
221
|
+
keybindings.registerKeybinding({
|
|
222
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.MOVE_GROUP.id,
|
|
223
|
+
keybinding: 'ctrlcmd+k ' + direction,
|
|
224
|
+
args: [direction],
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
keybindings.registerKeybinding({
|
|
228
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.COMPONENT_UNDO.id,
|
|
229
|
+
keybinding: 'ctrlcmd+z',
|
|
230
|
+
when: 'inEditorComponent',
|
|
231
|
+
});
|
|
232
|
+
keybindings.registerKeybinding({
|
|
233
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.COMPONENT_REDO.id,
|
|
234
|
+
keybinding: 'shift+ctrlcmd+z',
|
|
235
|
+
when: 'inEditorComponent',
|
|
236
|
+
});
|
|
237
|
+
keybindings.registerKeybinding({
|
|
238
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.TOGGLE_WORD_WRAP.id,
|
|
239
|
+
keybinding: 'alt+z',
|
|
240
|
+
when: 'editorFocus',
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
initialize() {
|
|
244
|
+
this.editorStatusBarService.setListener();
|
|
245
|
+
this.historyService.start();
|
|
246
|
+
}
|
|
247
|
+
registerCommands(commands) {
|
|
248
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.GO_FORWARD, {
|
|
249
|
+
execute: () => {
|
|
250
|
+
this.historyService.forward();
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.GO_BACK, {
|
|
254
|
+
execute: () => {
|
|
255
|
+
this.historyService.back();
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.OPEN_RESOURCE, {
|
|
259
|
+
execute: async (uri, options) => {
|
|
260
|
+
const openResult = await this.workbenchEditorService.open(uri, options);
|
|
261
|
+
if (openResult) {
|
|
262
|
+
return {
|
|
263
|
+
groupId: openResult === null || openResult === void 0 ? void 0 : openResult.group.name,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.OPEN_RESOURCES, {
|
|
269
|
+
execute: ({ uris }) => {
|
|
270
|
+
this.workbenchEditorService.openUris(uris);
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.COMPARE, {
|
|
274
|
+
execute: ({ original, modified, name }, options = {}) => {
|
|
275
|
+
name = name || `${original.displayName} <=> ${modified.displayName}`;
|
|
276
|
+
return this.workbenchEditorService.open(ide_core_browser_1.URI.from({
|
|
277
|
+
scheme: 'diff',
|
|
278
|
+
query: ide_core_browser_1.URI.stringifyQuery({
|
|
279
|
+
name,
|
|
280
|
+
original,
|
|
281
|
+
modified,
|
|
282
|
+
}),
|
|
283
|
+
}), options);
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SAVE_CURRENT, {
|
|
287
|
+
execute: async () => {
|
|
288
|
+
const group = this.workbenchEditorService.currentEditorGroup;
|
|
289
|
+
if (group && group.currentResource) {
|
|
290
|
+
group.pin(group.currentResource.uri);
|
|
291
|
+
group.saveCurrent();
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SAVE_URI, {
|
|
296
|
+
execute: async (uri) => {
|
|
297
|
+
for (const g of this.workbenchEditorService.editorGroups) {
|
|
298
|
+
const r = g.resources.find((r) => r.uri.isEqual(uri));
|
|
299
|
+
if (r) {
|
|
300
|
+
g.saveResource(r);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CLOSE_ALL_IN_GROUP, {
|
|
306
|
+
execute: async (args0, args1) => {
|
|
307
|
+
const { group, } = this.extractGroupAndUriFromArgs(args0, args1);
|
|
308
|
+
if (group) {
|
|
309
|
+
await group.closeAll();
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CLOSE_SAVED, {
|
|
314
|
+
execute: async (resource) => {
|
|
315
|
+
resource = resource || {};
|
|
316
|
+
const { group = this.workbenchEditorService.currentEditorGroup, } = resource;
|
|
317
|
+
if (group) {
|
|
318
|
+
await group.closeSaved();
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CLOSE_OTHER_IN_GROUP, {
|
|
323
|
+
execute: async (resource) => {
|
|
324
|
+
resource = resource || {};
|
|
325
|
+
const { group = this.workbenchEditorService.currentEditorGroup, uri = group && group.currentResource && group.currentResource.uri, } = resource;
|
|
326
|
+
if (group && uri) {
|
|
327
|
+
await group.closeOthers(uri);
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CLOSE, {
|
|
332
|
+
execute: async (resource) => {
|
|
333
|
+
resource = resource || {};
|
|
334
|
+
const { group = this.workbenchEditorService.currentEditorGroup, uri = group && group.currentResource && group.currentResource.uri, } = resource;
|
|
335
|
+
if (group && uri) {
|
|
336
|
+
await group.close(uri);
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CLOSE_TO_RIGHT, {
|
|
341
|
+
execute: async (resource) => {
|
|
342
|
+
resource = resource || {};
|
|
343
|
+
const { group = this.workbenchEditorService.currentEditorGroup, uri = group && group.currentResource && group.currentResource.uri, } = resource;
|
|
344
|
+
if (group && uri) {
|
|
345
|
+
await group.closeToRight(uri);
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.GET_CURRENT, {
|
|
350
|
+
execute: () => this.workbenchEditorService.currentEditorGroup,
|
|
351
|
+
});
|
|
352
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.GET_CURRENT_RESOURCE, {
|
|
353
|
+
execute: () => this.workbenchEditorService.currentResource,
|
|
354
|
+
});
|
|
355
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.PIN_CURRENT, {
|
|
356
|
+
execute: () => {
|
|
357
|
+
const group = this.workbenchEditorService.currentEditorGroup;
|
|
358
|
+
if (group) {
|
|
359
|
+
group.pinPreviewed();
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.COPY_CURRENT_PATH, {
|
|
364
|
+
execute: () => {
|
|
365
|
+
const resource = this.workbenchEditorService.currentResource;
|
|
366
|
+
if (resource && resource.uri.scheme === ide_core_browser_1.Schemas.file) {
|
|
367
|
+
this.clipboardService.writeText(resource.uri.codeUri.fsPath);
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_LEFT, {
|
|
372
|
+
execute: async (resource) => {
|
|
373
|
+
resource = resource || {};
|
|
374
|
+
const { group = this.workbenchEditorService.currentEditorGroup, uri = group && group.currentResource && group.currentResource.uri, } = resource;
|
|
375
|
+
if (group && uri) {
|
|
376
|
+
await group.split(common_1.EditorGroupSplitAction.Left, uri, { focus: true });
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_RIGHT, {
|
|
381
|
+
execute: async (resource, editorGroup) => {
|
|
382
|
+
const { group, uri } = this.extractGroupAndUriFromArgs(resource, editorGroup);
|
|
383
|
+
if (group && uri) {
|
|
384
|
+
await group.split(common_1.EditorGroupSplitAction.Right, uri, { focus: true });
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.GO_TO_GROUP, {
|
|
389
|
+
execute: async (index = 1) => {
|
|
390
|
+
var _a;
|
|
391
|
+
const group = this.workbenchEditorService.sortedEditorGroups[index - 1];
|
|
392
|
+
if (group) {
|
|
393
|
+
group.focus();
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
// 如果找的索引比 editorGroups 的数量大1,就向右拆分一个
|
|
397
|
+
const groupLength = this.workbenchEditorService.sortedEditorGroups.length;
|
|
398
|
+
if (groupLength === (index - 1)) {
|
|
399
|
+
const rightEditorGroup = this.workbenchEditorService.sortedEditorGroups[groupLength - 1];
|
|
400
|
+
const uri = (_a = rightEditorGroup === null || rightEditorGroup === void 0 ? void 0 : rightEditorGroup.currentResource) === null || _a === void 0 ? void 0 : _a.uri;
|
|
401
|
+
if (rightEditorGroup && uri) {
|
|
402
|
+
await rightEditorGroup.split(common_1.EditorGroupSplitAction.Right, uri, { focus: true });
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.MOVE_GROUP, {
|
|
408
|
+
execute: async (direction) => {
|
|
409
|
+
if (direction) {
|
|
410
|
+
const group = this.workbenchEditorService.currentEditorGroup;
|
|
411
|
+
if (group) {
|
|
412
|
+
group.grid.move(direction);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.FOCUS_ACTIVE_EDITOR_GROUP, {
|
|
418
|
+
execute: async () => {
|
|
419
|
+
const group = this.workbenchEditorService.currentEditorGroup;
|
|
420
|
+
if (group) {
|
|
421
|
+
group.focus();
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_TOP, {
|
|
426
|
+
execute: async (resource) => {
|
|
427
|
+
resource = resource || {};
|
|
428
|
+
const { group = this.workbenchEditorService.currentEditorGroup, uri = group && group.currentResource && group.currentResource.uri, } = resource;
|
|
429
|
+
if (group && uri) {
|
|
430
|
+
await group.split(common_1.EditorGroupSplitAction.Top, uri, { focus: true });
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
});
|
|
434
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_BOTTOM, {
|
|
435
|
+
execute: async (resource) => {
|
|
436
|
+
resource = resource || {};
|
|
437
|
+
const { group = this.workbenchEditorService.currentEditorGroup, uri = group && group.currentResource && group.currentResource.uri, } = resource;
|
|
438
|
+
if (group && uri) {
|
|
439
|
+
await group.split(common_1.EditorGroupSplitAction.Bottom, uri, { focus: true });
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
});
|
|
443
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CHANGE_LANGUAGE, {
|
|
444
|
+
execute: async (currentLanguageId) => {
|
|
445
|
+
const allLanguages = this.languagesService.languages;
|
|
446
|
+
const allLanguageItems = allLanguages.map((language) => ({
|
|
447
|
+
label: language.name,
|
|
448
|
+
value: language.id,
|
|
449
|
+
description: `(${language.id})`,
|
|
450
|
+
}));
|
|
451
|
+
const targetLanguageId = await this.quickPickService.show(allLanguageItems, {
|
|
452
|
+
placeholder: (0, ide_core_browser_1.localize)('editor.changeLanguageId'),
|
|
453
|
+
selectIndex: () => allLanguageItems.findIndex((item) => { var _a, _b; return item.value === ((_b = (_a = this.workbenchEditorService.currentCodeEditor) === null || _a === void 0 ? void 0 : _a.currentDocumentModel) === null || _b === void 0 ? void 0 : _b.languageId); }),
|
|
454
|
+
});
|
|
455
|
+
if (targetLanguageId && currentLanguageId !== targetLanguageId) {
|
|
456
|
+
if (this.workbenchEditorService.currentEditor) {
|
|
457
|
+
const currentDocModel = this.workbenchEditorService.currentEditor.currentDocumentModel;
|
|
458
|
+
if (currentDocModel) {
|
|
459
|
+
this.editorDocumentModelService.changeModelOptions(currentDocModel.uri, {
|
|
460
|
+
languageId: targetLanguageId,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CHANGE_ENCODING, {
|
|
468
|
+
execute: async () => {
|
|
469
|
+
var _a, _b;
|
|
470
|
+
// TODO: 这里应该和 vscode 一样,可以 通过编码打开 和 通过编码保存
|
|
471
|
+
// 但目前的磁盘文件对比使用的是文件字符串 md5 对比,导致更改编码时必定触发 diff,因此编码保存无法生效
|
|
472
|
+
// 长期看 md5 应该更改为 mtime 和 size 才更可靠
|
|
473
|
+
const resource = this.workbenchEditorService.currentResource;
|
|
474
|
+
const documentModel = (_a = this.workbenchEditorService.currentEditor) === null || _a === void 0 ? void 0 : _a.currentDocumentModel;
|
|
475
|
+
if (!resource || !documentModel) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const configuredEncoding = this.preferenceService.get('files.encoding', 'utf8', resource.uri.toString(), (0, ide_core_browser_1.getLanguageIdFromMonaco)(resource.uri));
|
|
479
|
+
const provider = await this.contentRegistry.getProvider(resource.uri);
|
|
480
|
+
const guessedEncoding = await ((_b = provider === null || provider === void 0 ? void 0 : provider.guessEncoding) === null || _b === void 0 ? void 0 : _b.call(provider, resource.uri));
|
|
481
|
+
const currentEncoding = documentModel.encoding;
|
|
482
|
+
let matchIndex;
|
|
483
|
+
const encodingItems = Object.keys(const_1.SUPPORTED_ENCODINGS)
|
|
484
|
+
.sort((k1, k2) => {
|
|
485
|
+
if (k1 === configuredEncoding) {
|
|
486
|
+
return -1;
|
|
487
|
+
}
|
|
488
|
+
else if (k2 === configuredEncoding) {
|
|
489
|
+
return 1;
|
|
490
|
+
}
|
|
491
|
+
return const_1.SUPPORTED_ENCODINGS[k1].order - const_1.SUPPORTED_ENCODINGS[k2].order;
|
|
492
|
+
})
|
|
493
|
+
.filter((k) => {
|
|
494
|
+
// 猜测的编码和配置的编码不一致不现实,单独在最上方显示
|
|
495
|
+
if (k === guessedEncoding && guessedEncoding !== configuredEncoding) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
return !const_1.SUPPORTED_ENCODINGS[k].encodeOnly; // 对于只用于 encode 编码不展示
|
|
499
|
+
})
|
|
500
|
+
.map((key, index) => {
|
|
501
|
+
if (key === currentEncoding || const_1.SUPPORTED_ENCODINGS[key].alias === currentEncoding) {
|
|
502
|
+
matchIndex = index;
|
|
503
|
+
}
|
|
504
|
+
return { label: const_1.SUPPORTED_ENCODINGS[key].labelLong, value: key, description: key };
|
|
505
|
+
});
|
|
506
|
+
// Insert guessed encoding
|
|
507
|
+
if (guessedEncoding && configuredEncoding !== guessedEncoding && const_1.SUPPORTED_ENCODINGS[guessedEncoding]) {
|
|
508
|
+
if (encodingItems[0]) {
|
|
509
|
+
encodingItems[0].showBorder = true;
|
|
510
|
+
}
|
|
511
|
+
encodingItems.unshift({
|
|
512
|
+
label: const_1.SUPPORTED_ENCODINGS[guessedEncoding].labelLong,
|
|
513
|
+
value: guessedEncoding,
|
|
514
|
+
description: (0, ide_core_browser_1.localize)('editor.guessEncodingFromContent'),
|
|
515
|
+
});
|
|
516
|
+
if (typeof matchIndex === 'number') {
|
|
517
|
+
matchIndex++;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
const selectedFileEncoding = await this.quickPickService.show(encodingItems, {
|
|
521
|
+
placeholder: (0, ide_core_browser_1.localize)('editor.chooseEncoding'),
|
|
522
|
+
selectIndex(lookFor) {
|
|
523
|
+
if (!lookFor) {
|
|
524
|
+
return typeof matchIndex === 'number' ? matchIndex : -1;
|
|
525
|
+
}
|
|
526
|
+
return -1;
|
|
527
|
+
},
|
|
528
|
+
});
|
|
529
|
+
if (!selectedFileEncoding) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
this.editorDocumentModelService.changeModelOptions(resource.uri, {
|
|
533
|
+
encoding: selectedFileEncoding,
|
|
534
|
+
});
|
|
535
|
+
},
|
|
536
|
+
});
|
|
537
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CHANGE_EOL, {
|
|
538
|
+
execute: async () => {
|
|
539
|
+
const resource = this.workbenchEditorService.currentResource;
|
|
540
|
+
const currentCodeEditor = this.workbenchEditorService.currentCodeEditor;
|
|
541
|
+
if (currentCodeEditor && currentCodeEditor.currentDocumentModel && resource) {
|
|
542
|
+
const res = await this.quickPickService.show([
|
|
543
|
+
{ label: 'LF', value: "\n" /* LF */ },
|
|
544
|
+
{ label: 'CRLF', value: "\r\n" /* CRLF */ },
|
|
545
|
+
], {
|
|
546
|
+
placeholder: (0, ide_core_browser_1.localize)('editor.changeEol'),
|
|
547
|
+
selectIndex: () => currentCodeEditor.currentDocumentModel.eol === "\n" /* LF */ ? 0 : 1,
|
|
548
|
+
});
|
|
549
|
+
if (res) {
|
|
550
|
+
this.editorDocumentModelService.changeModelOptions(resource.uri, {
|
|
551
|
+
eol: res,
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
});
|
|
557
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.FOCUS, {
|
|
558
|
+
execute: async () => {
|
|
559
|
+
if (this.workbenchEditorService.currentEditor) {
|
|
560
|
+
this.workbenchEditorService.currentEditor.monacoEditor.focus();
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
});
|
|
564
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NAVIGATE_NEXT, {
|
|
565
|
+
execute: async () => {
|
|
566
|
+
let i = this.workbenchEditorService.currentEditorGroup.index + 1;
|
|
567
|
+
if (this.workbenchEditorService.editorGroups.length <= i) {
|
|
568
|
+
i = 0;
|
|
569
|
+
}
|
|
570
|
+
return this.workbenchEditorService.sortedEditorGroups[i].focus();
|
|
571
|
+
},
|
|
572
|
+
});
|
|
573
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NAVIGATE_PREVIOUS, {
|
|
574
|
+
execute: async () => {
|
|
575
|
+
let i = this.workbenchEditorService.currentEditorGroup.index - 1;
|
|
576
|
+
if (i < 0) {
|
|
577
|
+
i = this.workbenchEditorService.editorGroups.length - 1;
|
|
578
|
+
}
|
|
579
|
+
return this.workbenchEditorService.sortedEditorGroups[i].focus();
|
|
580
|
+
},
|
|
581
|
+
});
|
|
582
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NAVIGATE_UP, {
|
|
583
|
+
execute: async () => {
|
|
584
|
+
const currentGrid = this.workbenchEditorService.currentEditorGroup.grid;
|
|
585
|
+
const targetGrid = currentGrid.findGird(common_1.Direction.UP);
|
|
586
|
+
if (targetGrid) {
|
|
587
|
+
return targetGrid.editorGroup.focus();
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NAVIGATE_DOWN, {
|
|
592
|
+
execute: async () => {
|
|
593
|
+
const currentGrid = this.workbenchEditorService.currentEditorGroup.grid;
|
|
594
|
+
const targetGrid = currentGrid.findGird(common_1.Direction.DOWN);
|
|
595
|
+
if (targetGrid) {
|
|
596
|
+
return targetGrid.editorGroup.focus();
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
});
|
|
600
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NAVIGATE_LEFT, {
|
|
601
|
+
execute: async () => {
|
|
602
|
+
const currentGrid = this.workbenchEditorService.currentEditorGroup.grid;
|
|
603
|
+
const targetGrid = currentGrid.findGird(common_1.Direction.LEFT);
|
|
604
|
+
if (targetGrid) {
|
|
605
|
+
return targetGrid.editorGroup.focus();
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
});
|
|
609
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NAVIGATE_RIGHT, {
|
|
610
|
+
execute: async () => {
|
|
611
|
+
const currentGrid = this.workbenchEditorService.currentEditorGroup.grid;
|
|
612
|
+
const targetGrid = currentGrid.findGird(common_1.Direction.RIGHT);
|
|
613
|
+
if (targetGrid) {
|
|
614
|
+
return targetGrid.editorGroup.focus();
|
|
615
|
+
}
|
|
616
|
+
},
|
|
617
|
+
});
|
|
618
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.PREVIOUS_IN_GROUP, {
|
|
619
|
+
execute: async () => {
|
|
620
|
+
const editorGroup = this.workbenchEditorService.currentEditorGroup;
|
|
621
|
+
if (!editorGroup.currentResource) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const index = editorGroup.resources.findIndex((r) => r.uri.isEqual(editorGroup.currentResource.uri)) - 1;
|
|
625
|
+
if (editorGroup.resources[index]) {
|
|
626
|
+
return editorGroup.open(editorGroup.resources[index].uri, { focus: true });
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
return editorGroup.open(editorGroup.resources[0].uri, { focus: true });
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
});
|
|
633
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NEXT_IN_GROUP, {
|
|
634
|
+
execute: async () => {
|
|
635
|
+
const editorGroup = this.workbenchEditorService.currentEditorGroup;
|
|
636
|
+
if (!editorGroup.currentResource) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
const index = editorGroup.resources.findIndex((r) => r.uri.isEqual(editorGroup.currentResource.uri)) + 1;
|
|
640
|
+
if (editorGroup.resources[index]) {
|
|
641
|
+
return editorGroup.open(editorGroup.resources[index].uri, { focus: true });
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
return editorGroup.open(editorGroup.resources[editorGroup.resources.length - 1].uri, { focus: true });
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
});
|
|
648
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NEXT, {
|
|
649
|
+
execute: async () => {
|
|
650
|
+
const editorGroup = this.workbenchEditorService.currentEditorGroup;
|
|
651
|
+
if (!editorGroup.currentResource) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const index = editorGroup.resources.findIndex((r) => r.uri.isEqual(editorGroup.currentResource.uri)) + 1;
|
|
655
|
+
if (editorGroup.resources[index]) {
|
|
656
|
+
return editorGroup.open(editorGroup.resources[index].uri, { focus: true });
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
const nextEditorGroupIndex = editorGroup.index === this.workbenchEditorService.editorGroups.length - 1 ? 0 : editorGroup.index + 1;
|
|
660
|
+
const nextEditorGroup = this.workbenchEditorService.sortedEditorGroups[nextEditorGroupIndex];
|
|
661
|
+
nextEditorGroup.focus();
|
|
662
|
+
return nextEditorGroup.open(nextEditorGroup.resources[0].uri, { focus: true });
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
});
|
|
666
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.PREVIOUS, {
|
|
667
|
+
execute: async () => {
|
|
668
|
+
const editorGroup = this.workbenchEditorService.currentEditorGroup;
|
|
669
|
+
if (!editorGroup.currentResource) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const index = editorGroup.resources.findIndex((r) => r.uri.isEqual(editorGroup.currentResource.uri)) - 1;
|
|
673
|
+
if (editorGroup.resources[index]) {
|
|
674
|
+
return editorGroup.open(editorGroup.resources[index].uri, { focus: true });
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
const nextEditorGroupIndex = editorGroup.index === 0 ? this.workbenchEditorService.editorGroups.length - 1 : editorGroup.index - 1;
|
|
678
|
+
const nextEditorGroup = this.workbenchEditorService.sortedEditorGroups[nextEditorGroupIndex];
|
|
679
|
+
nextEditorGroup.focus();
|
|
680
|
+
return nextEditorGroup.open(nextEditorGroup.resources[nextEditorGroup.resources.length - 1].uri, { focus: true });
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.LAST_IN_GROUP, {
|
|
685
|
+
execute: async () => {
|
|
686
|
+
const editorGroup = this.workbenchEditorService.currentEditorGroup;
|
|
687
|
+
if (editorGroup.resources.length > 0) {
|
|
688
|
+
return editorGroup.open(editorGroup.resources[editorGroup.resources.length - 1].uri, { focus: true });
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
});
|
|
692
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.EVEN_EDITOR_GROUPS, {
|
|
693
|
+
execute: async () => {
|
|
694
|
+
const eventBus = this.injector.get(ide_core_browser_1.IEventBus);
|
|
695
|
+
eventBus.fire(new types_1.EditorGroupsResetSizeEvent());
|
|
696
|
+
},
|
|
697
|
+
});
|
|
698
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CLOSE_OTHER_GROUPS, {
|
|
699
|
+
execute: async () => {
|
|
700
|
+
const editorGroup = this.workbenchEditorService.currentEditorGroup;
|
|
701
|
+
const groupsToClose = this.workbenchEditorService.editorGroups.filter((e) => e !== editorGroup);
|
|
702
|
+
groupsToClose.forEach((g) => {
|
|
703
|
+
g.dispose();
|
|
704
|
+
});
|
|
705
|
+
},
|
|
706
|
+
});
|
|
707
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.OPEN_EDITOR_AT_INDEX, {
|
|
708
|
+
execute: async (index) => {
|
|
709
|
+
const editorGroup = this.workbenchEditorService.currentEditorGroup;
|
|
710
|
+
const target = editorGroup.resources[index];
|
|
711
|
+
if (target) {
|
|
712
|
+
await editorGroup.open(target.uri, { focus: true });
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
});
|
|
716
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.REVERT_DOCUMENT, {
|
|
717
|
+
execute: async () => {
|
|
718
|
+
const group = this.workbenchEditorService.currentEditorGroup;
|
|
719
|
+
if (group.isCodeEditorMode()) {
|
|
720
|
+
const documentModel = group.codeEditor.currentDocumentModel;
|
|
721
|
+
if (documentModel) {
|
|
722
|
+
await documentModel.revert();
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
},
|
|
726
|
+
});
|
|
727
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.REVERT_AND_CLOSE, {
|
|
728
|
+
execute: async () => {
|
|
729
|
+
const group = this.workbenchEditorService.currentEditorGroup;
|
|
730
|
+
if (group.isCodeEditorMode()) {
|
|
731
|
+
const documentModel = group.codeEditor.currentDocumentModel;
|
|
732
|
+
if (documentModel) {
|
|
733
|
+
await documentModel.revert();
|
|
734
|
+
}
|
|
735
|
+
group.close(group.currentResource.uri);
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
});
|
|
739
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SAVE_ALL, {
|
|
740
|
+
execute: async (reason) => {
|
|
741
|
+
this.workbenchEditorService.saveAll(undefined, reason);
|
|
742
|
+
},
|
|
743
|
+
});
|
|
744
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.CLOSE_ALL, {
|
|
745
|
+
execute: async (uri) => {
|
|
746
|
+
this.workbenchEditorService.closeAll(uri);
|
|
747
|
+
},
|
|
748
|
+
});
|
|
749
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.REOPEN_CLOSED, {
|
|
750
|
+
execute: async () => {
|
|
751
|
+
this.historyService.popClosed();
|
|
752
|
+
},
|
|
753
|
+
});
|
|
754
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.NEW_UNTITLED_FILE, {
|
|
755
|
+
execute: () => {
|
|
756
|
+
this.workbenchEditorService.createUntitledResource();
|
|
757
|
+
},
|
|
758
|
+
});
|
|
759
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.COMPONENT_UNDO, {
|
|
760
|
+
execute: () => {
|
|
761
|
+
this.workbenchEditorService.currentEditorGroup.componentUndo();
|
|
762
|
+
},
|
|
763
|
+
});
|
|
764
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.COMPONENT_REDO, {
|
|
765
|
+
execute: () => {
|
|
766
|
+
this.workbenchEditorService.currentEditorGroup.componentRedo();
|
|
767
|
+
},
|
|
768
|
+
});
|
|
769
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.TEST_TOKENIZE, {
|
|
770
|
+
execute: () => {
|
|
771
|
+
const currentCodeEditor = this.workbenchEditorService.currentCodeEditor;
|
|
772
|
+
if (currentCodeEditor) {
|
|
773
|
+
const selections = currentCodeEditor.getSelections();
|
|
774
|
+
if (selections && selections.length > 0 && currentCodeEditor.currentDocumentModel) {
|
|
775
|
+
const { selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn, } = selections[0];
|
|
776
|
+
const selectionText = currentCodeEditor.currentDocumentModel.getText(new monaco.Range(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn));
|
|
777
|
+
this.monacoService.testTokenize(selectionText, currentCodeEditor.currentDocumentModel.languageId);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
});
|
|
782
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SEARCH_WORKSPACE_SYMBOL, {
|
|
783
|
+
execute: () => this.prefixQuickOpenService.open('#'),
|
|
784
|
+
});
|
|
785
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.SEARCH_WORKSPACE_SYMBOL_CLASS, {
|
|
786
|
+
execute: () => this.prefixQuickOpenService.open('##'),
|
|
787
|
+
});
|
|
788
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.TOGGLE_WORD_WRAP, {
|
|
789
|
+
execute: () => {
|
|
790
|
+
const wordWrap = this.preferenceService.get('editor.wordWrap');
|
|
791
|
+
if (wordWrap) {
|
|
792
|
+
const values = ['off', 'on'];
|
|
793
|
+
const index = values.indexOf(wordWrap) + 1;
|
|
794
|
+
if (index > -1) {
|
|
795
|
+
this.preferenceService.set('editor.wordWrap', values[index % values.length], ide_core_common_1.PreferenceScope.User);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
registerMenus(menus) {
|
|
802
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
803
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_LEFT.id,
|
|
804
|
+
group: '9_split',
|
|
805
|
+
});
|
|
806
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
807
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_RIGHT.id,
|
|
808
|
+
group: '9_split',
|
|
809
|
+
});
|
|
810
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
811
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_TOP.id,
|
|
812
|
+
group: '9_split',
|
|
813
|
+
});
|
|
814
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
815
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_BOTTOM.id,
|
|
816
|
+
group: '9_split',
|
|
817
|
+
});
|
|
818
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
819
|
+
command: {
|
|
820
|
+
id: ide_core_browser_1.EDITOR_COMMANDS.CLOSE.id,
|
|
821
|
+
label: (0, ide_core_browser_1.localize)('editor.title.context.close'),
|
|
822
|
+
},
|
|
823
|
+
group: '0_tab',
|
|
824
|
+
order: 1,
|
|
825
|
+
});
|
|
826
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
827
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CLOSE_ALL_IN_GROUP.id,
|
|
828
|
+
group: '0_tab',
|
|
829
|
+
order: 2,
|
|
830
|
+
});
|
|
831
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
832
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CLOSE_SAVED.id,
|
|
833
|
+
group: '0_tab',
|
|
834
|
+
order: 3,
|
|
835
|
+
});
|
|
836
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
837
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CLOSE_OTHER_IN_GROUP.id,
|
|
838
|
+
group: '0_tab',
|
|
839
|
+
order: 4,
|
|
840
|
+
});
|
|
841
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitleContext, {
|
|
842
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CLOSE_TO_RIGHT.id,
|
|
843
|
+
group: '0_tab',
|
|
844
|
+
order: 5,
|
|
845
|
+
});
|
|
846
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitle, {
|
|
847
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.CLOSE_ALL_IN_GROUP.id,
|
|
848
|
+
group: '0_internal',
|
|
849
|
+
});
|
|
850
|
+
menus.registerMenuItem(next_1.MenuId.EditorTitle, {
|
|
851
|
+
command: ide_core_browser_1.EDITOR_COMMANDS.SPLIT_TO_RIGHT.id,
|
|
852
|
+
group: 'navigation',
|
|
853
|
+
when: 'resource',
|
|
854
|
+
order: 5,
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
registerOpener(regisry) {
|
|
858
|
+
regisry.registerOpener(this.editorOpener);
|
|
859
|
+
}
|
|
860
|
+
registerQuickOpenHandlers(handlers) {
|
|
861
|
+
handlers.registerHandler(this.workspaceSymbolQuickOpenHandler, {
|
|
862
|
+
title: (0, ide_core_browser_1.localize)('quickopen.tab.symbol'),
|
|
863
|
+
order: 3,
|
|
864
|
+
commandId: ide_core_browser_1.EDITOR_COMMANDS.SEARCH_WORKSPACE_SYMBOL.id,
|
|
865
|
+
sub: {
|
|
866
|
+
// 将类单独作为一个 tab,Java 场景比较常见,其它技术栈可能不一定
|
|
867
|
+
'#': {
|
|
868
|
+
title: (0, ide_core_browser_1.localize)('quickopen.tab.class'),
|
|
869
|
+
order: 2,
|
|
870
|
+
commandId: ide_core_browser_1.EDITOR_COMMANDS.SEARCH_WORKSPACE_SYMBOL_CLASS.id,
|
|
871
|
+
},
|
|
872
|
+
},
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
(0, tslib_1.__decorate)([
|
|
877
|
+
(0, di_1.Autowired)(di_1.INJECTOR_TOKEN),
|
|
878
|
+
(0, tslib_1.__metadata)("design:type", di_1.Injector)
|
|
879
|
+
], EditorContribution.prototype, "injector", void 0);
|
|
880
|
+
(0, tslib_1.__decorate)([
|
|
881
|
+
(0, di_1.Autowired)(common_1.WorkbenchEditorService),
|
|
882
|
+
(0, tslib_1.__metadata)("design:type", workbench_editor_service_1.WorkbenchEditorServiceImpl)
|
|
883
|
+
], EditorContribution.prototype, "workbenchEditorService", void 0);
|
|
884
|
+
(0, tslib_1.__decorate)([
|
|
885
|
+
(0, di_1.Autowired)(common_1.ResourceService),
|
|
886
|
+
(0, tslib_1.__metadata)("design:type", common_1.ResourceService)
|
|
887
|
+
], EditorContribution.prototype, "resourceService", void 0);
|
|
888
|
+
(0, tslib_1.__decorate)([
|
|
889
|
+
(0, di_1.Autowired)(),
|
|
890
|
+
(0, tslib_1.__metadata)("design:type", editor_status_bar_service_1.EditorStatusBarService)
|
|
891
|
+
], EditorContribution.prototype, "editorStatusBarService", void 0);
|
|
892
|
+
(0, tslib_1.__decorate)([
|
|
893
|
+
(0, di_1.Autowired)(ide_core_browser_1.QuickPickService),
|
|
894
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
895
|
+
], EditorContribution.prototype, "quickPickService", void 0);
|
|
896
|
+
(0, tslib_1.__decorate)([
|
|
897
|
+
(0, di_1.Autowired)(common_1.ILanguageService),
|
|
898
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
899
|
+
], EditorContribution.prototype, "languagesService", void 0);
|
|
900
|
+
(0, tslib_1.__decorate)([
|
|
901
|
+
(0, di_1.Autowired)(types_2.IEditorDocumentModelService),
|
|
902
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
903
|
+
], EditorContribution.prototype, "editorDocumentModelService", void 0);
|
|
904
|
+
(0, tslib_1.__decorate)([
|
|
905
|
+
(0, di_1.Autowired)(common_1.IDocPersistentCacheProvider),
|
|
906
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
907
|
+
], EditorContribution.prototype, "cacheProvider", void 0);
|
|
908
|
+
(0, tslib_1.__decorate)([
|
|
909
|
+
(0, di_1.Autowired)(),
|
|
910
|
+
(0, tslib_1.__metadata)("design:type", history_1.EditorHistoryService)
|
|
911
|
+
], EditorContribution.prototype, "historyService", void 0);
|
|
912
|
+
(0, tslib_1.__decorate)([
|
|
913
|
+
(0, di_1.Autowired)(),
|
|
914
|
+
(0, tslib_1.__metadata)("design:type", ide_core_browser_1.MonacoService)
|
|
915
|
+
], EditorContribution.prototype, "monacoService", void 0);
|
|
916
|
+
(0, tslib_1.__decorate)([
|
|
917
|
+
(0, di_1.Autowired)(ide_core_browser_1.IOpenerService),
|
|
918
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
919
|
+
], EditorContribution.prototype, "openerService", void 0);
|
|
920
|
+
(0, tslib_1.__decorate)([
|
|
921
|
+
(0, di_1.Autowired)(ide_core_common_1.ILogger),
|
|
922
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
923
|
+
], EditorContribution.prototype, "logger", void 0);
|
|
924
|
+
(0, tslib_1.__decorate)([
|
|
925
|
+
(0, di_1.Autowired)(),
|
|
926
|
+
(0, tslib_1.__metadata)("design:type", editor_opener_1.EditorOpener)
|
|
927
|
+
], EditorContribution.prototype, "editorOpener", void 0);
|
|
928
|
+
(0, tslib_1.__decorate)([
|
|
929
|
+
(0, di_1.Autowired)(ide_core_browser_1.IClipboardService),
|
|
930
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
931
|
+
], EditorContribution.prototype, "clipboardService", void 0);
|
|
932
|
+
(0, tslib_1.__decorate)([
|
|
933
|
+
(0, di_1.Autowired)(),
|
|
934
|
+
(0, tslib_1.__metadata)("design:type", workspace_symbol_quickopen_1.WorkspaceSymbolQuickOpenHandler)
|
|
935
|
+
], EditorContribution.prototype, "workspaceSymbolQuickOpenHandler", void 0);
|
|
936
|
+
(0, tslib_1.__decorate)([
|
|
937
|
+
(0, di_1.Autowired)(ide_core_browser_1.PrefixQuickOpenService),
|
|
938
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
939
|
+
], EditorContribution.prototype, "prefixQuickOpenService", void 0);
|
|
940
|
+
(0, tslib_1.__decorate)([
|
|
941
|
+
(0, di_1.Autowired)(ide_core_browser_1.PreferenceService),
|
|
942
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
943
|
+
], EditorContribution.prototype, "preferenceService", void 0);
|
|
944
|
+
(0, tslib_1.__decorate)([
|
|
945
|
+
(0, di_1.Autowired)(types_3.IEditorDocumentModelContentRegistry),
|
|
946
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
947
|
+
], EditorContribution.prototype, "contentRegistry", void 0);
|
|
948
|
+
EditorContribution = (0, tslib_1.__decorate)([
|
|
949
|
+
(0, ide_core_browser_1.Domain)(ide_core_browser_1.CommandContribution, ide_core_browser_1.ClientAppContribution, ide_core_browser_1.KeybindingContribution, ide_core_browser_1.MonacoContribution, layout_1.ComponentContribution, next_1.MenuContribution, ide_core_browser_1.OpenerContribution, ide_core_browser_1.QuickOpenContribution)
|
|
950
|
+
], EditorContribution);
|
|
951
|
+
exports.EditorContribution = EditorContribution;
|
|
952
|
+
let EditorAutoSaveEditorContribution = class EditorAutoSaveEditorContribution {
|
|
953
|
+
registerEditorFeature(registry) {
|
|
954
|
+
registry.registerEditorFeatureContribution({
|
|
955
|
+
contribute: (editor) => {
|
|
956
|
+
const disposable = new ide_core_browser_1.Disposable();
|
|
957
|
+
disposable.addDispose(editor.monacoEditor.onDidBlurEditorWidget(() => {
|
|
958
|
+
if (this.preferenceService.get('editor.autoSave') === editor_1.AUTO_SAVE_MODE.EDITOR_FOCUS_CHANGE) {
|
|
959
|
+
if (editor.currentDocumentModel && !editor.currentDocumentModel.closeAutoSave && editor.currentDocumentModel.dirty && editor.currentDocumentModel.savable) {
|
|
960
|
+
editor.currentDocumentModel.save(undefined, common_1.SaveReason.FocusOut);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}));
|
|
964
|
+
disposable.addDispose(editor.monacoEditor.onDidChangeModel((e) => {
|
|
965
|
+
if (this.preferenceService.get('editor.autoSave') === editor_1.AUTO_SAVE_MODE.EDITOR_FOCUS_CHANGE) {
|
|
966
|
+
if (e.oldModelUrl) {
|
|
967
|
+
const oldUri = new ide_core_browser_1.URI(e.oldModelUrl.toString());
|
|
968
|
+
const docRef = this.editorDocumentService.getModelReference(oldUri, 'editor-focus-autosave');
|
|
969
|
+
if (docRef && !docRef.instance.closeAutoSave && docRef.instance.dirty && docRef.instance.savable) {
|
|
970
|
+
docRef.instance.save(undefined, common_1.SaveReason.FocusOut);
|
|
971
|
+
docRef.dispose();
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}));
|
|
976
|
+
return disposable;
|
|
977
|
+
},
|
|
978
|
+
});
|
|
979
|
+
window.addEventListener('blur', () => {
|
|
980
|
+
if (this.preferenceService.get('editor.autoSave') === editor_1.AUTO_SAVE_MODE.WINDOWS_LOST_FOCUS) {
|
|
981
|
+
this.commandService.executeCommand(ide_core_browser_1.EDITOR_COMMANDS.SAVE_ALL.id, common_1.SaveReason.FocusOut);
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
this.preferenceSettings.setEnumLabels('editor.autoSave', {
|
|
985
|
+
[editor_1.AUTO_SAVE_MODE.OFF]: (0, ide_core_browser_1.localize)('editor.autoSave.enum.off'),
|
|
986
|
+
[editor_1.AUTO_SAVE_MODE.AFTER_DELAY]: (0, ide_core_browser_1.localize)('editor.autoSave.enum.afterDelay'),
|
|
987
|
+
[editor_1.AUTO_SAVE_MODE.EDITOR_FOCUS_CHANGE]: (0, ide_core_browser_1.localize)('editor.autoSave.enum.editorFocusChange'),
|
|
988
|
+
[editor_1.AUTO_SAVE_MODE.WINDOWS_LOST_FOCUS]: (0, ide_core_browser_1.localize)('editor.autoSave.enum.windowLostFocus'),
|
|
989
|
+
});
|
|
990
|
+
registry.registerEditorFeatureContribution(new topPadding_1.EditorTopPaddingContribution());
|
|
991
|
+
registry.registerEditorFeatureContribution(this.injector.get(suggest_widget_1.EditorSuggestWidgetContribution));
|
|
992
|
+
this.registerAutoSaveConfigurationChange();
|
|
993
|
+
}
|
|
994
|
+
registerAutoSaveConfigurationChange() {
|
|
995
|
+
this.preferenceService.onSpecificPreferenceChange('editor.autoSave', (change) => {
|
|
996
|
+
const mode = change.newValue;
|
|
997
|
+
if (mode !== editor_1.AUTO_SAVE_MODE.OFF) {
|
|
998
|
+
// 只有两种原因:丢失焦点和延迟保存,非此即彼
|
|
999
|
+
let reason = common_1.SaveReason.FocusOut;
|
|
1000
|
+
if (mode === editor_1.AUTO_SAVE_MODE.AFTER_DELAY) {
|
|
1001
|
+
reason = common_1.SaveReason.AfterDelay;
|
|
1002
|
+
}
|
|
1003
|
+
// 只保存被该设置影响的文档
|
|
1004
|
+
// 比如在当前工作区写代码,然后打开了一个 ~/.xxx 文件
|
|
1005
|
+
// 然后用户修改了设置,这里就只保存当前工作区的文件。
|
|
1006
|
+
for (const group of this.workbenchEditorService.editorGroups) {
|
|
1007
|
+
for (const resource of group.resources) {
|
|
1008
|
+
if (change.affects(resource === null || resource === void 0 ? void 0 : resource.uri.toString())) {
|
|
1009
|
+
group.saveResource(resource, reason);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
registerCommands(commands) {
|
|
1017
|
+
commands.registerCommand(ide_core_browser_1.EDITOR_COMMANDS.AUTO_SAVE, {
|
|
1018
|
+
execute: () => {
|
|
1019
|
+
const autoSavePreferenceField = 'editor.autoSave';
|
|
1020
|
+
const value = this.preferenceSettings.getPreference(autoSavePreferenceField, ide_core_common_1.PreferenceScope.User).value || editor_1.AUTO_SAVE_MODE.OFF;
|
|
1021
|
+
const nextValue = [
|
|
1022
|
+
editor_1.AUTO_SAVE_MODE.AFTER_DELAY,
|
|
1023
|
+
editor_1.AUTO_SAVE_MODE.EDITOR_FOCUS_CHANGE,
|
|
1024
|
+
editor_1.AUTO_SAVE_MODE.WINDOWS_LOST_FOCUS,
|
|
1025
|
+
].includes(value) ? editor_1.AUTO_SAVE_MODE.OFF : editor_1.AUTO_SAVE_MODE.AFTER_DELAY;
|
|
1026
|
+
return this.preferenceSettings.setPreference(autoSavePreferenceField, nextValue, ide_core_common_1.PreferenceScope.User);
|
|
1027
|
+
},
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
(0, tslib_1.__decorate)([
|
|
1032
|
+
(0, di_1.Autowired)(di_1.INJECTOR_TOKEN),
|
|
1033
|
+
(0, tslib_1.__metadata)("design:type", di_1.Injector)
|
|
1034
|
+
], EditorAutoSaveEditorContribution.prototype, "injector", void 0);
|
|
1035
|
+
(0, tslib_1.__decorate)([
|
|
1036
|
+
(0, di_1.Autowired)(ide_core_browser_1.PreferenceService),
|
|
1037
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
1038
|
+
], EditorAutoSaveEditorContribution.prototype, "preferenceService", void 0);
|
|
1039
|
+
(0, tslib_1.__decorate)([
|
|
1040
|
+
(0, di_1.Autowired)(common_1.WorkbenchEditorService),
|
|
1041
|
+
(0, tslib_1.__metadata)("design:type", workbench_editor_service_1.WorkbenchEditorServiceImpl)
|
|
1042
|
+
], EditorAutoSaveEditorContribution.prototype, "workbenchEditorService", void 0);
|
|
1043
|
+
(0, tslib_1.__decorate)([
|
|
1044
|
+
(0, di_1.Autowired)(ide_core_browser_1.CommandService),
|
|
1045
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
1046
|
+
], EditorAutoSaveEditorContribution.prototype, "commandService", void 0);
|
|
1047
|
+
(0, tslib_1.__decorate)([
|
|
1048
|
+
(0, di_1.Autowired)(types_2.IEditorDocumentModelService),
|
|
1049
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
1050
|
+
], EditorAutoSaveEditorContribution.prototype, "editorDocumentService", void 0);
|
|
1051
|
+
(0, tslib_1.__decorate)([
|
|
1052
|
+
(0, di_1.Autowired)(ide_core_browser_1.IPreferenceSettingsService),
|
|
1053
|
+
(0, tslib_1.__metadata)("design:type", Object)
|
|
1054
|
+
], EditorAutoSaveEditorContribution.prototype, "preferenceSettings", void 0);
|
|
1055
|
+
EditorAutoSaveEditorContribution = (0, tslib_1.__decorate)([
|
|
1056
|
+
(0, ide_core_browser_1.Domain)(types_1.BrowserEditorContribution, ide_core_browser_1.CommandContribution)
|
|
1057
|
+
], EditorAutoSaveEditorContribution);
|
|
1058
|
+
exports.EditorAutoSaveEditorContribution = EditorAutoSaveEditorContribution;
|
|
1059
|
+
//# sourceMappingURL=editor.contribution.js.map
|