@theia/editor 1.45.1 → 1.46.0-next.72

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 (112) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/decorations/editor-decoration-style.d.ts +8 -8
  3. package/lib/browser/decorations/editor-decoration-style.js +36 -36
  4. package/lib/browser/decorations/editor-decoration.d.ts +106 -106
  5. package/lib/browser/decorations/editor-decoration.js +37 -37
  6. package/lib/browser/decorations/editor-decorator.d.ts +6 -6
  7. package/lib/browser/decorations/editor-decorator.js +43 -43
  8. package/lib/browser/decorations/index.d.ts +3 -3
  9. package/lib/browser/decorations/index.js +30 -30
  10. package/lib/browser/diff-navigator.d.ts +9 -10
  11. package/lib/browser/diff-navigator.d.ts.map +1 -1
  12. package/lib/browser/diff-navigator.js +19 -19
  13. package/lib/browser/diff-navigator.js.map +1 -1
  14. package/lib/browser/editor-command.d.ts +102 -102
  15. package/lib/browser/editor-command.js +426 -426
  16. package/lib/browser/editor-contribution.d.ts +26 -26
  17. package/lib/browser/editor-contribution.js +198 -198
  18. package/lib/browser/editor-frontend-module.d.ts +5 -5
  19. package/lib/browser/editor-frontend-module.js +74 -74
  20. package/lib/browser/editor-generated-preference-schema.d.ts +282 -249
  21. package/lib/browser/editor-generated-preference-schema.d.ts.map +1 -1
  22. package/lib/browser/editor-generated-preference-schema.js +2451 -2316
  23. package/lib/browser/editor-generated-preference-schema.js.map +1 -1
  24. package/lib/browser/editor-keybinding.d.ts +5 -5
  25. package/lib/browser/editor-keybinding.js +55 -55
  26. package/lib/browser/editor-linenumber-contribution.d.ts +15 -15
  27. package/lib/browser/editor-linenumber-contribution.d.ts.map +1 -1
  28. package/lib/browser/editor-linenumber-contribution.js +95 -96
  29. package/lib/browser/editor-linenumber-contribution.js.map +1 -1
  30. package/lib/browser/editor-manager.d.ts +115 -115
  31. package/lib/browser/editor-manager.js +428 -428
  32. package/lib/browser/editor-menu.d.ts +48 -48
  33. package/lib/browser/editor-menu.js +210 -210
  34. package/lib/browser/editor-navigation-contribution.d.ts +67 -67
  35. package/lib/browser/editor-navigation-contribution.js +343 -343
  36. package/lib/browser/editor-preferences.d.ts +41 -41
  37. package/lib/browser/editor-preferences.js +176 -176
  38. package/lib/browser/editor-variable-contribution.d.ts +8 -8
  39. package/lib/browser/editor-variable-contribution.js +64 -64
  40. package/lib/browser/editor-widget-factory.d.ts +17 -17
  41. package/lib/browser/editor-widget-factory.js +91 -91
  42. package/lib/browser/editor-widget.d.ts +24 -24
  43. package/lib/browser/editor-widget.d.ts.map +1 -1
  44. package/lib/browser/editor-widget.js +122 -114
  45. package/lib/browser/editor-widget.js.map +1 -1
  46. package/lib/browser/editor.d.ts +295 -293
  47. package/lib/browser/editor.d.ts.map +1 -1
  48. package/lib/browser/editor.js +103 -103
  49. package/lib/browser/editor.js.map +1 -1
  50. package/lib/browser/index.d.ts +10 -10
  51. package/lib/browser/index.js +37 -37
  52. package/lib/browser/language-status/editor-language-status-service.d.ts +77 -77
  53. package/lib/browser/language-status/editor-language-status-service.js +251 -251
  54. package/lib/browser/navigation/navigation-location-service.d.ts +103 -103
  55. package/lib/browser/navigation/navigation-location-service.js +281 -281
  56. package/lib/browser/navigation/navigation-location-service.spec.d.ts +1 -1
  57. package/lib/browser/navigation/navigation-location-service.spec.js +184 -184
  58. package/lib/browser/navigation/navigation-location-similarity.d.ts +15 -15
  59. package/lib/browser/navigation/navigation-location-similarity.js +62 -62
  60. package/lib/browser/navigation/navigation-location-similarity.spec.d.ts +1 -1
  61. package/lib/browser/navigation/navigation-location-similarity.spec.js +32 -32
  62. package/lib/browser/navigation/navigation-location-updater.d.ts +35 -35
  63. package/lib/browser/navigation/navigation-location-updater.js +210 -210
  64. package/lib/browser/navigation/navigation-location-updater.spec.d.ts +1 -1
  65. package/lib/browser/navigation/navigation-location-updater.spec.js +177 -177
  66. package/lib/browser/navigation/navigation-location.d.ts +191 -191
  67. package/lib/browser/navigation/navigation-location.js +300 -300
  68. package/lib/browser/navigation/test/mock-navigation-location-updater.d.ts +15 -15
  69. package/lib/browser/navigation/test/mock-navigation-location-updater.js +38 -38
  70. package/lib/browser/quick-editor-service.d.ts +16 -16
  71. package/lib/browser/quick-editor-service.js +109 -109
  72. package/lib/browser/undo-redo-service.d.ts +23 -23
  73. package/lib/browser/undo-redo-service.js +110 -110
  74. package/lib/common/language-selector.d.ts +13 -13
  75. package/lib/common/language-selector.js +90 -90
  76. package/lib/package.spec.js +25 -25
  77. package/package.json +5 -5
  78. package/src/browser/decorations/editor-decoration-style.ts +41 -41
  79. package/src/browser/decorations/editor-decoration.ts +127 -127
  80. package/src/browser/decorations/editor-decorator.ts +36 -36
  81. package/src/browser/decorations/index.ts +19 -19
  82. package/src/browser/diff-navigator.ts +27 -28
  83. package/src/browser/editor-command.ts +414 -414
  84. package/src/browser/editor-contribution.ts +185 -185
  85. package/src/browser/editor-frontend-module.ts +87 -87
  86. package/src/browser/editor-generated-preference-schema.ts +2707 -2539
  87. package/src/browser/editor-keybinding.ts +55 -55
  88. package/src/browser/editor-linenumber-contribution.ts +88 -89
  89. package/src/browser/editor-manager.ts +442 -442
  90. package/src/browser/editor-menu.ts +224 -224
  91. package/src/browser/editor-navigation-contribution.ts +343 -343
  92. package/src/browser/editor-preferences.ts +226 -226
  93. package/src/browser/editor-variable-contribution.ts +54 -54
  94. package/src/browser/editor-widget-factory.ts +82 -82
  95. package/src/browser/editor-widget.ts +137 -130
  96. package/src/browser/editor.ts +360 -358
  97. package/src/browser/index.ts +26 -26
  98. package/src/browser/language-status/editor-language-status-service.ts +271 -271
  99. package/src/browser/language-status/editor-language-status.css +101 -101
  100. package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
  101. package/src/browser/navigation/navigation-location-service.ts +284 -284
  102. package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
  103. package/src/browser/navigation/navigation-location-similarity.ts +58 -58
  104. package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
  105. package/src/browser/navigation/navigation-location-updater.ts +220 -220
  106. package/src/browser/navigation/navigation-location.ts +418 -418
  107. package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
  108. package/src/browser/quick-editor-service.ts +94 -94
  109. package/src/browser/style/index.css +19 -19
  110. package/src/browser/undo-redo-service.ts +120 -120
  111. package/src/common/language-selector.ts +104 -104
  112. package/src/package.spec.ts +28 -28
