@theia/editor 1.34.3 → 1.34.4

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 (100) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +30 -30
  3. package/lib/browser/decorations/editor-decoration-style.d.ts +8 -8
  4. package/lib/browser/decorations/editor-decoration-style.js +36 -36
  5. package/lib/browser/decorations/editor-decoration.d.ts +106 -106
  6. package/lib/browser/decorations/editor-decoration.js +37 -37
  7. package/lib/browser/decorations/editor-decorator.d.ts +6 -6
  8. package/lib/browser/decorations/editor-decorator.js +43 -43
  9. package/lib/browser/decorations/index.d.ts +3 -3
  10. package/lib/browser/decorations/index.js +30 -30
  11. package/lib/browser/diff-navigator.d.ts +10 -10
  12. package/lib/browser/diff-navigator.js +19 -19
  13. package/lib/browser/editor-command.d.ts +102 -102
  14. package/lib/browser/editor-command.js +426 -426
  15. package/lib/browser/editor-contribution.d.ts +26 -26
  16. package/lib/browser/editor-contribution.js +198 -198
  17. package/lib/browser/editor-frontend-module.d.ts +5 -5
  18. package/lib/browser/editor-frontend-module.js +74 -74
  19. package/lib/browser/editor-generated-preference-schema.d.ts +249 -249
  20. package/lib/browser/editor-generated-preference-schema.js +2316 -2316
  21. package/lib/browser/editor-keybinding-contexts.d.ts +35 -35
  22. package/lib/browser/editor-keybinding-contexts.js +98 -98
  23. package/lib/browser/editor-keybinding.d.ts +5 -5
  24. package/lib/browser/editor-keybinding.js +55 -55
  25. package/lib/browser/editor-manager.d.ts +113 -113
  26. package/lib/browser/editor-manager.js +412 -412
  27. package/lib/browser/editor-menu.d.ts +48 -48
  28. package/lib/browser/editor-menu.js +210 -210
  29. package/lib/browser/editor-navigation-contribution.d.ts +67 -67
  30. package/lib/browser/editor-navigation-contribution.js +331 -331
  31. package/lib/browser/editor-preferences.d.ts +40 -40
  32. package/lib/browser/editor-preferences.js +165 -165
  33. package/lib/browser/editor-variable-contribution.d.ts +8 -8
  34. package/lib/browser/editor-variable-contribution.js +64 -64
  35. package/lib/browser/editor-widget-factory.d.ts +17 -17
  36. package/lib/browser/editor-widget-factory.js +91 -91
  37. package/lib/browser/editor-widget.d.ts +20 -20
  38. package/lib/browser/editor-widget.js +87 -87
  39. package/lib/browser/editor.d.ts +293 -293
  40. package/lib/browser/editor.js +103 -103
  41. package/lib/browser/index.d.ts +10 -10
  42. package/lib/browser/index.js +37 -37
  43. package/lib/browser/language-status/editor-language-status-service.d.ts +77 -77
  44. package/lib/browser/language-status/editor-language-status-service.js +251 -251
  45. package/lib/browser/navigation/navigation-location-service.d.ts +103 -103
  46. package/lib/browser/navigation/navigation-location-service.js +281 -281
  47. package/lib/browser/navigation/navigation-location-service.spec.d.ts +1 -1
  48. package/lib/browser/navigation/navigation-location-service.spec.js +184 -184
  49. package/lib/browser/navigation/navigation-location-similarity.d.ts +15 -15
  50. package/lib/browser/navigation/navigation-location-similarity.js +62 -62
  51. package/lib/browser/navigation/navigation-location-similarity.spec.d.ts +1 -1
  52. package/lib/browser/navigation/navigation-location-similarity.spec.js +32 -32
  53. package/lib/browser/navigation/navigation-location-updater.d.ts +35 -35
  54. package/lib/browser/navigation/navigation-location-updater.js +210 -210
  55. package/lib/browser/navigation/navigation-location-updater.spec.d.ts +1 -1
  56. package/lib/browser/navigation/navigation-location-updater.spec.js +177 -177
  57. package/lib/browser/navigation/navigation-location.d.ts +191 -191
  58. package/lib/browser/navigation/navigation-location.js +300 -300
  59. package/lib/browser/navigation/test/mock-navigation-location-updater.d.ts +15 -15
  60. package/lib/browser/navigation/test/mock-navigation-location-updater.js +38 -38
  61. package/lib/browser/quick-editor-service.d.ts +16 -16
  62. package/lib/browser/quick-editor-service.js +109 -109
  63. package/lib/common/language-selector.d.ts +13 -13
  64. package/lib/common/language-selector.js +90 -90
  65. package/lib/package.spec.js +25 -25
  66. package/package.json +5 -5
  67. package/src/browser/decorations/editor-decoration-style.ts +41 -41
  68. package/src/browser/decorations/editor-decoration.ts +127 -127
  69. package/src/browser/decorations/editor-decorator.ts +36 -36
  70. package/src/browser/decorations/index.ts +19 -19
  71. package/src/browser/diff-navigator.ts +28 -28
  72. package/src/browser/editor-command.ts +414 -414
  73. package/src/browser/editor-contribution.ts +185 -185
  74. package/src/browser/editor-frontend-module.ts +85 -85
  75. package/src/browser/editor-generated-preference-schema.ts +2539 -2539
  76. package/src/browser/editor-keybinding-contexts.ts +87 -87
  77. package/src/browser/editor-keybinding.ts +55 -55
  78. package/src/browser/editor-manager.ts +429 -429
  79. package/src/browser/editor-menu.ts +224 -224
  80. package/src/browser/editor-navigation-contribution.ts +331 -331
  81. package/src/browser/editor-preferences.ts +220 -220
  82. package/src/browser/editor-variable-contribution.ts +54 -54
  83. package/src/browser/editor-widget-factory.ts +82 -82
  84. package/src/browser/editor-widget.ts +98 -98
  85. package/src/browser/editor.ts +358 -358
  86. package/src/browser/index.ts +26 -26
  87. package/src/browser/language-status/editor-language-status-service.ts +271 -271
  88. package/src/browser/language-status/editor-language-status.css +98 -98
  89. package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
  90. package/src/browser/navigation/navigation-location-service.ts +284 -284
  91. package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
  92. package/src/browser/navigation/navigation-location-similarity.ts +58 -58
  93. package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
  94. package/src/browser/navigation/navigation-location-updater.ts +220 -220
  95. package/src/browser/navigation/navigation-location.ts +418 -418
  96. package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
  97. package/src/browser/quick-editor-service.ts +94 -94
  98. package/src/browser/style/index.css +19 -19
  99. package/src/common/language-selector.ts +104 -104
  100. package/src/package.spec.ts +28 -28
