@lvce-editor/editor-worker 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/editorWorkerMain.js +98 -150
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/editorWorkerMain.js
CHANGED
|
@@ -561,6 +561,7 @@ const EmptyString = '';
|
|
|
561
561
|
const Space = ' ';
|
|
562
562
|
const Tab = '\t';
|
|
563
563
|
const Underline = '_';
|
|
564
|
+
const DoubleQuote$1 = '"';
|
|
564
565
|
const T = 't';
|
|
565
566
|
|
|
566
567
|
const getTabCount = string => {
|
|
@@ -642,9 +643,6 @@ const shouldNormalizeText = text => {
|
|
|
642
643
|
return text.includes(Tab);
|
|
643
644
|
};
|
|
644
645
|
|
|
645
|
-
// TODO visible selections could also be uint16array
|
|
646
|
-
// [top1, left1, width1, height1, top2, left2, width2, height2...]
|
|
647
|
-
|
|
648
646
|
const getX = (line, column, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference = 0) => {
|
|
649
647
|
if (!line) {
|
|
650
648
|
return 0;
|
|
@@ -2544,36 +2542,30 @@ const copy = async editor => {
|
|
|
2544
2542
|
// TODO handle multiline selection
|
|
2545
2543
|
// TODO handle multiple cursors
|
|
2546
2544
|
|
|
2547
|
-
// @ts-ignore
|
|
2548
2545
|
const copyLineDown = editor => {
|
|
2549
2546
|
const {
|
|
2550
|
-
selections
|
|
2551
|
-
primarySelectionIndex
|
|
2547
|
+
selections
|
|
2552
2548
|
} = editor;
|
|
2553
|
-
const rowIndex = selections[
|
|
2549
|
+
const rowIndex = selections[0];
|
|
2554
2550
|
number$1(rowIndex);
|
|
2555
2551
|
const position = {
|
|
2556
2552
|
rowIndex,
|
|
2557
2553
|
columnIndex: 0
|
|
2558
2554
|
};
|
|
2559
2555
|
const changes = [{
|
|
2560
|
-
inserted: [getLine(editor, rowIndex), ''],
|
|
2561
|
-
deleted: [''],
|
|
2562
2556
|
start: position,
|
|
2563
|
-
end: position
|
|
2557
|
+
end: position,
|
|
2558
|
+
inserted: [getLine(editor, rowIndex), ''],
|
|
2559
|
+
deleted: ['']
|
|
2564
2560
|
}];
|
|
2565
2561
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
2566
2562
|
};
|
|
2567
2563
|
|
|
2568
|
-
// @ts-ignore
|
|
2569
|
-
|
|
2570
|
-
// @ts-ignore
|
|
2571
2564
|
const copyLineUp = editor => {
|
|
2572
2565
|
const {
|
|
2573
|
-
selections
|
|
2574
|
-
primarySelectionIndex
|
|
2566
|
+
selections
|
|
2575
2567
|
} = editor;
|
|
2576
|
-
const rowIndex = selections[
|
|
2568
|
+
const rowIndex = selections[0];
|
|
2577
2569
|
const position = {
|
|
2578
2570
|
rowIndex: rowIndex,
|
|
2579
2571
|
columnIndex: 0
|
|
@@ -2671,7 +2663,6 @@ const editorCursorHorizontalLeft = (editor, getDelta) => {
|
|
|
2671
2663
|
return scheduleSelections(editor, newSelections);
|
|
2672
2664
|
};
|
|
2673
2665
|
|
|
2674
|
-
// @ts-ignore
|
|
2675
2666
|
const characterLeft = (line, columnIndex) => {
|
|
2676
2667
|
if (!supported()) {
|
|
2677
2668
|
return 1;
|
|
@@ -2683,8 +2674,6 @@ const characterLeft = (line, columnIndex) => {
|
|
|
2683
2674
|
const twoCharactersLeft = () => {
|
|
2684
2675
|
return 2;
|
|
2685
2676
|
};
|
|
2686
|
-
|
|
2687
|
-
// @ts-ignore
|
|
2688
2677
|
const characterRight = (line, columnIndex) => {
|
|
2689
2678
|
if (!supported()) {
|
|
2690
2679
|
return 1;
|
|
@@ -2693,13 +2682,9 @@ const characterRight = (line, columnIndex) => {
|
|
|
2693
2682
|
const next = segmenter.at(line, columnIndex);
|
|
2694
2683
|
return next.segment.length;
|
|
2695
2684
|
};
|
|
2696
|
-
|
|
2697
|
-
// @ts-ignore
|
|
2698
2685
|
const isWhitespace = char => {
|
|
2699
2686
|
return char === Space || char === Tab;
|
|
2700
2687
|
};
|
|
2701
|
-
|
|
2702
|
-
// @ts-ignore
|
|
2703
2688
|
const lineCharacterStart = (line, columnIndex) => {
|
|
2704
2689
|
if (line.length === 0) {
|
|
2705
2690
|
return 0;
|
|
@@ -2711,13 +2696,9 @@ const lineCharacterStart = (line, columnIndex) => {
|
|
|
2711
2696
|
}
|
|
2712
2697
|
return columnIndex;
|
|
2713
2698
|
};
|
|
2714
|
-
|
|
2715
|
-
// @ts-ignore
|
|
2716
2699
|
const lineEnd = (line, columnIndex) => {
|
|
2717
2700
|
return line.length - columnIndex;
|
|
2718
2701
|
};
|
|
2719
|
-
|
|
2720
|
-
// @ts-ignore
|
|
2721
2702
|
const tryRegexArray = (partialLine, regexArray) => {
|
|
2722
2703
|
for (const regex of regexArray) {
|
|
2723
2704
|
const match = partialLine.match(regex);
|
|
@@ -2742,8 +2723,6 @@ const wordLeft = (line, columnIndex) => {
|
|
|
2742
2723
|
const RE_WORD_RIGHT_1 = /^\s*[\u00C0-\u017F\w]+/i;
|
|
2743
2724
|
const RE_WORD_RIGHT_2 = /^[^a-zA-Z\d]+\w*/;
|
|
2744
2725
|
const RE_WORD_RIGHT = [RE_WORD_RIGHT_1, RE_WORD_RIGHT_2];
|
|
2745
|
-
|
|
2746
|
-
// @ts-ignore
|
|
2747
2726
|
const wordRight = (line, columnIndex) => {
|
|
2748
2727
|
const partialLine = line.slice(columnIndex);
|
|
2749
2728
|
return tryRegexArray(partialLine, RE_WORD_RIGHT);
|
|
@@ -2758,8 +2737,6 @@ const RE_PARTIAL_WORD_LEFT_7 = /(?<![A-Z])[A-Z]_+\s*$/;
|
|
|
2758
2737
|
const RE_PARTIAL_WORD_LEFT_8 = /[a-z]+\s*$/;
|
|
2759
2738
|
const RE_PARTIAL_WORD_LEFT_9 = /[^a-zA-Z\d\s]+\s*$/;
|
|
2760
2739
|
const RE_PARTIAL_WORD_LEFT = [RE_PARTIAL_WORD_LEFT_1, RE_PARTIAL_WORD_LEFT_2, RE_PARTIAL_WORD_LEFT_3, RE_PARTIAL_WORD_LEFT_4, RE_PARTIAL_WORD_LEFT_5, RE_PARTIAL_WORD_LEFT_6, RE_PARTIAL_WORD_LEFT_7, RE_PARTIAL_WORD_LEFT_8, RE_PARTIAL_WORD_LEFT_9];
|
|
2761
|
-
|
|
2762
|
-
// @ts-ignore
|
|
2763
2740
|
const wordPartLeft = (line, columnIndex) => {
|
|
2764
2741
|
const partialLine = line.slice(0, columnIndex);
|
|
2765
2742
|
return tryRegexArray(partialLine, RE_PARTIAL_WORD_LEFT);
|
|
@@ -2778,8 +2755,6 @@ const ARRAY_PARTIAL_WORD_RIGHT_1 = [RE_PARTIAL_WORD_RIGHT_1,
|
|
|
2778
2755
|
RE_PARTIAL_WORD_RIGHT_3, RE_PARTIAL_WORD_RIGHT_4, RE_PARTIAL_WORD_RIGHT_5, RE_PARTIAL_WORD_RIGHT_6];
|
|
2779
2756
|
const ARRAY_PARTIAL_WORD_RIGHT_2 = [RE_PARTIAL_WORD_RIGHT_1, RE_PARTIAL_WORD_RIGHT_2, RE_PARTIAL_WORD_RIGHT_3, RE_PARTIAL_WORD_RIGHT_4, RE_PARTIAL_WORD_RIGHT_5, RE_PARTIAL_WORD_RIGHT_6];
|
|
2780
2757
|
const RE_UPPERCASE = /[A-Z]/;
|
|
2781
|
-
|
|
2782
|
-
// @ts-ignore
|
|
2783
2758
|
const wordPartRight = (line, columnIndex) => {
|
|
2784
2759
|
const partialLine = line.slice(columnIndex);
|
|
2785
2760
|
// line[columnIndex]//?
|
|
@@ -2794,7 +2769,6 @@ const cursorCharacterLeft = editor => {
|
|
|
2794
2769
|
return editorCursorHorizontalLeft(editor, characterLeft);
|
|
2795
2770
|
};
|
|
2796
2771
|
|
|
2797
|
-
// @ts-ignore
|
|
2798
2772
|
const editorGetPositionRight = (position, lines, getDelta) => {
|
|
2799
2773
|
const rowIndex = position.rowIndex;
|
|
2800
2774
|
const columnIndex = position.columnIndex;
|
|
@@ -2813,8 +2787,6 @@ const editorGetPositionRight = (position, lines, getDelta) => {
|
|
|
2813
2787
|
columnIndex: columnIndex + delta
|
|
2814
2788
|
};
|
|
2815
2789
|
};
|
|
2816
|
-
|
|
2817
|
-
// @ts-ignore
|
|
2818
2790
|
const moveToPositionRight = (selections, i, rowIndex, columnIndex, lines, getDelta) => {
|
|
2819
2791
|
if (rowIndex >= lines.length) {
|
|
2820
2792
|
return;
|
|
@@ -2830,9 +2802,6 @@ const moveToPositionRight = (selections, i, rowIndex, columnIndex, lines, getDel
|
|
|
2830
2802
|
}
|
|
2831
2803
|
};
|
|
2832
2804
|
|
|
2833
|
-
// @ts-ignore
|
|
2834
|
-
|
|
2835
|
-
// @ts-ignore
|
|
2836
2805
|
const getNewSelections$a = (selections, lines, getDelta) => {
|
|
2837
2806
|
const newSelections = new Uint32Array(selections.length);
|
|
2838
2807
|
for (let i = 0; i < selections.length; i += 4) {
|
|
@@ -2846,8 +2815,6 @@ const getNewSelections$a = (selections, lines, getDelta) => {
|
|
|
2846
2815
|
}
|
|
2847
2816
|
return newSelections;
|
|
2848
2817
|
};
|
|
2849
|
-
|
|
2850
|
-
// @ts-ignore
|
|
2851
2818
|
const editorCursorHorizontalRight = (editor, getDelta) => {
|
|
2852
2819
|
const {
|
|
2853
2820
|
lines,
|
|
@@ -2904,16 +2871,9 @@ const getNewSelections$8 = selections => {
|
|
|
2904
2871
|
return map(selections, moveSelectionWithoutIntlSegmenter);
|
|
2905
2872
|
};
|
|
2906
2873
|
const cursorVertical = (editor, getPosition, getEdgePosition, delta) => {
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
// getPosition,
|
|
2911
|
-
// getEdgePosition,
|
|
2912
|
-
// delta
|
|
2913
|
-
// )
|
|
2914
|
-
// }
|
|
2915
|
-
const selections = editor.selections;
|
|
2916
|
-
// @ts-ignore
|
|
2874
|
+
const {
|
|
2875
|
+
selections
|
|
2876
|
+
} = editor;
|
|
2917
2877
|
const newSelections = getNewSelections$8(selections);
|
|
2918
2878
|
return scheduleSelections(editor, newSelections);
|
|
2919
2879
|
};
|
|
@@ -2940,7 +2900,6 @@ const cursorWordPartRight = editor => {
|
|
|
2940
2900
|
return editorCursorHorizontalRight(editor, wordPartRight);
|
|
2941
2901
|
};
|
|
2942
2902
|
|
|
2943
|
-
// @ts-ignore
|
|
2944
2903
|
const cursorWordRight = editor => {
|
|
2945
2904
|
return editorCursorHorizontalRight(editor, wordRight);
|
|
2946
2905
|
};
|
|
@@ -5204,22 +5163,39 @@ const editorSelectAllLeft = editor => {
|
|
|
5204
5163
|
editorSelectHorizontalLeft(editor, lineCharacterStart);
|
|
5205
5164
|
};
|
|
5206
5165
|
|
|
5207
|
-
|
|
5166
|
+
const RE_ALPHA_NUMERIC = /[a-zA-Z\d]/;
|
|
5167
|
+
const isAlphaNumeric = char => {
|
|
5168
|
+
return RE_ALPHA_NUMERIC.test(char);
|
|
5169
|
+
};
|
|
5208
5170
|
|
|
5209
|
-
const
|
|
5210
|
-
|
|
5211
|
-
|
|
5171
|
+
const getWordStartIndex = (line, index) => {
|
|
5172
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
5173
|
+
if (!isAlphaNumeric(line[i])) {
|
|
5174
|
+
return i + 1;
|
|
5175
|
+
}
|
|
5212
5176
|
}
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5177
|
+
return 0;
|
|
5178
|
+
};
|
|
5179
|
+
const getWordEndIndex = (line, index) => {
|
|
5180
|
+
for (let i = index; i < line.length; i++) {
|
|
5181
|
+
if (!isAlphaNumeric(line[i])) {
|
|
5182
|
+
return i;
|
|
5219
5183
|
}
|
|
5220
5184
|
}
|
|
5221
|
-
return
|
|
5185
|
+
return line.length - 1;
|
|
5186
|
+
};
|
|
5187
|
+
const getWordMatchAtPosition = (lines, rowIndex, columnIndex) => {
|
|
5188
|
+
const line = lines[rowIndex];
|
|
5189
|
+
const start = getWordStartIndex(line, columnIndex);
|
|
5190
|
+
const end = getWordEndIndex(line, columnIndex);
|
|
5191
|
+
const word = line.slice(start, end);
|
|
5192
|
+
return {
|
|
5193
|
+
start,
|
|
5194
|
+
end,
|
|
5195
|
+
word
|
|
5196
|
+
};
|
|
5222
5197
|
};
|
|
5198
|
+
|
|
5223
5199
|
const isMultiLineMatch = (lines, rowIndex, wordParts) => {
|
|
5224
5200
|
let j = 0;
|
|
5225
5201
|
if (!lines[rowIndex + j].endsWith(wordParts[j])) {
|
|
@@ -5230,14 +5206,29 @@ const isMultiLineMatch = (lines, rowIndex, wordParts) => {
|
|
|
5230
5206
|
return false;
|
|
5231
5207
|
}
|
|
5232
5208
|
}
|
|
5233
|
-
// j--
|
|
5234
5209
|
if (!lines[rowIndex + j].startsWith(wordParts[j])) {
|
|
5235
|
-
|
|
5236
5210
|
return false;
|
|
5237
5211
|
}
|
|
5238
5212
|
return true;
|
|
5239
5213
|
};
|
|
5240
5214
|
|
|
5215
|
+
// TODO handle virtual space
|
|
5216
|
+
|
|
5217
|
+
const getNewSelectionsSingleLineWord = (lines, word) => {
|
|
5218
|
+
if (word.length === 0) {
|
|
5219
|
+
throw new Error('word length must be greater than zero');
|
|
5220
|
+
}
|
|
5221
|
+
const newSelections = [];
|
|
5222
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5223
|
+
const line = lines[i];
|
|
5224
|
+
let columnIndex = -word.length;
|
|
5225
|
+
while ((columnIndex = line.indexOf(word, columnIndex + word.length)) !== -1) {
|
|
5226
|
+
newSelections.push(i, columnIndex, i, columnIndex + word.length);
|
|
5227
|
+
}
|
|
5228
|
+
}
|
|
5229
|
+
return new Uint32Array(newSelections);
|
|
5230
|
+
};
|
|
5231
|
+
|
|
5241
5232
|
// TODO this is very expensive, there might be a better algorithm for this
|
|
5242
5233
|
// TODO if this matches the given selections, don't schedule selections/rerender
|
|
5243
5234
|
const getAllOccurrencesMultiLine = (lines, wordParts) => {
|
|
@@ -5253,39 +5244,6 @@ const getAllOccurrencesMultiLine = (lines, wordParts) => {
|
|
|
5253
5244
|
}
|
|
5254
5245
|
return new Uint32Array(newSelections);
|
|
5255
5246
|
};
|
|
5256
|
-
|
|
5257
|
-
// TODO duplicate code with EditorSelectNextOccurrence
|
|
5258
|
-
const RE_ALPHA_NUMERIC$1 = /[a-zA-Z\d]/;
|
|
5259
|
-
const isAlphaNumeric$1 = char => {
|
|
5260
|
-
return RE_ALPHA_NUMERIC$1.test(char);
|
|
5261
|
-
};
|
|
5262
|
-
const getWordStartIndex$1 = (line, index) => {
|
|
5263
|
-
for (let i = index - 1; i >= 0; i--) {
|
|
5264
|
-
if (!isAlphaNumeric$1(line[i])) {
|
|
5265
|
-
return i + 1;
|
|
5266
|
-
}
|
|
5267
|
-
}
|
|
5268
|
-
return 0;
|
|
5269
|
-
};
|
|
5270
|
-
const getWordEndIndex$1 = (line, index) => {
|
|
5271
|
-
for (let i = index; i < line.length; i++) {
|
|
5272
|
-
if (!isAlphaNumeric$1(line[i])) {
|
|
5273
|
-
return i;
|
|
5274
|
-
}
|
|
5275
|
-
}
|
|
5276
|
-
return line.length - 1;
|
|
5277
|
-
};
|
|
5278
|
-
const getWordMatchAtPosition$1 = (lines, rowIndex, columnIndex) => {
|
|
5279
|
-
const line = lines[rowIndex];
|
|
5280
|
-
const start = getWordStartIndex$1(line, columnIndex);
|
|
5281
|
-
const end = getWordEndIndex$1(line, columnIndex);
|
|
5282
|
-
const word = line.slice(start, end);
|
|
5283
|
-
return {
|
|
5284
|
-
start,
|
|
5285
|
-
end,
|
|
5286
|
-
word
|
|
5287
|
-
};
|
|
5288
|
-
};
|
|
5289
5247
|
const getNewSelections$3 = (lines, selections) => {
|
|
5290
5248
|
if (selections.length < 4) {
|
|
5291
5249
|
throw new Error('selections must have at least one entry');
|
|
@@ -5297,7 +5255,7 @@ const getNewSelections$3 = (lines, selections) => {
|
|
|
5297
5255
|
const endColumnIndex = selections[firstSelectionIndex + 3];
|
|
5298
5256
|
if (startRowIndex === endRowIndex) {
|
|
5299
5257
|
if (startColumnIndex === endColumnIndex) {
|
|
5300
|
-
const wordMatch = getWordMatchAtPosition
|
|
5258
|
+
const wordMatch = getWordMatchAtPosition(lines, endRowIndex, endColumnIndex);
|
|
5301
5259
|
if (wordMatch.start === wordMatch.end) {
|
|
5302
5260
|
return selections;
|
|
5303
5261
|
}
|
|
@@ -5407,11 +5365,11 @@ const getNewSelections$1 = (lines, selections) => {
|
|
|
5407
5365
|
let startColumnIndex = selectionStartColumn;
|
|
5408
5366
|
let endColumnIndex = selectionEndColumn;
|
|
5409
5367
|
const line = lines[rowIndex];
|
|
5410
|
-
while (startColumnIndex > 0 && line[startColumnIndex] !==
|
|
5368
|
+
while (startColumnIndex > 0 && line[startColumnIndex] !== DoubleQuote$1) {
|
|
5411
5369
|
startColumnIndex--;
|
|
5412
5370
|
}
|
|
5413
5371
|
startColumnIndex++;
|
|
5414
|
-
while (endColumnIndex < line.length && line[endColumnIndex] !==
|
|
5372
|
+
while (endColumnIndex < line.length && line[endColumnIndex] !== DoubleQuote$1) {
|
|
5415
5373
|
endColumnIndex++;
|
|
5416
5374
|
}
|
|
5417
5375
|
newSelections[i] = rowIndex;
|
|
@@ -5434,9 +5392,26 @@ const selectInsideString = editor => {
|
|
|
5434
5392
|
return scheduleSelections(editor, newSelections);
|
|
5435
5393
|
};
|
|
5436
5394
|
|
|
5437
|
-
//
|
|
5395
|
+
// TODO handle virtual space
|
|
5396
|
+
|
|
5397
|
+
// TODO editors behave differently when selecting next occurrence, for example:
|
|
5398
|
+
|
|
5399
|
+
// aaa
|
|
5400
|
+
// bbb 1
|
|
5401
|
+
// ccc
|
|
5402
|
+
// bbb 2
|
|
5403
|
+
// bbb 3
|
|
5404
|
+
// aaa
|
|
5405
|
+
// bbb 4
|
|
5406
|
+
// ccc
|
|
5407
|
+
|
|
5408
|
+
// when clicking first at position 4 and then position 2,
|
|
5409
|
+
// - vscode selects next position 3 and refuses to select position 1
|
|
5410
|
+
// - atom also selects next position 3 and refuses to select position 1
|
|
5411
|
+
// - WebStorm also selects next position 3 and refuses to select position 1
|
|
5412
|
+
// - brackets (codemirror) selects position 3 and then selects position 1
|
|
5413
|
+
// - sublime selects next position 1, then next position 3
|
|
5438
5414
|
|
|
5439
|
-
// @ts-ignore
|
|
5440
5415
|
const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
5441
5416
|
const lastSelectionIndex = selections.length - 4;
|
|
5442
5417
|
const rowIndex = selections[lastSelectionIndex];
|
|
@@ -5515,48 +5490,6 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
|
5515
5490
|
}
|
|
5516
5491
|
return undefined;
|
|
5517
5492
|
};
|
|
5518
|
-
const RE_ALPHA_NUMERIC = /[a-zA-Z\d]/;
|
|
5519
|
-
|
|
5520
|
-
// @ts-ignore
|
|
5521
|
-
const isAlphaNumeric = char => {
|
|
5522
|
-
return RE_ALPHA_NUMERIC.test(char);
|
|
5523
|
-
};
|
|
5524
|
-
|
|
5525
|
-
// @ts-ignore
|
|
5526
|
-
const getWordStartIndex = (line, index) => {
|
|
5527
|
-
for (let i = index - 1; i >= 0; i--) {
|
|
5528
|
-
if (!isAlphaNumeric(line[i])) {
|
|
5529
|
-
return i + 1;
|
|
5530
|
-
}
|
|
5531
|
-
}
|
|
5532
|
-
return 0;
|
|
5533
|
-
};
|
|
5534
|
-
|
|
5535
|
-
// @ts-ignore
|
|
5536
|
-
const getWordEndIndex = (line, index) => {
|
|
5537
|
-
for (let i = index; i < line.length; i++) {
|
|
5538
|
-
if (!isAlphaNumeric(line[i])) {
|
|
5539
|
-
return i;
|
|
5540
|
-
}
|
|
5541
|
-
}
|
|
5542
|
-
return line.length - 1;
|
|
5543
|
-
};
|
|
5544
|
-
|
|
5545
|
-
// @ts-ignore
|
|
5546
|
-
const getWordMatchAtPosition = (lines, rowIndex, columnIndex) => {
|
|
5547
|
-
const line = lines[rowIndex];
|
|
5548
|
-
const index = columnIndex;
|
|
5549
|
-
const start = getWordStartIndex(line, index);
|
|
5550
|
-
const end = getWordEndIndex(line, index);
|
|
5551
|
-
const word = line.slice(start, end);
|
|
5552
|
-
return {
|
|
5553
|
-
start,
|
|
5554
|
-
end,
|
|
5555
|
-
word
|
|
5556
|
-
};
|
|
5557
|
-
};
|
|
5558
|
-
|
|
5559
|
-
// @ts-ignore
|
|
5560
5493
|
const getSelectNextOccurrenceResult = editor => {
|
|
5561
5494
|
const lines = editor.lines;
|
|
5562
5495
|
const selections = editor.selections;
|
|
@@ -5588,13 +5521,31 @@ const getSelectNextOccurrenceResult = editor => {
|
|
|
5588
5521
|
return undefined;
|
|
5589
5522
|
};
|
|
5590
5523
|
|
|
5591
|
-
//
|
|
5524
|
+
// TODO handle virtual space
|
|
5525
|
+
|
|
5526
|
+
// TODO editors behave differently when selecting next occurrence, for example:
|
|
5527
|
+
|
|
5528
|
+
// aaa
|
|
5529
|
+
// bbb 1
|
|
5530
|
+
// ccc
|
|
5531
|
+
// bbb 2
|
|
5532
|
+
// bbb 3
|
|
5533
|
+
// aaa
|
|
5534
|
+
// bbb 4
|
|
5535
|
+
// ccc
|
|
5536
|
+
|
|
5537
|
+
// when clicking first at position 4 and then position 2,
|
|
5538
|
+
// - vscode selects next position 3 and refuses to select position 1
|
|
5539
|
+
// - atom also selects next position 3 and refuses to select position 1
|
|
5540
|
+
// - WebStorm also selects next position 3 and refuses to select position 1
|
|
5541
|
+
// - brackets (codemirror) selects position 3 and then selects position 1
|
|
5542
|
+
// - sublime selects next position 1, then next position 3
|
|
5543
|
+
|
|
5592
5544
|
const isRangeInViewPort = (minLineY, maxLineY, startRowIndex, endRowIndex) => {
|
|
5593
5545
|
return startRowIndex >= minLineY && endRowIndex <= maxLineY;
|
|
5594
5546
|
};
|
|
5595
5547
|
|
|
5596
5548
|
// TODO handle virtual space
|
|
5597
|
-
// @ts-ignore
|
|
5598
5549
|
const selectNextOccurrence = editor => {
|
|
5599
5550
|
const result = getSelectNextOccurrenceResult(editor);
|
|
5600
5551
|
if (!result) {
|
|
@@ -5609,7 +5560,6 @@ const selectNextOccurrence = editor => {
|
|
|
5609
5560
|
}
|
|
5610
5561
|
// TODO what is this magic number 5?
|
|
5611
5562
|
// const deltaY = (revealRangeStartRowIndex - 5) * editor.rowHeight
|
|
5612
|
-
// @ts-ignore
|
|
5613
5563
|
return scheduleDocumentAndCursorsSelections(editor, [], selectionEdits);
|
|
5614
5564
|
};
|
|
5615
5565
|
|
|
@@ -6528,7 +6478,6 @@ const typeWithAutoClosing = async (editor, text) => {
|
|
|
6528
6478
|
// EditorCommandCompletion.openFromType(editor, text)
|
|
6529
6479
|
};
|
|
6530
6480
|
|
|
6531
|
-
// @ts-ignore
|
|
6532
6481
|
const inverseChange = edit => {
|
|
6533
6482
|
const endColumnIndex = edit.end.columnIndex - edit.deleted[0].length + edit.inserted[0].length;
|
|
6534
6483
|
return {
|
|
@@ -6542,7 +6491,6 @@ const inverseChange = edit => {
|
|
|
6542
6491
|
};
|
|
6543
6492
|
};
|
|
6544
6493
|
|
|
6545
|
-
// @ts-ignore
|
|
6546
6494
|
const undo = state => {
|
|
6547
6495
|
const {
|
|
6548
6496
|
undoStack
|