@@ -1,178 +1,178 @@
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-only 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 mock_navigation_location_updater_1 = require("./test/mock-navigation-location-updater");
21
- describe('navigation-location-updater', () => {
22
- const updater = new mock_navigation_location_updater_1.MockNavigationLocationUpdater();
23
- describe('contained', () => {
24
- [
25
- [{ start: { line: 4, character: 3 }, end: { line: 4, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 6, character: 12 } }, true],
26
- [{ start: { line: 4, character: 3 }, end: { line: 5, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 6, character: 12 } }, true],
27
- [{ start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, true],
28
- [{ start: { line: 3, character: 2 }, end: { line: 3, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, false],
29
- [{ start: { line: 2, character: 3 }, end: { line: 3, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, false],
30
- [{ start: { line: 3, character: 3 }, end: { line: 3, character: 13 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, false],
31
- [{ start: { line: 3, character: 3 }, end: { line: 4, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, false],
32
- ].forEach(test => {
33
- const [subRange, range, expected] = test;
34
- it(`range ${JSON.stringify(range)} should${!expected ? ' not' : ''} be contained in range ${JSON.stringify(subRange)}`, () => {
35
- (0, chai_1.expect)(updater.contained(subRange, range)).to.be.equal(expected);
36
- });
37
- });
38
- });
39
- describe('affected', () => {
40
- it('should never affect a location if they belong to different resources', () => {
41
- const actual = updater.affects(navigation_location_1.NavigationLocation.create('file:///a', { line: 0, character: 0, }), navigation_location_1.NavigationLocation.create('file:///b', { line: 0, character: 0, }));
42
- (0, chai_1.expect)(actual).to.be.false;
43
- });
44
- [
45
- // Spec(1. and 2.)
46
- {
47
- candidate: { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } },
48
- other: { range: { start: { line: 1, character: 6 }, end: { line: 3, character: 2 } }, rangeLength: 78, text: 'x' },
49
- expected: { start: { line: 1, character: 8 }, end: { line: 1, character: 17 } }
50
- },
51
- {
52
- candidate: { start: { line: 3, character: 3 }, end: { line: 4, character: 18 } },
53
- other: { range: { start: { line: 1, character: 6 }, end: { line: 3, character: 2 } }, rangeLength: 78, text: 'x' },
54
- expected: { start: { line: 1, character: 8 }, end: { line: 2, character: 18 } }
55
- },
56
- {
57
- candidate: { start: { line: 3, character: 17 }, end: { line: 3, character: 26 } },
58
- other: { range: { start: { line: 1, character: 3 }, end: { line: 1, character: 12 } }, rangeLength: 9, text: 'x' },
59
- expected: false
60
- },
61
- {
62
- candidate: { start: { line: 3, character: 17 }, end: { line: 3, character: 26 } },
63
- other: { range: { start: { line: 1, character: 3 }, end: { line: 1, character: 12 } }, rangeLength: 9, text: 'a\n\b\nc' },
64
- expected: { start: { line: 5, character: 17 }, end: { line: 5, character: 26 } }
65
- },
66
- // Spec (3.)
67
- {
68
- candidate: { start: { line: 3, character: 17 }, end: { line: 3, character: 26 } },
69
- other: { range: { start: { line: 3, character: 18 }, end: { line: 3, character: 24 } }, rangeLength: 6, text: 'x' },
70
- expected: { start: { line: 3, character: 17 }, end: { line: 3, character: 21 } }
71
- },
72
- {
73
- candidate: { start: { line: 3, character: 17 }, end: { line: 3, character: 26 } },
74
- other: { range: { start: { line: 3, character: 18 }, end: { line: 3, character: 23 } }, rangeLength: 5, text: 'a\n\b\nc' },
75
- expected: { start: { line: 3, character: 17 }, end: { line: 5, character: 4 } }
76
- },
77
- {
78
- candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
79
- other: { range: { start: { line: 3, character: 19 }, end: { line: 4, character: 19 } }, rangeLength: 41, text: 'xxx' },
80
- expected: { start: { line: 3, character: 17 }, end: { line: 3, character: 29 } }
81
- },
82
- {
83
- candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
84
- other: { range: { start: { line: 3, character: 19 }, end: { line: 3, character: 21 } }, rangeLength: 2, text: 'a\nb' },
85
- expected: { start: { line: 3, character: 17 }, end: { line: 5, character: 26 } }
86
- },
87
- {
88
- candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
89
- other: { range: { start: { line: 3, character: 18 }, end: { line: 4, character: 24 } }, rangeLength: 47, text: 'a\nb\nc' },
90
- expected: { start: { line: 3, character: 17 }, end: { line: 5, character: 3 } }
91
- },
92
- // Spec (4.)
93
- {
94
- candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
95
- other: { range: { start: { line: 6, character: 13 }, end: { line: 6, character: 23 } }, rangeLength: 10, text: '' },
96
- expected: false
97
- },
98
- {
99
- candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
100
- other: { range: { start: { line: 6, character: 13 }, end: { line: 6, character: 23 } }, rangeLength: 10, text: 'a\nb\nc' },
101
- expected: false
102
- },
103
- // Spec (5.)
104
- {
105
- candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
106
- other: { range: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } }, rangeLength: 50, text: '' },
107
- expected: { start: { line: 3, character: 17 }, end: { line: 3, character: 17 } }
108
- },
109
- {
110
- candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
111
- other: { range: { start: { line: 3, character: 17 }, end: { line: 4, character: 27 } }, rangeLength: 51, text: '' },
112
- expected: undefined
113
- },
114
- ].forEach(test => {
115
- const { other, expected, candidate } = test;
116
- it(`should update the navigation location: ${JSON.stringify(candidate)} => ${JSON.stringify(expected)}`, () => {
117
- if (test.trace) {
118
- trace(test);
119
- }
120
- const actual = updater.affects(navigation_location_1.NavigationLocation.create('file:///a', candidate), navigation_location_1.NavigationLocation.create('file:///a', other));
121
- if (typeof expected === 'boolean') {
122
- (0, chai_1.expect)(actual).to.be.deep.equal(expected);
123
- }
124
- else if (expected === undefined) {
125
- (0, chai_1.expect)(actual).to.be.undefined;
126
- }
127
- else {
128
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
- (0, chai_1.expect)(actual.context).to.be.deep.equal(expected);
130
- }
131
- });
132
- });
133
- });
134
- });
135
- function trace(test) {
136
- const line = 10;
137
- const column = 40;
138
- const doc = [];
139
- const printDoc = (text) => {
140
- if (text) {
141
- console.log(`\n START - ${text} `);
142
- }
143
- doc.forEach(row => console.log(row.join('')));
144
- if (text) {
145
- console.log(` END - ${text} \n`);
146
- }
147
- };
148
- const select = (range, p) => {
149
- for (let i = range.start.line + 1; i < range.end.line; i++) {
150
- for (let j = 0; j < column; j++) {
151
- doc[i][j] = p;
152
- }
153
- }
154
- if (range.start.line === range.end.line) {
155
- for (let j = range.start.character; j < range.end.character; j++) {
156
- doc[range.start.line][j] = p;
157
- }
158
- }
159
- else {
160
- for (let j = range.start.character; j < column; j++) {
161
- doc[range.start.line][j] = p;
162
- }
163
- for (let j = 0; j < range.end.character; j++) {
164
- doc[range.end.line][j] = p;
165
- }
166
- }
167
- };
168
- for (let i = 0; i < line; i++) {
169
- doc.push(Array(column).fill('+'));
170
- }
171
- printDoc('EMPTY DOCUMENT');
172
- select(test.candidate, '_');
173
- printDoc('CANDIDATE SELECTION');
174
- select(test.other.range, 'a');
175
- printDoc('APPLIED MODIFICATION');
176
- // TODO: Show the "doc" after applying the changes.
177
- }
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-only 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 mock_navigation_location_updater_1 = require("./test/mock-navigation-location-updater");
21
+ describe('navigation-location-updater', () => {
22
+ const updater = new mock_navigation_location_updater_1.MockNavigationLocationUpdater();
23
+ describe('contained', () => {
24
+ [
25
+ [{ start: { line: 4, character: 3 }, end: { line: 4, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 6, character: 12 } }, true],
26
+ [{ start: { line: 4, character: 3 }, end: { line: 5, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 6, character: 12 } }, true],
27
+ [{ start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, true],
28
+ [{ start: { line: 3, character: 2 }, end: { line: 3, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, false],
29
+ [{ start: { line: 2, character: 3 }, end: { line: 3, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, false],
30
+ [{ start: { line: 3, character: 3 }, end: { line: 3, character: 13 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, false],
31
+ [{ start: { line: 3, character: 3 }, end: { line: 4, character: 12 } }, { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } }, false],
32
+ ].forEach(test => {
33
+ const [subRange, range, expected] = test;
34
+ it(`range ${JSON.stringify(range)} should${!expected ? ' not' : ''} be contained in range ${JSON.stringify(subRange)}`, () => {
35
+ (0, chai_1.expect)(updater.contained(subRange, range)).to.be.equal(expected);
36
+ });
37
+ });
38
+ });
39
+ describe('affected', () => {
40
+ it('should never affect a location if they belong to different resources', () => {
41
+ const actual = updater.affects(navigation_location_1.NavigationLocation.create('file:///a', { line: 0, character: 0, }), navigation_location_1.NavigationLocation.create('file:///b', { line: 0, character: 0, }));
42
+ (0, chai_1.expect)(actual).to.be.false;
43
+ });
44
+ [
45
+ // Spec(1. and 2.)
46
+ {
47
+ candidate: { start: { line: 3, character: 3 }, end: { line: 3, character: 12 } },
48
+ other: { range: { start: { line: 1, character: 6 }, end: { line: 3, character: 2 } }, rangeLength: 78, text: 'x' },
49
+ expected: { start: { line: 1, character: 8 }, end: { line: 1, character: 17 } }
50
+ },
51
+ {
52
+ candidate: { start: { line: 3, character: 3 }, end: { line: 4, character: 18 } },
53
+ other: { range: { start: { line: 1, character: 6 }, end: { line: 3, character: 2 } }, rangeLength: 78, text: 'x' },
54
+ expected: { start: { line: 1, character: 8 }, end: { line: 2, character: 18 } }
55
+ },
56
+ {
57
+ candidate: { start: { line: 3, character: 17 }, end: { line: 3, character: 26 } },
58
+ other: { range: { start: { line: 1, character: 3 }, end: { line: 1, character: 12 } }, rangeLength: 9, text: 'x' },
59
+ expected: false
60
+ },
61
+ {
62
+ candidate: { start: { line: 3, character: 17 }, end: { line: 3, character: 26 } },
63
+ other: { range: { start: { line: 1, character: 3 }, end: { line: 1, character: 12 } }, rangeLength: 9, text: 'a\n\b\nc' },
64
+ expected: { start: { line: 5, character: 17 }, end: { line: 5, character: 26 } }
65
+ },
66
+ // Spec (3.)
67
+ {
68
+ candidate: { start: { line: 3, character: 17 }, end: { line: 3, character: 26 } },
69
+ other: { range: { start: { line: 3, character: 18 }, end: { line: 3, character: 24 } }, rangeLength: 6, text: 'x' },
70
+ expected: { start: { line: 3, character: 17 }, end: { line: 3, character: 21 } }
71
+ },
72
+ {
73
+ candidate: { start: { line: 3, character: 17 }, end: { line: 3, character: 26 } },
74
+ other: { range: { start: { line: 3, character: 18 }, end: { line: 3, character: 23 } }, rangeLength: 5, text: 'a\n\b\nc' },
75
+ expected: { start: { line: 3, character: 17 }, end: { line: 5, character: 4 } }
76
+ },
77
+ {
78
+ candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
79
+ other: { range: { start: { line: 3, character: 19 }, end: { line: 4, character: 19 } }, rangeLength: 41, text: 'xxx' },
80
+ expected: { start: { line: 3, character: 17 }, end: { line: 3, character: 29 } }
81
+ },
82
+ {
83
+ candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
84
+ other: { range: { start: { line: 3, character: 19 }, end: { line: 3, character: 21 } }, rangeLength: 2, text: 'a\nb' },
85
+ expected: { start: { line: 3, character: 17 }, end: { line: 5, character: 26 } }
86
+ },
87
+ {
88
+ candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
89
+ other: { range: { start: { line: 3, character: 18 }, end: { line: 4, character: 24 } }, rangeLength: 47, text: 'a\nb\nc' },
90
+ expected: { start: { line: 3, character: 17 }, end: { line: 5, character: 3 } }
91
+ },
92
+ // Spec (4.)
93
+ {
94
+ candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
95
+ other: { range: { start: { line: 6, character: 13 }, end: { line: 6, character: 23 } }, rangeLength: 10, text: '' },
96
+ expected: false
97
+ },
98
+ {
99
+ candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
100
+ other: { range: { start: { line: 6, character: 13 }, end: { line: 6, character: 23 } }, rangeLength: 10, text: 'a\nb\nc' },
101
+ expected: false
102
+ },
103
+ // Spec (5.)
104
+ {
105
+ candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
106
+ other: { range: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } }, rangeLength: 50, text: '' },
107
+ expected: { start: { line: 3, character: 17 }, end: { line: 3, character: 17 } }
108
+ },
109
+ {
110
+ candidate: { start: { line: 3, character: 17 }, end: { line: 4, character: 26 } },
111
+ other: { range: { start: { line: 3, character: 17 }, end: { line: 4, character: 27 } }, rangeLength: 51, text: '' },
112
+ expected: undefined
113
+ },
114
+ ].forEach(test => {
115
+ const { other, expected, candidate } = test;
116
+ it(`should update the navigation location: ${JSON.stringify(candidate)} => ${JSON.stringify(expected)}`, () => {
117
+ if (test.trace) {
118
+ trace(test);
119
+ }
120
+ const actual = updater.affects(navigation_location_1.NavigationLocation.create('file:///a', candidate), navigation_location_1.NavigationLocation.create('file:///a', other));
121
+ if (typeof expected === 'boolean') {
122
+ (0, chai_1.expect)(actual).to.be.deep.equal(expected);
123
+ }
124
+ else if (expected === undefined) {
125
+ (0, chai_1.expect)(actual).to.be.undefined;
126
+ }
127
+ else {
128
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
+ (0, chai_1.expect)(actual.context).to.be.deep.equal(expected);
130
+ }
131
+ });
132
+ });
133
+ });
134
+ });
135
+ function trace(test) {
136
+ const line = 10;
137
+ const column = 40;
138
+ const doc = [];
139
+ const printDoc = (text) => {
140
+ if (text) {
141
+ console.log(`\n START - ${text} `);
142
+ }
143
+ doc.forEach(row => console.log(row.join('')));
144
+ if (text) {
145
+ console.log(` END - ${text} \n`);
146
+ }
147
+ };
148
+ const select = (range, p) => {
149
+ for (let i = range.start.line + 1; i < range.end.line; i++) {
150
+ for (let j = 0; j < column; j++) {
151
+ doc[i][j] = p;
152
+ }
153
+ }
154
+ if (range.start.line === range.end.line) {
155
+ for (let j = range.start.character; j < range.end.character; j++) {
156
+ doc[range.start.line][j] = p;
157
+ }
158
+ }
159
+ else {
160
+ for (let j = range.start.character; j < column; j++) {
161
+ doc[range.start.line][j] = p;
162
+ }
163
+ for (let j = 0; j < range.end.character; j++) {
164
+ doc[range.end.line][j] = p;
165
+ }
166
+ }
167
+ };
168
+ for (let i = 0; i < line; i++) {
169
+ doc.push(Array(column).fill('+'));
170
+ }
171
+ printDoc('EMPTY DOCUMENT');
172
+ select(test.candidate, '_');
173
+ printDoc('CANDIDATE SELECTION');
174
+ select(test.other.range, 'a');
175
+ printDoc('APPLIED MODIFICATION');
176
+ // TODO: Show the "doc" after applying the changes.
177
+ }
178
178
  //# sourceMappingURL=navigation-location-updater.spec.js.map