-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathSelectionService.test.ts
500 lines (471 loc) · 24.2 KB
/
SelectionService.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { assert } from 'chai';
import { SelectionService, SelectionMode } from './SelectionService';
import { SelectionModel } from 'browser/selection/SelectionModel';
import { IBufferLine } from 'common/Types';
import { MockBufferService, MockOptionsService, MockCoreService } from 'common/TestUtils.test';
import { BufferLine } from 'common/buffer/BufferLine';
import { IBufferService, IOptionsService } from 'common/services/Services';
import { MockCoreBrowserService, MockMouseService, MockRenderService } from 'browser/TestUtils.test';
import { CellData } from 'common/buffer/CellData';
import { IBuffer } from 'common/buffer/Types';
import { IRenderService } from 'browser/services/Services';
class TestSelectionService extends SelectionService {
constructor(
bufferService: IBufferService,
optionsService: IOptionsService,
renderService: IRenderService
) {
super(null!, null!, null!, bufferService, new MockCoreService(), new MockMouseService(), optionsService, renderService, new MockCoreBrowserService());
}
public get model(): SelectionModel { return this._model; }
public set selectionMode(mode: SelectionMode) { this._activeSelectionMode = mode; }
public selectLineAt(line: number): void { this._selectLineAt(line); }
public selectWordAt(coords: [number, number]): void { this._selectWordAt(coords, true); }
public areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean { return this._areCoordsInSelection(coords, start, end); }
// Disable DOM interaction
public enable(): void {}
public disable(): void {}
public refresh(): void {}
}
describe('SelectionService', () => {
let buffer: IBuffer;
let bufferService: IBufferService;
let optionsService: IOptionsService;
let selectionService: TestSelectionService;
beforeEach(() => {
optionsService = new MockOptionsService();
bufferService = new MockBufferService(20, 20, optionsService);
buffer = bufferService.buffer;
const renderService = new MockRenderService();
renderService.dimensions.css.canvas.height = 10 * 20;
renderService.dimensions.css.canvas.width = 10 * 20;
selectionService = new TestSelectionService(bufferService, optionsService, renderService);
});
function stringToRow(text: string): IBufferLine {
const result = BufferLine.make(text.length);
for (let i = 0; i < text.length; i++) {
result.setCell(i, CellData.fromCharData([0, text.charAt(i), 1, text.charCodeAt(i)]));
}
return result;
}
function stringArrayToRow(chars: string[]): IBufferLine {
const line = BufferLine.make(chars.length);
chars.map((c, idx) => line.setCell(idx, CellData.fromCharData([0, c, 1, c.charCodeAt(0)])));
return line;
}
describe('_selectWordAt', () => {
it('should expand selection for normal width chars', () => {
buffer.lines.set(0, stringToRow('foo bar'));
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, 'foo');
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, 'foo');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, 'foo');
selectionService.selectWordAt([3, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([4, 0]);
assert.equal(selectionService.selectionText, 'bar');
selectionService.selectWordAt([5, 0]);
assert.equal(selectionService.selectionText, 'bar');
selectionService.selectWordAt([6, 0]);
assert.equal(selectionService.selectionText, 'bar');
});
it('should expand selection for whitespace', () => {
buffer.lines.set(0, stringToRow('a b'));
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, 'a');
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([3, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([4, 0]);
assert.equal(selectionService.selectionText, 'b');
});
it('should expand selection for wide characters', () => {
// Wide characters use a special format
const data: [number, string, number, number][] = [
[0, '中', 2, '中'.charCodeAt(0)],
[0, '', 0, 0],
[0, '文', 2, '文'.charCodeAt(0)],
[0, '', 0, 0],
[0, ' ', 1, ' '.charCodeAt(0)],
[0, 'a', 1, 'a'.charCodeAt(0)],
[0, '中', 2, '中'.charCodeAt(0)],
[0, '', 0, 0],
[0, '文', 2, '文'.charCodeAt(0)],
[0, '', 0, ''.charCodeAt(0)],
[0, 'b', 1, 'b'.charCodeAt(0)],
[0, ' ', 1, ' '.charCodeAt(0)],
[0, 'f', 1, 'f'.charCodeAt(0)],
[0, 'o', 1, 'o'.charCodeAt(0)],
[0, 'o', 1, 'o'.charCodeAt(0)]
];
const line = BufferLine.make(data.length);
for (let i = 0; i < data.length; ++i) line.setCell(i, CellData.fromCharData(data[i]));
buffer.lines.set(0, line);
// Ensure wide characters take up 2 columns
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, '中文');
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, '中文');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, '中文');
selectionService.selectWordAt([3, 0]);
assert.equal(selectionService.selectionText, '中文');
selectionService.selectWordAt([4, 0]);
assert.equal(selectionService.selectionText, ' ');
// Ensure wide characters work when wrapped in normal width characters
selectionService.selectWordAt([5, 0]);
assert.equal(selectionService.selectionText, 'a中文b');
selectionService.selectWordAt([6, 0]);
assert.equal(selectionService.selectionText, 'a中文b');
selectionService.selectWordAt([7, 0]);
assert.equal(selectionService.selectionText, 'a中文b');
selectionService.selectWordAt([8, 0]);
assert.equal(selectionService.selectionText, 'a中文b');
selectionService.selectWordAt([9, 0]);
assert.equal(selectionService.selectionText, 'a中文b');
selectionService.selectWordAt([10, 0]);
assert.equal(selectionService.selectionText, 'a中文b');
selectionService.selectWordAt([11, 0]);
assert.equal(selectionService.selectionText, ' ');
// Ensure normal width characters work fine in a line containing wide characters
selectionService.selectWordAt([12, 0]);
assert.equal(selectionService.selectionText, 'foo');
selectionService.selectWordAt([13, 0]);
assert.equal(selectionService.selectionText, 'foo');
selectionService.selectWordAt([14, 0]);
assert.equal(selectionService.selectionText, 'foo');
});
it('should select up to non-path characters that are commonly adjacent to paths', () => {
buffer.lines.set(0, stringToRow('(cd)[ef]{gh}\'ij"'));
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, '(cd');
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, 'cd');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, 'cd');
selectionService.selectWordAt([3, 0]);
assert.equal(selectionService.selectionText, 'cd)');
selectionService.selectWordAt([4, 0]);
assert.equal(selectionService.selectionText, '[ef');
selectionService.selectWordAt([5, 0]);
assert.equal(selectionService.selectionText, 'ef');
selectionService.selectWordAt([6, 0]);
assert.equal(selectionService.selectionText, 'ef');
selectionService.selectWordAt([7, 0]);
assert.equal(selectionService.selectionText, 'ef]');
selectionService.selectWordAt([8, 0]);
assert.equal(selectionService.selectionText, '{gh');
selectionService.selectWordAt([9, 0]);
assert.equal(selectionService.selectionText, 'gh');
selectionService.selectWordAt([10, 0]);
assert.equal(selectionService.selectionText, 'gh');
selectionService.selectWordAt([11, 0]);
assert.equal(selectionService.selectionText, 'gh}');
selectionService.selectWordAt([12, 0]);
assert.equal(selectionService.selectionText, '\'ij');
selectionService.selectWordAt([13, 0]);
assert.equal(selectionService.selectionText, 'ij');
selectionService.selectWordAt([14, 0]);
assert.equal(selectionService.selectionText, 'ij');
selectionService.selectWordAt([15, 0]);
assert.equal(selectionService.selectionText, 'ij"');
});
it('should expand upwards or downards for wrapped lines', () => {
buffer.lines.set(0, stringToRow(' foo'));
buffer.lines.set(1, stringToRow('bar '));
buffer.setWrapped(1, true);
selectionService.selectWordAt([1, 1]);
assert.equal(selectionService.selectionText, 'foobar');
selectionService.model.clearSelection();
selectionService.selectWordAt([18, 0]);
assert.equal(selectionService.selectionText, 'foobar');
});
it('should expand both upwards and downwards for word wrapped over many lines', () => {
const expectedText = 'fooaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccbar';
buffer.lines.set(0, stringToRow(' foo'));
buffer.lines.set(1, stringToRow('aaaaaaaaaaaaaaaaaaaa'));
buffer.lines.set(2, stringToRow('bbbbbbbbbbbbbbbbbbbb'));
buffer.lines.set(3, stringToRow('cccccccccccccccccccc'));
buffer.lines.set(4, stringToRow('bar '));
buffer.setWrapped(1, true);
buffer.setWrapped(2, true);
buffer.setWrapped(3, true);
buffer.setWrapped(4, true);
selectionService.selectWordAt([18, 0]);
assert.equal(selectionService.selectionText, expectedText);
selectionService.model.clearSelection();
selectionService.selectWordAt([10, 1]);
assert.equal(selectionService.selectionText, expectedText);
selectionService.model.clearSelection();
selectionService.selectWordAt([10, 2]);
assert.equal(selectionService.selectionText, expectedText);
selectionService.model.clearSelection();
selectionService.selectWordAt([10, 3]);
assert.equal(selectionService.selectionText, expectedText);
selectionService.model.clearSelection();
selectionService.selectWordAt([1, 4]);
assert.equal(selectionService.selectionText, expectedText);
});
describe('emoji', () => {
it('should treat a single emoji as a word when wrapped in spaces', () => {
buffer.lines.set(0, stringToRow(' ⚽ a')); // The a is here to prevent the space being trimmed in selectionText
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, '⚽');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, ' ');
});
it('should treat multiple emojis as a word when wrapped in spaces', () => {
buffer.lines.set(0, stringToRow(' ⚽⚽ a')); // The a is here to prevent the space being trimmed in selectionText
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, '⚽⚽');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, '⚽⚽');
selectionService.selectWordAt([3, 0]);
assert.equal(selectionService.selectionText, ' ');
});
it('should treat emojis using the zero-width-joiner as a single word', () => {
// Note that the first 3 emojis include the invisible ZWJ char
buffer.lines.set(0, stringArrayToRow([
' ', '👨', '👩', '👧', '👦', ' ', 'a'
])); // The a is here to prevent the space being trimmed in selectionText
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, ' ');
// ZWJ emojis do not combine in the terminal so the family emoji used here consumed 4 cells
// The selection text should retain ZWJ chars despite not combining on the terminal
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, '👨👩👧👦');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, '👨👩👧👦');
selectionService.selectWordAt([3, 0]);
assert.equal(selectionService.selectionText, '👨👩👧👦');
selectionService.selectWordAt([4, 0]);
assert.equal(selectionService.selectionText, '👨👩👧👦');
selectionService.selectWordAt([5, 0]);
assert.equal(selectionService.selectionText, ' ');
});
it('should treat emojis and characters joined together as a word', () => {
buffer.lines.set(0, stringToRow(' ⚽ab cd⚽ ef⚽gh')); // The a is here to prevent the space being trimmed in selectionText
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, '⚽ab');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, '⚽ab');
selectionService.selectWordAt([3, 0]);
assert.equal(selectionService.selectionText, '⚽ab');
selectionService.selectWordAt([4, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([5, 0]);
assert.equal(selectionService.selectionText, 'cd⚽');
selectionService.selectWordAt([6, 0]);
assert.equal(selectionService.selectionText, 'cd⚽');
selectionService.selectWordAt([7, 0]);
assert.equal(selectionService.selectionText, 'cd⚽');
selectionService.selectWordAt([8, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([9, 0]);
assert.equal(selectionService.selectionText, 'ef⚽gh');
selectionService.selectWordAt([10, 0]);
assert.equal(selectionService.selectionText, 'ef⚽gh');
selectionService.selectWordAt([11, 0]);
assert.equal(selectionService.selectionText, 'ef⚽gh');
selectionService.selectWordAt([12, 0]);
assert.equal(selectionService.selectionText, 'ef⚽gh');
selectionService.selectWordAt([13, 0]);
assert.equal(selectionService.selectionText, 'ef⚽gh');
});
it('should treat complex emojis and characters joined together as a word', () => {
// This emoji is the flag for England and is made up of: 1F3F4 E0067 E0062 E0065 E006E E0067 E007F
buffer.lines.set(0, stringArrayToRow([
' ', '🏴', 'a', 'b', ' ', 'c', 'd', '🏴', ' ', 'e', 'f', '🏴', 'g', 'h', ' ', 'a'
])); // The a is here to prevent the space being trimmed in selectionText
selectionService.selectWordAt([0, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([1, 0]);
assert.equal(selectionService.selectionText, '🏴ab');
selectionService.selectWordAt([2, 0]);
assert.equal(selectionService.selectionText, '🏴ab');
selectionService.selectWordAt([3, 0]);
assert.equal(selectionService.selectionText, '🏴ab');
selectionService.selectWordAt([4, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([5, 0]);
assert.equal(selectionService.selectionText, 'cd🏴');
selectionService.selectWordAt([6, 0]);
assert.equal(selectionService.selectionText, 'cd🏴');
selectionService.selectWordAt([7, 0]);
assert.equal(selectionService.selectionText, 'cd🏴');
selectionService.selectWordAt([8, 0]);
assert.equal(selectionService.selectionText, ' ');
selectionService.selectWordAt([9, 0]);
assert.equal(selectionService.selectionText, 'ef🏴gh');
selectionService.selectWordAt([10, 0]);
assert.equal(selectionService.selectionText, 'ef🏴gh');
selectionService.selectWordAt([11, 0]);
assert.equal(selectionService.selectionText, 'ef🏴gh');
selectionService.selectWordAt([12, 0]);
assert.equal(selectionService.selectionText, 'ef🏴gh');
selectionService.selectWordAt([13, 0]);
assert.equal(selectionService.selectionText, 'ef🏴gh');
});
});
});
describe('_selectLineAt', () => {
it('should select the entire line', () => {
buffer.lines.set(0, stringToRow('foo bar'));
selectionService.selectLineAt(0);
assert.equal(selectionService.selectionText, 'foo bar', 'The selected text is correct');
assert.deepEqual(selectionService.model.selectionStart, [0, 0]);
assert.deepEqual(selectionService.model.selectionEnd, undefined);
assert.deepEqual(selectionService.model.selectionStartLength, 20);
assert.deepEqual(selectionService.model.finalSelectionStart, [0, 0]);
assert.deepEqual(selectionService.model.finalSelectionEnd, [bufferService.cols, 0], 'The actual selection spans the entire column');
});
it('should select the entire wrapped line', () => {
buffer.lines.set(0, stringToRow('foo'));
const line2 = stringToRow('bar');
buffer.lines.set(1, line2);
buffer.setWrapped(1, true);
selectionService.selectLineAt(0);
assert.equal(selectionService.selectionText, 'foobar', 'The selected text is correct');
assert.deepEqual(selectionService.model.selectionStart, [0, 0]);
assert.deepEqual(selectionService.model.selectionEnd, undefined);
assert.deepEqual(selectionService.model.selectionStartLength, 40);
assert.deepEqual(selectionService.model.finalSelectionStart, [0, 0]);
assert.deepEqual(selectionService.model.finalSelectionEnd, [bufferService.cols, 1], 'The actual selection spans the entire column');
});
});
describe('selectAll', () => {
it('should select the entire buffer, beyond the viewport', () => {
bufferService.resize(20, 5);
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
buffer.lines.set(3, stringToRow('4'));
buffer.lines.set(4, stringToRow('5'));
selectionService.selectAll();
assert.equal(selectionService.selectionText, '1\n2\n3\n4\n5');
});
});
describe('selectLines', () => {
it('should select a single line', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
selectionService.selectLines(1, 1);
assert.deepEqual(selectionService.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionService.model.finalSelectionEnd, [bufferService.cols, 1]);
});
it('should select multiple lines', () => {
buffer.lines.length = 5;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
buffer.lines.set(3, stringToRow('4'));
buffer.lines.set(4, stringToRow('5'));
selectionService.selectLines(1, 3);
assert.deepEqual(selectionService.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionService.model.finalSelectionEnd, [bufferService.cols, 3]);
});
it('should select the to the start when requesting a negative row', () => {
buffer.lines.length = 2;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
selectionService.selectLines(-1, 0);
assert.deepEqual(selectionService.model.finalSelectionStart, [0, 0]);
assert.deepEqual(selectionService.model.finalSelectionEnd, [bufferService.cols, 0]);
});
it('should select the to the end when requesting beyond the final row', () => {
buffer.lines.length = 2;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
selectionService.selectLines(1, 2);
assert.deepEqual(selectionService.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionService.model.finalSelectionEnd, [bufferService.cols, 1]);
});
});
describe('hasSelection', () => {
it('should return whether there is a selection', () => {
selectionService.model.selectionStart = [0, 0];
selectionService.model.selectionStartLength = 0;
assert.equal(selectionService.hasSelection, false);
selectionService.model.selectionEnd = [0, 0];
assert.equal(selectionService.hasSelection, false);
selectionService.model.selectionEnd = [1, 0];
assert.equal(selectionService.hasSelection, true);
selectionService.model.selectionEnd = [0, 1];
assert.equal(selectionService.hasSelection, true);
selectionService.model.selectionEnd = [1, 1];
assert.equal(selectionService.hasSelection, true);
});
});
describe('column selection', () => {
it('should select a column of text', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('abcdefghij'));
buffer.lines.set(1, stringToRow('klmnopqrst'));
buffer.lines.set(2, stringToRow('uvwxyz'));
selectionService.selectionMode = SelectionMode.COLUMN;
selectionService.model.selectionStart = [2, 0];
selectionService.model.selectionEnd = [4, 2];
assert.equal(selectionService.selectionText, 'cd\nmn\nwx');
});
it('should select a column of text without chopping up double width characters', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('a'));
buffer.lines.set(1, stringToRow('語'));
buffer.lines.set(2, stringToRow('b'));
selectionService.selectionMode = SelectionMode.COLUMN;
selectionService.model.selectionStart = [0, 0];
selectionService.model.selectionEnd = [1, 2];
assert.equal(selectionService.selectionText, 'a\n語\nb');
});
it('should select a column of text with single character emojis', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('a'));
buffer.lines.set(1, stringToRow('☃'));
buffer.lines.set(2, stringToRow('c'));
selectionService.selectionMode = SelectionMode.COLUMN;
selectionService.model.selectionStart = [0, 0];
selectionService.model.selectionEnd = [1, 2];
assert.equal(selectionService.selectionText, 'a\n☃\nc');
});
it('should select a column of text with double character emojis', () => {
// TODO the case this is testing works for me in the demo webapp,
// but doing it programmatically fails.
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('a '));
buffer.lines.set(1, stringArrayToRow(['😁', ' ']));
buffer.lines.set(2, stringToRow('c '));
selectionService.selectionMode = SelectionMode.COLUMN;
selectionService.model.selectionStart = [0, 0];
selectionService.model.selectionEnd = [1, 2];
assert.equal(selectionService.selectionText, 'a\n😁\nc');
});
});
describe('_areCoordsInSelection', () => {
it('should return whether coords are in the selection', () => {
assert.isFalse(selectionService.areCoordsInSelection([0, 0], [2, 0], [2, 1]));
assert.isFalse(selectionService.areCoordsInSelection([1, 0], [2, 0], [2, 1]));
assert.isTrue(selectionService.areCoordsInSelection([2, 0], [2, 0], [2, 1]));
assert.isTrue(selectionService.areCoordsInSelection([10, 0], [2, 0], [2, 1]));
assert.isTrue(selectionService.areCoordsInSelection([0, 1], [2, 0], [2, 1]));
assert.isTrue(selectionService.areCoordsInSelection([1, 1], [2, 0], [2, 1]));
assert.isFalse(selectionService.areCoordsInSelection([2, 1], [2, 0], [2, 1]));
});
});
});