@@ -1,185 +1,185 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // *****************************************************************************
4
- // Copyright (C) 2018 TypeFox and others.
5
- //
6
- // This program and the accompanying materials are made available under the
7
- // terms of the Eclipse Public License v. 2.0 which is available at
8
- // http://www.eclipse.org/legal/epl-2.0.
9
- //
10
- // This Source Code may also be made available under the following Secondary
11
- // Licenses when the conditions for such availability set forth in the Eclipse
12
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
13
- // with the GNU Classpath Exception which is available at
14
- // https://www.gnu.org/software/classpath/license.html.
15
- //
16
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17
- // *****************************************************************************
18
- const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
19
- let disableJSDOM = (0, jsdom_1.enableJSDOM)();
20
- const chai_1 = require("chai");
21
- const inversify_1 = require("@theia/core/shared/inversify");
22
- const uri_1 = require("@theia/core/lib/common/uri");
23
- const logger_1 = require("@theia/core/lib/common/logger");
24
- const mock_logger_1 = require("@theia/core/lib/common/test/mock-logger");
25
- const opener_service_1 = require("@theia/core/lib/browser/opener-service");
26
- const mock_opener_service_1 = require("@theia/core/lib/browser/test/mock-opener-service");
27
- const navigation_location_updater_1 = require("./navigation-location-updater");
28
- const mock_navigation_location_updater_1 = require("./test/mock-navigation-location-updater");
29
- const navigation_location_similarity_1 = require("./navigation-location-similarity");
30
- const navigation_location_1 = require("./navigation-location");
31
- const navigation_location_service_1 = require("./navigation-location-service");
32
- disableJSDOM();
33
- describe('navigation-location-service', () => {
34
- let stack;
35
- before(() => {
36
- disableJSDOM = (0, jsdom_1.enableJSDOM)();
37
- });
38
- after(() => {
39
- disableJSDOM();
40
- });
41
- beforeEach(() => {
42
- stack = init();
43
- });
44
- it('should not allow navigating back when the stack is empty', () => {
45
- (0, chai_1.expect)(stack.canGoBack()).to.be.false;
46
- });
47
- it('should not allow navigating back when the stack has a single location', () => {
48
- stack.register(createCursorLocation());
49
- (0, chai_1.expect)(stack.canGoBack()).to.be.false;
50
- });
51
- it('should allow navigating back when the stack has more than one locations', () => {
52
- stack.register(createCursorLocation(), createCursorLocation({ line: 100, character: 100 }));
53
- (0, chai_1.expect)(stack.canGoBack()).to.be.true;
54
- });
55
- it('should not allow navigating forward when the stack is empty', () => {
56
- (0, chai_1.expect)(stack.canGoForward()).to.be.false;
57
- });
58
- it('should not allow navigating forward when the pointer points to the end last element of the stack', () => {
59
- stack.register(createCursorLocation(), createCursorLocation({ line: 100, character: 100 }));
60
- (0, chai_1.expect)(stack.canGoForward()).to.be.false;
61
- });
62
- it('should not exceed the max stack item', () => {
63
- const max = navigation_location_service_1.NavigationLocationService['MAX_STACK_ITEMS'];
64
- const locations = [...Array(max + 10).keys()].map(i => createCursorLocation({ line: i * 10, character: i }, `file://${i}`));
65
- stack.register(...locations);
66
- (0, chai_1.expect)(stack.locations().length).to.not.be.greaterThan(max);
67
- });
68
- it('should successfully clear the history', () => {
69
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
70
- const editor = createMockClosedEditor(new uri_1.default('file://foo/a.ts'));
71
- stack.addClosedEditor(editor);
72
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(1);
73
- (0, chai_1.expect)(stack['stack'].length).equal(0);
74
- stack.register(createCursorLocation());
75
- (0, chai_1.expect)(stack['stack'].length).equal(1);
76
- stack['clearHistory']();
77
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
78
- (0, chai_1.expect)(stack['stack'].length).equal(0);
79
- });
80
- describe('last-edit-location', async () => {
81
- it('should return with undefined if the stack contains no modifications', () => {
82
- stack.register(createCursorLocation(), createCursorLocation({ line: 100, character: 100 }));
83
- (0, chai_1.expect)(stack.lastEditLocation()).to.be.undefined;
84
- });
85
- it('should return with the location of the last modification', () => {
86
- const expected = navigation_location_1.NavigationLocation.create('file://path/to/file', {
87
- text: '',
88
- range: { start: { line: 200, character: 0 }, end: { line: 500, character: 0 } },
89
- rangeLength: 0
90
- });
91
- stack.register(createCursorLocation(), expected, createCursorLocation({ line: 100, character: 100 }));
92
- (0, chai_1.expect)(stack.lastEditLocation()).to.be.deep.equal(expected);
93
- });
94
- it('should return with the location of the last modification even if the pointer is not on the head', async () => {
95
- const modificationLocation = navigation_location_1.NavigationLocation.create('file://path/to/file', {
96
- text: '',
97
- range: { start: { line: 300, character: 0 }, end: { line: 500, character: 0 } },
98
- rangeLength: 0
99
- });
100
- const expected = navigation_location_1.NavigationLocation.create('file://path/to/file', {
101
- text: '',
102
- range: { start: { line: 700, character: 0 }, end: { line: 800, character: 0 } },
103
- rangeLength: 0
104
- });
105
- stack.register(createCursorLocation(), modificationLocation, createCursorLocation({ line: 100, character: 100 }), expected);
106
- await stack.back();
107
- await stack.back();
108
- (0, chai_1.expect)(stack.currentLocation()).to.be.deep.equal(modificationLocation);
109
- (0, chai_1.expect)(stack.lastEditLocation()).to.be.deep.equal(expected);
110
- });
111
- });
112
- describe('recently-closed-editors', () => {
113
- describe('#getLastClosedEditor', () => {
114
- it('should return the last closed editor from the history', () => {
115
- const uri = new uri_1.default('file://foo/a.ts');
116
- stack.addClosedEditor(createMockClosedEditor(uri));
117
- const editor = stack.getLastClosedEditor();
118
- (0, chai_1.expect)(editor === null || editor === void 0 ? void 0 : editor.uri).equal(uri);
119
- });
120
- it('should return `undefined` when no history is found', () => {
121
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
122
- const editor = stack.getLastClosedEditor();
123
- (0, chai_1.expect)(editor).equal(undefined);
124
- });
125
- it('should not exceed the max history', () => {
126
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
127
- const max = navigation_location_service_1.NavigationLocationService['MAX_RECENTLY_CLOSED_EDITORS'];
128
- for (let i = 0; i < max + 10; i++) {
129
- const uri = new uri_1.default(`file://foo/bar-${i}.ts`);
130
- stack.addClosedEditor(createMockClosedEditor(uri));
131
- }
132
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length <= max).be.true;
133
- });
134
- });
135
- describe('#addToRecentlyClosedEditors', () => {
136
- it('should include unique recently closed editors in the history', () => {
137
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
138
- const a = createMockClosedEditor(new uri_1.default('file://foo/a.ts'));
139
- const b = createMockClosedEditor(new uri_1.default('file://foo/b.ts'));
140
- stack.addClosedEditor(a);
141
- stack.addClosedEditor(b);
142
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(2);
143
- });
144
- it('should not include duplicate recently closed editors in the history', () => {
145
- const uri = new uri_1.default('file://foo/a.ts');
146
- [1, 2, 3].forEach(i => {
147
- stack.addClosedEditor(createMockClosedEditor(uri));
148
- });
149
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(1);
150
- });
151
- });
152
- describe('#removeFromRecentlyClosedEditors', () => {
153
- it('should successfully remove editors from the history that match the given editor uri', () => {
154
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
155
- const editor = createMockClosedEditor(new uri_1.default('file://foo/a.ts'));
156
- [1, 2, 3].forEach(() => {
157
- stack['recentlyClosedEditors'].push(editor);
158
- });
159
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(3);
160
- // Remove the given editor from the recently closed history.
161
- stack['removeClosedEditor'](editor.uri);
162
- (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
163
- });
164
- });
165
- });
166
- function createCursorLocation(context = { line: 0, character: 0, }, uri = 'file://path/to/file') {
167
- return navigation_location_1.NavigationLocation.create(uri, context);
168
- }
169
- function init() {
170
- const container = new inversify_1.Container({ defaultScope: 'Singleton' });
171
- container.bind(navigation_location_service_1.NavigationLocationService).toSelf();
172
- container.bind(navigation_location_similarity_1.NavigationLocationSimilarity).toSelf();
173
- container.bind(mock_opener_service_1.MockOpenerService).toSelf();
174
- container.bind(mock_logger_1.MockLogger).toSelf();
175
- container.bind(logger_1.ILogger).toService(mock_logger_1.MockLogger);
176
- container.bind(mock_navigation_location_updater_1.NoopNavigationLocationUpdater).toSelf();
177
- container.bind(navigation_location_updater_1.NavigationLocationUpdater).toService(mock_navigation_location_updater_1.NoopNavigationLocationUpdater);
178
- container.bind(opener_service_1.OpenerService).toService(mock_opener_service_1.MockOpenerService);
179
- return container.get(navigation_location_service_1.NavigationLocationService);
180
- }
181
- function createMockClosedEditor(uri) {
182
- return { uri, viewState: {} };
183
- }
184
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // *****************************************************************************
4
+ // Copyright (C) 2018 TypeFox and others.
5
+ //
6
+ // This program and the accompanying materials are made available under the
7
+ // terms of the Eclipse Public License v. 2.0 which is available at
8
+ // http://www.eclipse.org/legal/epl-2.0.
9
+ //
10
+ // This Source Code may also be made available under the following Secondary
11
+ // Licenses when the conditions for such availability set forth in the Eclipse
12
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
13
+ // with the GNU Classpath Exception which is available at
14
+ // https://www.gnu.org/software/classpath/license.html.
15
+ //
16
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17
+ // *****************************************************************************
18
+ const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
19
+ let disableJSDOM = (0, jsdom_1.enableJSDOM)();
20
+ const chai_1 = require("chai");
21
+ const inversify_1 = require("@theia/core/shared/inversify");
22
+ const uri_1 = require("@theia/core/lib/common/uri");
23
+ const logger_1 = require("@theia/core/lib/common/logger");
24
+ const mock_logger_1 = require("@theia/core/lib/common/test/mock-logger");
25
+ const opener_service_1 = require("@theia/core/lib/browser/opener-service");
26
+ const mock_opener_service_1 = require("@theia/core/lib/browser/test/mock-opener-service");
27
+ const navigation_location_updater_1 = require("./navigation-location-updater");
28
+ const mock_navigation_location_updater_1 = require("./test/mock-navigation-location-updater");
29
+ const navigation_location_similarity_1 = require("./navigation-location-similarity");
30
+ const navigation_location_1 = require("./navigation-location");
31
+ const navigation_location_service_1 = require("./navigation-location-service");
32
+ disableJSDOM();
33
+ describe('navigation-location-service', () => {
34
+ let stack;
35
+ before(() => {
36
+ disableJSDOM = (0, jsdom_1.enableJSDOM)();
37
+ });
38
+ after(() => {
39
+ disableJSDOM();
40
+ });
41
+ beforeEach(() => {
42
+ stack = init();
43
+ });
44
+ it('should not allow navigating back when the stack is empty', () => {
45
+ (0, chai_1.expect)(stack.canGoBack()).to.be.false;
46
+ });
47
+ it('should not allow navigating back when the stack has a single location', () => {
48
+ stack.register(createCursorLocation());
49
+ (0, chai_1.expect)(stack.canGoBack()).to.be.false;
50
+ });
51
+ it('should allow navigating back when the stack has more than one locations', () => {
52
+ stack.register(createCursorLocation(), createCursorLocation({ line: 100, character: 100 }));
53
+ (0, chai_1.expect)(stack.canGoBack()).to.be.true;
54
+ });
55
+ it('should not allow navigating forward when the stack is empty', () => {
56
+ (0, chai_1.expect)(stack.canGoForward()).to.be.false;
57
+ });
58
+ it('should not allow navigating forward when the pointer points to the end last element of the stack', () => {
59
+ stack.register(createCursorLocation(), createCursorLocation({ line: 100, character: 100 }));
60
+ (0, chai_1.expect)(stack.canGoForward()).to.be.false;
61
+ });
62
+ it('should not exceed the max stack item', () => {
63
+ const max = navigation_location_service_1.NavigationLocationService['MAX_STACK_ITEMS'];
64
+ const locations = [...Array(max + 10).keys()].map(i => createCursorLocation({ line: i * 10, character: i }, `file://${i}`));
65
+ stack.register(...locations);
66
+ (0, chai_1.expect)(stack.locations().length).to.not.be.greaterThan(max);
67
+ });
68
+ it('should successfully clear the history', () => {
69
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
70
+ const editor = createMockClosedEditor(new uri_1.default('file://foo/a.ts'));
71
+ stack.addClosedEditor(editor);
72
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(1);
73
+ (0, chai_1.expect)(stack['stack'].length).equal(0);
74
+ stack.register(createCursorLocation());
75
+ (0, chai_1.expect)(stack['stack'].length).equal(1);
76
+ stack['clearHistory']();
77
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
78
+ (0, chai_1.expect)(stack['stack'].length).equal(0);
79
+ });
80
+ describe('last-edit-location', async () => {
81
+ it('should return with undefined if the stack contains no modifications', () => {
82
+ stack.register(createCursorLocation(), createCursorLocation({ line: 100, character: 100 }));
83
+ (0, chai_1.expect)(stack.lastEditLocation()).to.be.undefined;
84
+ });
85
+ it('should return with the location of the last modification', () => {
86
+ const expected = navigation_location_1.NavigationLocation.create('file://path/to/file', {
87
+ text: '',
88
+ range: { start: { line: 200, character: 0 }, end: { line: 500, character: 0 } },
89
+ rangeLength: 0
90
+ });
91
+ stack.register(createCursorLocation(), expected, createCursorLocation({ line: 100, character: 100 }));
92
+ (0, chai_1.expect)(stack.lastEditLocation()).to.be.deep.equal(expected);
93
+ });
94
+ it('should return with the location of the last modification even if the pointer is not on the head', async () => {
95
+ const modificationLocation = navigation_location_1.NavigationLocation.create('file://path/to/file', {
96
+ text: '',
97
+ range: { start: { line: 300, character: 0 }, end: { line: 500, character: 0 } },
98
+ rangeLength: 0
99
+ });
100
+ const expected = navigation_location_1.NavigationLocation.create('file://path/to/file', {
101
+ text: '',
102
+ range: { start: { line: 700, character: 0 }, end: { line: 800, character: 0 } },
103
+ rangeLength: 0
104
+ });
105
+ stack.register(createCursorLocation(), modificationLocation, createCursorLocation({ line: 100, character: 100 }), expected);
106
+ await stack.back();
107
+ await stack.back();
108
+ (0, chai_1.expect)(stack.currentLocation()).to.be.deep.equal(modificationLocation);
109
+ (0, chai_1.expect)(stack.lastEditLocation()).to.be.deep.equal(expected);
110
+ });
111
+ });
112
+ describe('recently-closed-editors', () => {
113
+ describe('#getLastClosedEditor', () => {
114
+ it('should return the last closed editor from the history', () => {
115
+ const uri = new uri_1.default('file://foo/a.ts');
116
+ stack.addClosedEditor(createMockClosedEditor(uri));
117
+ const editor = stack.getLastClosedEditor();
118
+ (0, chai_1.expect)(editor === null || editor === void 0 ? void 0 : editor.uri).equal(uri);
119
+ });
120
+ it('should return `undefined` when no history is found', () => {
121
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
122
+ const editor = stack.getLastClosedEditor();
123
+ (0, chai_1.expect)(editor).equal(undefined);
124
+ });
125
+ it('should not exceed the max history', () => {
126
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
127
+ const max = navigation_location_service_1.NavigationLocationService['MAX_RECENTLY_CLOSED_EDITORS'];
128
+ for (let i = 0; i < max + 10; i++) {
129
+ const uri = new uri_1.default(`file://foo/bar-${i}.ts`);
130
+ stack.addClosedEditor(createMockClosedEditor(uri));
131
+ }
132
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length <= max).be.true;
133
+ });
134
+ });
135
+ describe('#addToRecentlyClosedEditors', () => {
136
+ it('should include unique recently closed editors in the history', () => {
137
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
138
+ const a = createMockClosedEditor(new uri_1.default('file://foo/a.ts'));
139
+ const b = createMockClosedEditor(new uri_1.default('file://foo/b.ts'));
140
+ stack.addClosedEditor(a);
141
+ stack.addClosedEditor(b);
142
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(2);
143
+ });
144
+ it('should not include duplicate recently closed editors in the history', () => {
145
+ const uri = new uri_1.default('file://foo/a.ts');
146
+ [1, 2, 3].forEach(i => {
147
+ stack.addClosedEditor(createMockClosedEditor(uri));
148
+ });
149
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(1);
150
+ });
151
+ });
152
+ describe('#removeFromRecentlyClosedEditors', () => {
153
+ it('should successfully remove editors from the history that match the given editor uri', () => {
154
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
155
+ const editor = createMockClosedEditor(new uri_1.default('file://foo/a.ts'));
156
+ [1, 2, 3].forEach(() => {
157
+ stack['recentlyClosedEditors'].push(editor);
158
+ });
159
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(3);
160
+ // Remove the given editor from the recently closed history.
161
+ stack['removeClosedEditor'](editor.uri);
162
+ (0, chai_1.expect)(stack['recentlyClosedEditors'].length).equal(0);
163
+ });
164
+ });
165
+ });
166
+ function createCursorLocation(context = { line: 0, character: 0, }, uri = 'file://path/to/file') {
167
+ return navigation_location_1.NavigationLocation.create(uri, context);
168
+ }
169
+ function init() {
170
+ const container = new inversify_1.Container({ defaultScope: 'Singleton' });
171
+ container.bind(navigation_location_service_1.NavigationLocationService).toSelf();
172
+ container.bind(navigation_location_similarity_1.NavigationLocationSimilarity).toSelf();
173
+ container.bind(mock_opener_service_1.MockOpenerService).toSelf();
174
+ container.bind(mock_logger_1.MockLogger).toSelf();
175
+ container.bind(logger_1.ILogger).toService(mock_logger_1.MockLogger);
176
+ container.bind(mock_navigation_location_updater_1.NoopNavigationLocationUpdater).toSelf();
177
+ container.bind(navigation_location_updater_1.NavigationLocationUpdater).toService(mock_navigation_location_updater_1.NoopNavigationLocationUpdater);
178
+ container.bind(opener_service_1.OpenerService).toService(mock_opener_service_1.MockOpenerService);
179
+ return container.get(navigation_location_service_1.NavigationLocationService);
180
+ }
181
+ function createMockClosedEditor(uri) {
182
+ return { uri, viewState: {} };
183
+ }
184
+ });
185
185
  //# sourceMappingURL=navigation-location-service.spec.js.map
@@ -1,16 +1,16 @@
1
- import { NavigationLocation } from './navigation-location';
2
- /**
3
- * Service for checking whether two navigation locations are similar or not.
4
- */
5
- export declare class NavigationLocationSimilarity {
6
- /**
7
- * The number of lines to move in the editor to justify for new state.
8
- */
9
- private static EDITOR_SELECTION_THRESHOLD;
10
- /**
11
- * `true` if the `left` and `right` locations are withing +- 10 lines in the same editor. Otherwise, `false`.
12
- */
13
- similar(left: NavigationLocation | undefined, right: NavigationLocation | undefined): boolean;
14
- protected getThreshold(): number;
15
- }
1
+ import { NavigationLocation } from './navigation-location';
2
+ /**
3
+ * Service for checking whether two navigation locations are similar or not.
4
+ */
5
+ export declare class NavigationLocationSimilarity {
6
+ /**
7
+ * The number of lines to move in the editor to justify for new state.
8
+ */
9
+ private static EDITOR_SELECTION_THRESHOLD;
10
+ /**
11
+ * `true` if the `left` and `right` locations are withing +- 10 lines in the same editor. Otherwise, `false`.
12
+ */
13
+ similar(left: NavigationLocation | undefined, right: NavigationLocation | undefined): boolean;
14
+ protected getThreshold(): number;
15
+ }
16
16
  //# sourceMappingURL=navigation-location-similarity.d.ts.map
@@ -1,63 +1,63 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2018 TypeFox and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var NavigationLocationSimilarity_1;
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.NavigationLocationSimilarity = void 0;
26
- const inversify_1 = require("@theia/core/shared/inversify");
27
- const navigation_location_1 = require("./navigation-location");
28
- /**
29
- * Service for checking whether two navigation locations are similar or not.
30
- */
31
- let NavigationLocationSimilarity = NavigationLocationSimilarity_1 = class NavigationLocationSimilarity {
32
- /**
33
- * `true` if the `left` and `right` locations are withing +- 10 lines in the same editor. Otherwise, `false`.
34
- */
35
- similar(left, right) {
36
- if (left === undefined || right === undefined) {
37
- return left === right;
38
- }
39
- if (left.uri.toString() !== right.uri.toString()) {
40
- return false;
41
- }
42
- const leftRange = navigation_location_1.NavigationLocation.range(left);
43
- const rightRange = navigation_location_1.NavigationLocation.range(right);
44
- if (leftRange === undefined || rightRange === undefined) {
45
- return leftRange === rightRange;
46
- }
47
- const leftLineNumber = Math.min(leftRange.start.line, leftRange.end.line);
48
- const rightLineNumber = Math.min(rightRange.start.line, rightRange.end.line);
49
- return Math.abs(leftLineNumber - rightLineNumber) < this.getThreshold();
50
- }
51
- getThreshold() {
52
- return NavigationLocationSimilarity_1.EDITOR_SELECTION_THRESHOLD;
53
- }
54
- };
55
- /**
56
- * The number of lines to move in the editor to justify for new state.
57
- */
58
- NavigationLocationSimilarity.EDITOR_SELECTION_THRESHOLD = 10;
59
- NavigationLocationSimilarity = NavigationLocationSimilarity_1 = __decorate([
60
- (0, inversify_1.injectable)()
61
- ], NavigationLocationSimilarity);
62
- exports.NavigationLocationSimilarity = NavigationLocationSimilarity;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2018 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var NavigationLocationSimilarity_1;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.NavigationLocationSimilarity = void 0;
26
+ const inversify_1 = require("@theia/core/shared/inversify");
27
+ const navigation_location_1 = require("./navigation-location");
28
+ /**
29
+ * Service for checking whether two navigation locations are similar or not.
30
+ */
31
+ let NavigationLocationSimilarity = NavigationLocationSimilarity_1 = class NavigationLocationSimilarity {
32
+ /**
33
+ * `true` if the `left` and `right` locations are withing +- 10 lines in the same editor. Otherwise, `false`.
34
+ */
35
+ similar(left, right) {
36
+ if (left === undefined || right === undefined) {
37
+ return left === right;
38
+ }
39
+ if (left.uri.toString() !== right.uri.toString()) {
40
+ return false;
41
+ }
42
+ const leftRange = navigation_location_1.NavigationLocation.range(left);
43
+ const rightRange = navigation_location_1.NavigationLocation.range(right);
44
+ if (leftRange === undefined || rightRange === undefined) {
45
+ return leftRange === rightRange;
46
+ }
47
+ const leftLineNumber = Math.min(leftRange.start.line, leftRange.end.line);
48
+ const rightLineNumber = Math.min(rightRange.start.line, rightRange.end.line);
49
+ return Math.abs(leftLineNumber - rightLineNumber) < this.getThreshold();
50
+ }
51
+ getThreshold() {
52
+ return NavigationLocationSimilarity_1.EDITOR_SELECTION_THRESHOLD;
53
+ }
54
+ };
55
+ /**
56
+ * The number of lines to move in the editor to justify for new state.
57
+ */
58
+ NavigationLocationSimilarity.EDITOR_SELECTION_THRESHOLD = 10;
59
+ NavigationLocationSimilarity = NavigationLocationSimilarity_1 = __decorate([
60
+ (0, inversify_1.injectable)()
61
+ ], NavigationLocationSimilarity);
62
+ exports.NavigationLocationSimilarity = NavigationLocationSimilarity;
63
63
  //# sourceMappingURL=navigation-location-similarity.js.map
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=navigation-location-similarity.spec.d.ts.map
@@ -1,33 +1,33 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2018 TypeFox and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const chai_1 = require("chai");
19
- const navigation_location_1 = require("./navigation-location");
20
- const navigation_location_similarity_1 = require("./navigation-location-similarity");
21
- describe('navigation-location-similarity', () => {
22
- const similarity = new navigation_location_similarity_1.NavigationLocationSimilarity();
23
- it('should never be similar if they belong to different resources', () => {
24
- (0, chai_1.expect)(similarity.similar(navigation_location_1.NavigationLocation.create('file:///a', { line: 0, character: 0, }), navigation_location_1.NavigationLocation.create('file:///b', { line: 0, character: 0, }))).to.be.false;
25
- });
26
- it('should be true if the locations are withing the threshold', () => {
27
- (0, chai_1.expect)(similarity.similar(navigation_location_1.NavigationLocation.create('file:///a', { start: { line: 0, character: 10 }, end: { line: 0, character: 15 } }), navigation_location_1.NavigationLocation.create('file:///a', { start: { line: 10, character: 3 }, end: { line: 0, character: 5 } }))).to.be.true;
28
- });
29
- it('should be false if the locations are outside of the threshold', () => {
30
- (0, chai_1.expect)(similarity.similar(navigation_location_1.NavigationLocation.create('file:///a', { start: { line: 0, character: 10 }, end: { line: 0, character: 15 } }), navigation_location_1.NavigationLocation.create('file:///a', { start: { line: 11, character: 3 }, end: { line: 0, character: 5 } }))).to.be.true;
31
- });
32
- });
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2018 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const chai_1 = require("chai");
19
+ const navigation_location_1 = require("./navigation-location");
20
+ const navigation_location_similarity_1 = require("./navigation-location-similarity");
21
+ describe('navigation-location-similarity', () => {
22
+ const similarity = new navigation_location_similarity_1.NavigationLocationSimilarity();
23
+ it('should never be similar if they belong to different resources', () => {
24
+ (0, chai_1.expect)(similarity.similar(navigation_location_1.NavigationLocation.create('file:///a', { line: 0, character: 0, }), navigation_location_1.NavigationLocation.create('file:///b', { line: 0, character: 0, }))).to.be.false;
25
+ });
26
+ it('should be true if the locations are withing the threshold', () => {
27
+ (0, chai_1.expect)(similarity.similar(navigation_location_1.NavigationLocation.create('file:///a', { start: { line: 0, character: 10 }, end: { line: 0, character: 15 } }), navigation_location_1.NavigationLocation.create('file:///a', { start: { line: 10, character: 3 }, end: { line: 0, character: 5 } }))).to.be.true;
28
+ });
29
+ it('should be false if the locations are outside of the threshold', () => {
30
+ (0, chai_1.expect)(similarity.similar(navigation_location_1.NavigationLocation.create('file:///a', { start: { line: 0, character: 10 }, end: { line: 0, character: 15 } }), navigation_location_1.NavigationLocation.create('file:///a', { start: { line: 11, character: 3 }, end: { line: 0, character: 5 } }))).to.be.true;
31
+ });
32
+ });
33
33
  //# sourceMappingURL=navigation-location-similarity.spec.js.map