@theia/editor 1.53.0-next.4 → 1.53.0-next.55

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.
Files changed (48) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/editor-manager.d.ts.map +1 -1
  3. package/lib/browser/editor-manager.js +11 -4
  4. package/lib/browser/editor-manager.js.map +1 -1
  5. package/lib/browser/editor-variable-contribution.d.ts.map +1 -1
  6. package/lib/browser/editor-variable-contribution.js +9 -1
  7. package/lib/browser/editor-variable-contribution.js.map +1 -1
  8. package/lib/browser/editor.d.ts +5 -2
  9. package/lib/browser/editor.d.ts.map +1 -1
  10. package/lib/browser/editor.js.map +1 -1
  11. package/lib/browser/navigation/navigation-location-service.js +3 -3
  12. package/package.json +5 -5
  13. package/src/browser/decorations/editor-decoration-style.ts +41 -41
  14. package/src/browser/decorations/editor-decoration.ts +127 -127
  15. package/src/browser/decorations/editor-decorator.ts +36 -36
  16. package/src/browser/decorations/index.ts +19 -19
  17. package/src/browser/diff-navigator.ts +27 -27
  18. package/src/browser/editor-command.ts +393 -393
  19. package/src/browser/editor-contribution.ts +185 -185
  20. package/src/browser/editor-frontend-module.ts +90 -90
  21. package/src/browser/editor-generated-preference-schema.ts +2956 -2956
  22. package/src/browser/editor-keybinding.ts +55 -55
  23. package/src/browser/editor-language-quick-pick-service.ts +68 -68
  24. package/src/browser/editor-linenumber-contribution.ts +88 -88
  25. package/src/browser/editor-manager.ts +462 -452
  26. package/src/browser/editor-menu.ts +224 -224
  27. package/src/browser/editor-navigation-contribution.ts +343 -343
  28. package/src/browser/editor-preferences.ts +226 -226
  29. package/src/browser/editor-variable-contribution.ts +62 -54
  30. package/src/browser/editor-widget-factory.ts +82 -82
  31. package/src/browser/editor-widget.ts +139 -139
  32. package/src/browser/editor.ts +366 -362
  33. package/src/browser/index.ts +26 -26
  34. package/src/browser/language-status/editor-language-status-service.ts +271 -271
  35. package/src/browser/language-status/editor-language-status.css +101 -101
  36. package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
  37. package/src/browser/navigation/navigation-location-service.ts +284 -284
  38. package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
  39. package/src/browser/navigation/navigation-location-similarity.ts +58 -58
  40. package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
  41. package/src/browser/navigation/navigation-location-updater.ts +220 -220
  42. package/src/browser/navigation/navigation-location.ts +418 -418
  43. package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
  44. package/src/browser/quick-editor-service.ts +94 -94
  45. package/src/browser/style/index.css +19 -19
  46. package/src/browser/undo-redo-service.ts +120 -120
  47. package/src/common/language-selector.ts +104 -104
  48. package/src/package.spec.ts +28 -28
@@ -1,55 +1,55 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable } from '@theia/core/shared/inversify';
18
- import { environment } from '@theia/core/shared/@theia/application-package/lib/environment';
19
- import { isOSX, isWindows } from '@theia/core/lib/common/os';
20
- import { KeybindingContribution, KeybindingRegistry } from '@theia/core/lib/browser/keybinding';
21
- import { EditorCommands } from './editor-command';
22
-
23
- @injectable()
24
- export class EditorKeybindingContribution implements KeybindingContribution {
25
-
26
- registerKeybindings(registry: KeybindingRegistry): void {
27
- registry.registerKeybindings(
28
- {
29
- command: EditorCommands.GO_BACK.id,
30
- keybinding: isOSX ? 'ctrl+-' : isWindows ? 'alt+left' : /* isLinux */ 'ctrl+alt+-'
31
- },
32
- {
33
- command: EditorCommands.GO_FORWARD.id,
34
- keybinding: isOSX ? 'ctrl+shift+-' : isWindows ? 'alt+right' : /* isLinux */ 'ctrl+shift+-'
35
- },
36
- {
37
- command: EditorCommands.GO_LAST_EDIT.id,
38
- keybinding: 'ctrl+alt+q'
39
- },
40
- {
41
- command: EditorCommands.TOGGLE_WORD_WRAP.id,
42
- keybinding: 'alt+z'
43
- },
44
- {
45
- command: EditorCommands.REOPEN_CLOSED_EDITOR.id,
46
- keybinding: this.isElectron() ? 'ctrlcmd+shift+t' : 'alt+shift+t'
47
- }
48
- );
49
- }
50
-
51
- private isElectron(): boolean {
52
- return environment.electron.is();
53
- }
54
-
55
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+ import { environment } from '@theia/core/shared/@theia/application-package/lib/environment';
19
+ import { isOSX, isWindows } from '@theia/core/lib/common/os';
20
+ import { KeybindingContribution, KeybindingRegistry } from '@theia/core/lib/browser/keybinding';
21
+ import { EditorCommands } from './editor-command';
22
+
23
+ @injectable()
24
+ export class EditorKeybindingContribution implements KeybindingContribution {
25
+
26
+ registerKeybindings(registry: KeybindingRegistry): void {
27
+ registry.registerKeybindings(
28
+ {
29
+ command: EditorCommands.GO_BACK.id,
30
+ keybinding: isOSX ? 'ctrl+-' : isWindows ? 'alt+left' : /* isLinux */ 'ctrl+alt+-'
31
+ },
32
+ {
33
+ command: EditorCommands.GO_FORWARD.id,
34
+ keybinding: isOSX ? 'ctrl+shift+-' : isWindows ? 'alt+right' : /* isLinux */ 'ctrl+shift+-'
35
+ },
36
+ {
37
+ command: EditorCommands.GO_LAST_EDIT.id,
38
+ keybinding: 'ctrl+alt+q'
39
+ },
40
+ {
41
+ command: EditorCommands.TOGGLE_WORD_WRAP.id,
42
+ keybinding: 'alt+z'
43
+ },
44
+ {
45
+ command: EditorCommands.REOPEN_CLOSED_EDITOR.id,
46
+ keybinding: this.isElectron() ? 'ctrlcmd+shift+t' : 'alt+shift+t'
47
+ }
48
+ );
49
+ }
50
+
51
+ private isElectron(): boolean {
52
+ return environment.electron.is();
53
+ }
54
+
55
+ }
@@ -1,68 +1,68 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { inject, injectable } from '@theia/core/shared/inversify';
18
- import { Language, LanguageService } from '@theia/core/lib/browser/language-service';
19
- import { nls, QuickInputService, QuickPickItemOrSeparator, QuickPickValue, URI } from '@theia/core';
20
- import { LabelProvider } from '@theia/core/lib/browser';
21
-
22
- @injectable()
23
- export class EditorLanguageQuickPickService {
24
- @inject(LanguageService)
25
- protected readonly languages: LanguageService;
26
-
27
- @inject(QuickInputService)
28
- protected readonly quickInputService: QuickInputService;
29
-
30
- @inject(LabelProvider)
31
- protected readonly labelProvider: LabelProvider;
32
-
33
- async pickEditorLanguage(current: string): Promise<QuickPickValue<'autoDetect' | Language> | undefined> {
34
- const items: Array<QuickPickValue<'autoDetect' | Language> | QuickPickItemOrSeparator> = [
35
- { label: nls.localizeByDefault('Auto Detect'), value: 'autoDetect' },
36
- { type: 'separator', label: nls.localizeByDefault('languages (identifier)') },
37
- ... (this.languages.languages.map(language => this.toQuickPickLanguage(language, current))).sort((e, e2) => e.label.localeCompare(e2.label))
38
- ];
39
- const selectedMode = await this.quickInputService?.showQuickPick(items, { placeholder: nls.localizeByDefault('Select Language Mode') });
40
- return (selectedMode && 'value' in selectedMode) ? selectedMode : undefined;
41
- }
42
-
43
- protected toQuickPickLanguage(value: Language, current: string): QuickPickValue<Language> {
44
- const languageUri = this.toLanguageUri(value);
45
- const icon = this.labelProvider.getIcon(languageUri);
46
- const iconClasses = icon !== '' ? [icon + ' file-icon'] : undefined;
47
- const configured = current === value.id;
48
- return {
49
- value,
50
- label: value.name,
51
- description: nls.localizeByDefault(`({0})${configured ? ' - Configured Language' : ''}`, value.id),
52
- iconClasses
53
- };
54
- }
55
-
56
- protected toLanguageUri(language: Language): URI {
57
- const extension = language.extensions.values().next();
58
- if (extension.value) {
59
- return new URI('file:///' + extension.value);
60
- }
61
- const filename = language.filenames.values().next();
62
- if (filename.value) {
63
- return new URI('file:///' + filename.value);
64
- }
65
- return new URI('file:///.txt');
66
- }
67
-
68
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable } from '@theia/core/shared/inversify';
18
+ import { Language, LanguageService } from '@theia/core/lib/browser/language-service';
19
+ import { nls, QuickInputService, QuickPickItemOrSeparator, QuickPickValue, URI } from '@theia/core';
20
+ import { LabelProvider } from '@theia/core/lib/browser';
21
+
22
+ @injectable()
23
+ export class EditorLanguageQuickPickService {
24
+ @inject(LanguageService)
25
+ protected readonly languages: LanguageService;
26
+
27
+ @inject(QuickInputService)
28
+ protected readonly quickInputService: QuickInputService;
29
+
30
+ @inject(LabelProvider)
31
+ protected readonly labelProvider: LabelProvider;
32
+
33
+ async pickEditorLanguage(current: string): Promise<QuickPickValue<'autoDetect' | Language> | undefined> {
34
+ const items: Array<QuickPickValue<'autoDetect' | Language> | QuickPickItemOrSeparator> = [
35
+ { label: nls.localizeByDefault('Auto Detect'), value: 'autoDetect' },
36
+ { type: 'separator', label: nls.localizeByDefault('languages (identifier)') },
37
+ ... (this.languages.languages.map(language => this.toQuickPickLanguage(language, current))).sort((e, e2) => e.label.localeCompare(e2.label))
38
+ ];
39
+ const selectedMode = await this.quickInputService?.showQuickPick(items, { placeholder: nls.localizeByDefault('Select Language Mode') });
40
+ return (selectedMode && 'value' in selectedMode) ? selectedMode : undefined;
41
+ }
42
+
43
+ protected toQuickPickLanguage(value: Language, current: string): QuickPickValue<Language> {
44
+ const languageUri = this.toLanguageUri(value);
45
+ const icon = this.labelProvider.getIcon(languageUri);
46
+ const iconClasses = icon !== '' ? [icon + ' file-icon'] : undefined;
47
+ const configured = current === value.id;
48
+ return {
49
+ value,
50
+ label: value.name,
51
+ description: nls.localizeByDefault(`({0})${configured ? ' - Configured Language' : ''}`, value.id),
52
+ iconClasses
53
+ };
54
+ }
55
+
56
+ protected toLanguageUri(language: Language): URI {
57
+ const extension = language.extensions.values().next();
58
+ if (extension.value) {
59
+ return new URI('file:///' + extension.value);
60
+ }
61
+ const filename = language.filenames.values().next();
62
+ if (filename.value) {
63
+ return new URI('file:///' + filename.value);
64
+ }
65
+ return new URI('file:///.txt');
66
+ }
67
+
68
+ }
@@ -1,88 +1,88 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { EditorManager } from './editor-manager';
18
- import { EditorMouseEvent, MouseTargetType, Position, TextEditor } from './editor';
19
- import { injectable, inject } from '@theia/core/shared/inversify';
20
- import { FrontendApplicationContribution, ContextMenuRenderer } from '@theia/core/lib/browser';
21
- import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
22
- import { Disposable, DisposableCollection, MenuPath } from '@theia/core';
23
- import { EditorWidget } from './editor-widget';
24
-
25
- export const EDITOR_LINENUMBER_CONTEXT_MENU: MenuPath = ['editor_linenumber_context_menu'];
26
-
27
- @injectable()
28
- export class EditorLineNumberContribution implements FrontendApplicationContribution {
29
-
30
- @inject(ContextKeyService)
31
- protected readonly contextKeyService: ContextKeyService;
32
-
33
- @inject(ContextMenuRenderer)
34
- protected readonly contextMenuRenderer: ContextMenuRenderer;
35
-
36
- @inject(EditorManager)
37
- protected readonly editorManager: EditorManager;
38
-
39
- onStart(): void {
40
- this.editorManager.onCreated(editor => this.addLineNumberContextMenu(editor));
41
- }
42
-
43
- protected addLineNumberContextMenu(editorWidget: EditorWidget): void {
44
- const editor = editorWidget.editor;
45
- if (editor) {
46
- const disposables = new DisposableCollection();
47
- disposables.push(editor.onMouseDown(event => this.handleContextMenu(editor, event)));
48
- const dispose = () => disposables.dispose();
49
- editorWidget.disposed.connect(dispose);
50
- disposables.push(Disposable.create(() => editorWidget.disposed.disconnect(dispose)));
51
- }
52
- }
53
-
54
- protected handleContextMenu(editor: TextEditor, event: EditorMouseEvent): void {
55
- if (event.target && (event.target.type === MouseTargetType.GUTTER_LINE_NUMBERS || event.target.type === MouseTargetType.GUTTER_GLYPH_MARGIN)) {
56
- if (event.event.button === 2) {
57
- editor.focus();
58
- const lineNumber = lineNumberFromPosition(event.target.position);
59
- const contextKeyService = this.contextKeyService.createOverlay([['editorLineNumber', lineNumber]]);
60
- const uri = editor.getResourceUri()!;
61
- const args = [{
62
- lineNumber: lineNumber,
63
- column: 1, // Compatible with Monaco editor IPosition API
64
- uri: uri['codeUri'],
65
- }];
66
-
67
- setTimeout(() => {
68
- this.contextMenuRenderer.render({
69
- menuPath: EDITOR_LINENUMBER_CONTEXT_MENU,
70
- anchor: event.event,
71
- args,
72
- contextKeyService
73
- });
74
- });
75
- }
76
- }
77
- }
78
-
79
- }
80
-
81
- function lineNumberFromPosition(position: Position | undefined): number | undefined {
82
- // position.line is 0-based line position, where the expected editor line number is 1-based.
83
- if (position) {
84
- return position.line + 1;
85
- }
86
- return undefined;
87
- }
88
-
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { EditorManager } from './editor-manager';
18
+ import { EditorMouseEvent, MouseTargetType, Position, TextEditor } from './editor';
19
+ import { injectable, inject } from '@theia/core/shared/inversify';
20
+ import { FrontendApplicationContribution, ContextMenuRenderer } from '@theia/core/lib/browser';
21
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
22
+ import { Disposable, DisposableCollection, MenuPath } from '@theia/core';
23
+ import { EditorWidget } from './editor-widget';
24
+
25
+ export const EDITOR_LINENUMBER_CONTEXT_MENU: MenuPath = ['editor_linenumber_context_menu'];
26
+
27
+ @injectable()
28
+ export class EditorLineNumberContribution implements FrontendApplicationContribution {
29
+
30
+ @inject(ContextKeyService)
31
+ protected readonly contextKeyService: ContextKeyService;
32
+
33
+ @inject(ContextMenuRenderer)
34
+ protected readonly contextMenuRenderer: ContextMenuRenderer;
35
+
36
+ @inject(EditorManager)
37
+ protected readonly editorManager: EditorManager;
38
+
39
+ onStart(): void {
40
+ this.editorManager.onCreated(editor => this.addLineNumberContextMenu(editor));
41
+ }
42
+
43
+ protected addLineNumberContextMenu(editorWidget: EditorWidget): void {
44
+ const editor = editorWidget.editor;
45
+ if (editor) {
46
+ const disposables = new DisposableCollection();
47
+ disposables.push(editor.onMouseDown(event => this.handleContextMenu(editor, event)));
48
+ const dispose = () => disposables.dispose();
49
+ editorWidget.disposed.connect(dispose);
50
+ disposables.push(Disposable.create(() => editorWidget.disposed.disconnect(dispose)));
51
+ }
52
+ }
53
+
54
+ protected handleContextMenu(editor: TextEditor, event: EditorMouseEvent): void {
55
+ if (event.target && (event.target.type === MouseTargetType.GUTTER_LINE_NUMBERS || event.target.type === MouseTargetType.GUTTER_GLYPH_MARGIN)) {
56
+ if (event.event.button === 2) {
57
+ editor.focus();
58
+ const lineNumber = lineNumberFromPosition(event.target.position);
59
+ const contextKeyService = this.contextKeyService.createOverlay([['editorLineNumber', lineNumber]]);
60
+ const uri = editor.getResourceUri()!;
61
+ const args = [{
62
+ lineNumber: lineNumber,
63
+ column: 1, // Compatible with Monaco editor IPosition API
64
+ uri: uri['codeUri'],
65
+ }];
66
+
67
+ setTimeout(() => {
68
+ this.contextMenuRenderer.render({
69
+ menuPath: EDITOR_LINENUMBER_CONTEXT_MENU,
70
+ anchor: event.event,
71
+ args,
72
+ contextKeyService
73
+ });
74
+ });
75
+ }
76
+ }
77
+ }
78
+
79
+ }
80
+
81
+ function lineNumberFromPosition(position: Position | undefined): number | undefined {
82
+ // position.line is 0-based line position, where the expected editor line number is 1-based.
83
+ if (position) {
84
+ return position.line + 1;
85
+ }
86
+ return undefined;
87
+ }
88
+