forked from Silverquark/dance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-all.ts
1415 lines (1366 loc) · 57.9 KB
/
load-all.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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { CommandDescriptor, Commands } from ".";
import { ArgumentError, buildCommands, Context, Direction, EditorRequiredError, Shift } from "../api";
import { Register } from "../state/registers";
function getRegister<F extends Register.Flags | Register.Flags[]>(
_: Context.WithoutActiveEditor,
argument: { register?: string | Register },
defaultRegisterName: string,
requiredFlags: F extends readonly (infer Fs)[] ? Fs : F,
): Register.WithFlags<F> {
let register = argument.register;
const extension = _.extension;
if (typeof register === "string") {
if (register.startsWith(" ")) {
if (!(_ instanceof Context)) {
throw new EditorRequiredError();
}
register = extension.registers.forDocument(_.document).get(register.slice(1));
} else {
register = extension.registers.get(register);
}
} else if (!(register instanceof Register)) {
register = extension.registers.get(defaultRegisterName);
}
register.checkFlags(requiredFlags);
return (argument.register = register as any);
}
function getCount(_: Context.WithoutActiveEditor, argument: { count?: number }) {
const count = +(argument.count as any);
if (count >= 0 && Number.isInteger(count)) {
return count;
}
return (argument.count = 0);
}
function getRepetitions(_: Context.WithoutActiveEditor, argument: { count?: number }) {
const count = getCount(_, argument);
if (count <= 0) {
return 1;
}
return count;
}
function getDirection(argument: { direction?: number | string }) {
const direction = argument.direction;
if (direction === undefined) {
return undefined;
}
if (typeof direction === "number") {
if (direction === 1 || direction === -1) {
return direction as Direction;
}
} else if (typeof direction === "string") {
if (direction === "forward") {
return Direction.Forward;
}
if (direction === "backward") {
return Direction.Backward;
}
}
throw new ArgumentError(
'"direction" must be "forward", "backward", 1, -1, or undefined',
"direction",
);
}
function getShift(argument: { shift?: number | string }) {
const shift = argument.shift;
if (shift === undefined) {
return undefined;
}
if (typeof shift === "number") {
if (shift === 0 || shift === 1 || shift === 2) {
return shift as Shift;
}
} else if (typeof shift === "string") {
if (shift === "jump") {
return Shift.Jump;
}
if (shift === "select") {
return Shift.Select;
}
if (shift === "extend") {
return Shift.Extend;
}
}
throw new ArgumentError(
'"shift" must be "jump", "select", "extend", 0, 1, 2, or undefined',
"shift",
);
}
function getInputOr(argumentName: string, argument: Record<string, any>): any {
// TODO: remove fallback to deprecated "input" name.
const defaultInput = argument[argumentName] ?? argument["input"];
if (defaultInput != null) {
return () => defaultInput;
}
return (promptDefaultInput: () => any) => {
const result = promptDefaultInput();
if (typeof result.then === "function") {
return (result as Thenable<any>).then((x) => (argument[argumentName] = x));
}
return (argument[argumentName] = result);
};
}
function describeAdditionalCommand(
commands: Commands,
name: string,
flags: CommandDescriptor.Flags,
innerCommands: Parameters<typeof buildCommands>[0],
) {
const runCommand = buildCommands(innerCommands, { commands });
(commands as Record<string, CommandDescriptor>)[name] = new CommandDescriptor(
name,
(_, argument) => _.runAsync((_) => runCommand(argument, _)),
flags,
);
}
/* eslint-disable max-len */
/* eslint-disable no-useless-escape */
/* eslint-disable sort-imports */
//
// Content below this line was auto-generated by load-all.build.ts. Do not edit manually.
import {
copyLastErrorMessage as dev_copyLastErrorMessage,
setSelectionBehavior as dev_setSelectionBehavior,
} from "./dev";
import {
align as edit_align,
case_swap as edit_case_swap,
case_toLower as edit_case_toLower,
case_toUpper as edit_case_toUpper,
copyIndentation as edit_copyIndentation,
deindent as edit_deindent,
deindent_withIncomplete as edit_deindent_withIncomplete,
indent as edit_indent,
indent_withEmpty as edit_indent_withEmpty,
insert as edit_insert,
join as edit_join,
join_select as edit_join_select,
newLine_above as edit_newLine_above,
newLine_below as edit_newLine_below,
replaceCharacters as edit_replaceCharacters,
} from "./edit";
import {
recording_play as history_recording_play,
recording_start as history_recording_start,
recording_stop as history_recording_stop,
redo as history_redo,
redo_selections as history_redo_selections,
repeat as history_repeat,
repeat_edit as history_repeat_edit,
undo as history_undo,
undo_selections as history_undo_selections,
} from "./history";
import {
setup as keybindings_setup,
} from "./keybindings";
import {
surround as match_surround,
surrounddelete as match_surrounddelete,
surroundreplace as match_surroundreplace,
} from "./match";
import {
cancel as cancel,
changeInput as changeInput,
ifEmpty as ifEmpty,
ignore as ignore,
openMenu as openMenu,
run as run,
selectRegister as selectRegister,
updateCount as updateCount,
updateRegister as updateRegister,
} from "./misc";
import {
set as modes_set,
set_temporarily as modes_set_temporarily,
} from "./modes";
import {
next as search_next,
search as search,
selection as search_selection,
} from "./search";
import {
enclosing as seek_enclosing,
leap as seek_leap,
object as seek_object,
seek as seek,
word as seek_word,
} from "./seek";
import {
buffer as select_buffer,
firstVisibleLine as select_firstVisibleLine,
horizontally as select_horizontally,
lastLine as select_lastLine,
lastVisibleLine as select_lastVisibleLine,
lineEnd as select_lineEnd,
lineStart as select_lineStart,
line_above as select_line_above,
line_above_extend as select_line_above_extend,
line_below as select_line_below,
line_below_extend as select_line_below_extend,
middleVisibleLine as select_middleVisibleLine,
to as select_to,
vertically as select_vertically,
} from "./select";
import {
changeDirection as selections_changeDirection,
changeOrder as selections_changeOrder,
copy as selections_copy,
expandToLines as selections_expandToLines,
filter as selections_filter,
merge as selections_merge,
open as selections_open,
pipe as selections_pipe,
reduce as selections_reduce,
restore as selections_restore,
restore_withCurrent as selections_restore_withCurrent,
save as selections_save,
saveText as selections_saveText,
select as selections_select,
sort as selections_sort,
split as selections_split,
splitLines as selections_splitLines,
toggleIndices as selections_toggleIndices,
trimLines as selections_trimLines,
trimWhitespace as selections_trimWhitespace,
} from "./selections";
import {
both as selections_rotate_both,
contents as selections_rotate_contents,
selections as selections_rotate_selections,
} from "./selections.rotate";
import {
} from "./space";
import {
line as view_line,
} from "./view";
import {
} from "./window";
/**
* All defined Dance commands.
*/
export const commands: Commands = function () {
// Normal commands.
const commands = {
"dance.cancel": new CommandDescriptor(
"dance.cancel",
(_) => _.runAsync((_) => cancel(_.extension)),
CommandDescriptor.Flags.None,
),
"dance.changeInput": new CommandDescriptor(
"dance.changeInput",
(_, argument) => _.runAsync((_) => changeInput(argument["action"])),
CommandDescriptor.Flags.DoNotReplay,
),
"dance.dev.copyLastErrorMessage": new CommandDescriptor(
"dance.dev.copyLastErrorMessage",
(_) => _.runAsync((_) => dev_copyLastErrorMessage(_.extension)),
CommandDescriptor.Flags.None,
),
"dance.dev.setSelectionBehavior": new CommandDescriptor(
"dance.dev.setSelectionBehavior",
(_, argument) => _.runAsync((_) => dev_setSelectionBehavior(_, _.extension, argument["mode"], argument["value"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.align": new CommandDescriptor(
"dance.edit.align",
(_, argument) => _.runAsync((_) => edit_align(_, _.selections, argument["fill"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.case.swap": new CommandDescriptor(
"dance.edit.case.swap",
(_) => _.runAsync((_) => edit_case_swap(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.case.toLower": new CommandDescriptor(
"dance.edit.case.toLower",
(_) => _.runAsync((_) => edit_case_toLower(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.case.toUpper": new CommandDescriptor(
"dance.edit.case.toUpper",
(_) => _.runAsync((_) => edit_case_toUpper(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.copyIndentation": new CommandDescriptor(
"dance.edit.copyIndentation",
(_, argument) => _.runAsync((_) => edit_copyIndentation(_, _.document, _.selections, getCount(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.deindent": new CommandDescriptor(
"dance.edit.deindent",
(_, argument) => _.runAsync((_) => edit_deindent(_, getRepetitions(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.deindent.withIncomplete": new CommandDescriptor(
"dance.edit.deindent.withIncomplete",
(_, argument) => _.runAsync((_) => edit_deindent_withIncomplete(_, getRepetitions(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.indent": new CommandDescriptor(
"dance.edit.indent",
(_, argument) => _.runAsync((_) => edit_indent(_, getRepetitions(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.indent.withEmpty": new CommandDescriptor(
"dance.edit.indent.withEmpty",
(_, argument) => _.runAsync((_) => edit_indent_withEmpty(_, getRepetitions(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.insert": new CommandDescriptor(
"dance.edit.insert",
(_, argument) => _.runAsync((_) => edit_insert(_, _.selections, getRegister(_, argument, "dquote", Register.Flags.CanRead), argument["adjust"], argument["all"], argument["handleNewLine"], getRepetitions(_, argument), getShift(argument), argument["text"], argument["where"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.join": new CommandDescriptor(
"dance.edit.join",
(_, argument) => _.runAsync((_) => edit_join(_, argument["separator"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.join.select": new CommandDescriptor(
"dance.edit.join.select",
(_, argument) => _.runAsync((_) => edit_join_select(_, argument["separator"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.newLine.above": new CommandDescriptor(
"dance.edit.newLine.above",
(_, argument) => _.runAsync((_) => edit_newLine_above(_, getRepetitions(_, argument), getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.newLine.below": new CommandDescriptor(
"dance.edit.newLine.below",
(_, argument) => _.runAsync((_) => edit_newLine_below(_, getRepetitions(_, argument), getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.edit.replaceCharacters": new CommandDescriptor(
"dance.edit.replaceCharacters",
(_, argument) => _.runAsync((_) => edit_replaceCharacters(_, getRepetitions(_, argument), getInputOr("input", argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.history.recording.play": new CommandDescriptor(
"dance.history.recording.play",
(_, argument) => _.runAsync((_) => history_recording_play(_, getRepetitions(_, argument), getRegister(_, argument, "arobase", Register.Flags.CanReadWriteMacros))),
CommandDescriptor.Flags.DoNotReplay,
),
"dance.history.recording.start": new CommandDescriptor(
"dance.history.recording.start",
(_, argument) => _.runAsync((_) => history_recording_start(_, getRegister(_, argument, "arobase", Register.Flags.CanReadWriteMacros))),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.history.recording.stop": new CommandDescriptor(
"dance.history.recording.stop",
(_, argument) => _.runAsync((_) => history_recording_stop(_, getRegister(_, argument, "arobase", Register.Flags.CanReadWriteMacros))),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.history.redo": new CommandDescriptor(
"dance.history.redo",
(_) => _.runAsync((_) => history_redo()),
CommandDescriptor.Flags.None,
),
"dance.history.redo.selections": new CommandDescriptor(
"dance.history.redo.selections",
(_) => _.runAsync((_) => history_redo_selections()),
CommandDescriptor.Flags.None,
),
"dance.history.repeat": new CommandDescriptor(
"dance.history.repeat",
(_, argument) => _.runAsync((_) => history_repeat(_, getRepetitions(_, argument), argument["filter"])),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.history.repeat.edit": new CommandDescriptor(
"dance.history.repeat.edit",
(_, argument) => _.runAsync((_) => history_repeat_edit(_, getRepetitions(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.history.undo": new CommandDescriptor(
"dance.history.undo",
(_) => _.runAsync((_) => history_undo()),
CommandDescriptor.Flags.None,
),
"dance.history.undo.selections": new CommandDescriptor(
"dance.history.undo.selections",
(_) => _.runAsync((_) => history_undo_selections()),
CommandDescriptor.Flags.None,
),
"dance.ifEmpty": new CommandDescriptor(
"dance.ifEmpty",
(_, argument) => _.runAsync((_) => ifEmpty(_, argument, _.selections, argument["then"], argument["otherwise"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.ignore": new CommandDescriptor(
"dance.ignore",
(_) => _.runAsync((_) => ignore()),
CommandDescriptor.Flags.None,
),
"dance.keybindings.setup": new CommandDescriptor(
"dance.keybindings.setup",
(_, argument) => _.runAsync((_) => keybindings_setup(_, getRegister(_, argument, "dquote", Register.Flags.CanWrite))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.match.surround": new CommandDescriptor(
"dance.match.surround",
(_, argument) => _.runAsync((_) => match_surround(_, _.selections, getRegister(_, argument, "dquote", Register.Flags.CanRead), getInputOr("input", argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.match.surrounddelete": new CommandDescriptor(
"dance.match.surrounddelete",
(_, argument) => _.runAsync((_) => match_surrounddelete(_, getInputOr("input", argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.match.surroundreplace": new CommandDescriptor(
"dance.match.surroundreplace",
(_, argument) => _.runAsync((_) => match_surroundreplace(_, _.selections, getInputOr("input", argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.modes.set": new CommandDescriptor(
"dance.modes.set",
(_, argument) => _.runAsync((_) => modes_set(_, getInputOr("mode", argument))),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.modes.set.temporarily": new CommandDescriptor(
"dance.modes.set.temporarily",
(_, argument) => _.runAsync((_) => modes_set_temporarily(_, getInputOr("mode", argument), getRepetitions(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.openMenu": new CommandDescriptor(
"dance.openMenu",
(_, argument) => _.runAsync((_) => openMenu(_, getInputOr("menu", argument), argument["prefix"], argument["pass"], argument["locked"], argument["delay"], argument["title"])),
CommandDescriptor.Flags.DoNotReplay,
),
"dance.run": new CommandDescriptor(
"dance.run",
(_, argument) => _.runAsync((_) => run(_, argument, getInputOr("code", argument), getCount(_, argument), getRepetitions(_, argument), getRegister(_, argument, "null", Register.Flags.None), argument["commands"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.search": new CommandDescriptor(
"dance.search",
(_, argument) => _.runAsync((_) => search(_, getRegister<[Register.Flags.CanRead, Register.Flags.CanWrite]>(_, argument, "slash", Register.Flags.CanRead | Register.Flags.CanWrite), getRepetitions(_, argument), argument["add"], getDirection(argument), argument["interactive"], getShift(argument), argument)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.search.next": new CommandDescriptor(
"dance.search.next",
(_, argument) => _.runAsync((_) => search_next(_, _.document, getRegister(_, argument, "slash", Register.Flags.CanRead), getRepetitions(_, argument), argument["add"], getDirection(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.search.selection": new CommandDescriptor(
"dance.search.selection",
(_, argument) => _.runAsync((_) => search_selection(_.document, _.selections, getRegister(_, argument, "slash", Register.Flags.CanWrite), argument["smart"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.seek": new CommandDescriptor(
"dance.seek",
(_, argument) => _.runAsync((_) => seek(_, getInputOr("input", argument), getRepetitions(_, argument), getDirection(argument), getShift(argument), argument["include"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.seek.enclosing": new CommandDescriptor(
"dance.seek.enclosing",
(_, argument) => _.runAsync((_) => seek_enclosing(_, getDirection(argument), getShift(argument), argument["open"], argument["pairs"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.seek.leap": new CommandDescriptor(
"dance.seek.leap",
(_, argument) => _.runAsync((_) => seek_leap(_, getDirection(argument), argument["labels"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.seek.object": new CommandDescriptor(
"dance.seek.object",
(_, argument) => _.runAsync((_) => seek_object(_, getInputOr("input", argument), argument["inner"], argument["where"], getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.seek.word": new CommandDescriptor(
"dance.seek.word",
(_, argument) => _.runAsync((_) => seek_word(_, getRepetitions(_, argument), argument["stopAtEnd"], argument["ws"], getDirection(argument), getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.buffer": new CommandDescriptor(
"dance.select.buffer",
(_) => _.runAsync((_) => select_buffer(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.firstVisibleLine": new CommandDescriptor(
"dance.select.firstVisibleLine",
(_, argument) => _.runAsync((_) => select_firstVisibleLine(_, getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.horizontally": new CommandDescriptor(
"dance.select.horizontally",
(_, argument) => _.runAsync((_) => select_horizontally(_, argument["avoidEol"], getRepetitions(_, argument), getDirection(argument), getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.lastLine": new CommandDescriptor(
"dance.select.lastLine",
(_, argument) => _.runAsync((_) => select_lastLine(_, _.document, getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.lastVisibleLine": new CommandDescriptor(
"dance.select.lastVisibleLine",
(_, argument) => _.runAsync((_) => select_lastVisibleLine(_, getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.line.above": new CommandDescriptor(
"dance.select.line.above",
(_, argument) => _.runAsync((_) => select_line_above(_, getCount(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.line.above.extend": new CommandDescriptor(
"dance.select.line.above.extend",
(_, argument) => _.runAsync((_) => select_line_above_extend(_, getCount(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.line.below": new CommandDescriptor(
"dance.select.line.below",
(_, argument) => _.runAsync((_) => select_line_below(_, getCount(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.line.below.extend": new CommandDescriptor(
"dance.select.line.below.extend",
(_, argument) => _.runAsync((_) => select_line_below_extend(_, getCount(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.lineEnd": new CommandDescriptor(
"dance.select.lineEnd",
(_, argument) => _.runAsync((_) => select_lineEnd(_, getCount(_, argument), getShift(argument), argument["lineBreak"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.lineStart": new CommandDescriptor(
"dance.select.lineStart",
(_, argument) => _.runAsync((_) => select_lineStart(_, getCount(_, argument), getShift(argument), argument["skipBlank"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.middleVisibleLine": new CommandDescriptor(
"dance.select.middleVisibleLine",
(_, argument) => _.runAsync((_) => select_middleVisibleLine(_, getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.to": new CommandDescriptor(
"dance.select.to",
(_, argument) => _.runAsync((_) => select_to(_, getCount(_, argument), argument, getShift(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.select.vertically": new CommandDescriptor(
"dance.select.vertically",
(_, argument) => _.runAsync((_) => select_vertically(_, _.selections, argument["avoidEol"], getRepetitions(_, argument), getDirection(argument), getShift(argument), argument["by"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selectRegister": new CommandDescriptor(
"dance.selectRegister",
(_, argument) => _.runAsync((_) => selectRegister(_, getInputOr("register", argument))),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.selections.changeDirection": new CommandDescriptor(
"dance.selections.changeDirection",
(_, argument) => _.runAsync((_) => selections_changeDirection(_, getDirection(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.changeOrder": new CommandDescriptor(
"dance.selections.changeOrder",
(_, argument) => _.runAsync((_) => selections_changeOrder(_, _.selections.slice(), getDirection(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.copy": new CommandDescriptor(
"dance.selections.copy",
(_, argument) => _.runAsync((_) => selections_copy(_, _.document, _.selections, getRepetitions(_, argument), getDirection(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.expandToLines": new CommandDescriptor(
"dance.selections.expandToLines",
(_) => _.runAsync((_) => selections_expandToLines(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.filter": new CommandDescriptor(
"dance.selections.filter",
(_, argument) => _.runAsync((_) => selections_filter(_, argument, argument["defaultExpression"], argument["inverse"], argument["interactive"], getCount(_, argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.merge": new CommandDescriptor(
"dance.selections.merge",
(_) => _.runAsync((_) => selections_merge(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.open": new CommandDescriptor(
"dance.selections.open",
(_) => _.runAsync((_) => selections_open(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.pipe": new CommandDescriptor(
"dance.selections.pipe",
(_, argument) => _.runAsync((_) => selections_pipe(_, getRegister(_, argument, "pipe", Register.Flags.CanWrite), getInputOr("expression", argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.reduce": new CommandDescriptor(
"dance.selections.reduce",
(_, argument) => _.runAsync((_) => selections_reduce(_, argument["where"], argument["empty"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.restore": new CommandDescriptor(
"dance.selections.restore",
(_, argument) => _.runAsync((_) => selections_restore(_, getRegister(_, argument, "caret", Register.Flags.CanReadSelections))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.restore.withCurrent": new CommandDescriptor(
"dance.selections.restore.withCurrent",
(_, argument) => _.runAsync((_) => selections_restore_withCurrent(_, _.document, getRegister(_, argument, "caret", Register.Flags.CanReadSelections), argument["reverse"], argument["action"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.rotate.both": new CommandDescriptor(
"dance.selections.rotate.both",
(_, argument) => _.runAsync((_) => selections_rotate_both(_, getRepetitions(_, argument), argument["reverse"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.rotate.contents": new CommandDescriptor(
"dance.selections.rotate.contents",
(_, argument) => _.runAsync((_) => selections_rotate_contents(_, getRepetitions(_, argument), argument["reverse"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.rotate.selections": new CommandDescriptor(
"dance.selections.rotate.selections",
(_, argument) => _.runAsync((_) => selections_rotate_selections(_, getRepetitions(_, argument), argument["reverse"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.save": new CommandDescriptor(
"dance.selections.save",
(_, argument) => _.runAsync((_) => selections_save(_, _.document, _.selections, getRegister(_, argument, "caret", Register.Flags.CanWriteSelections), argument["style"], argument["until"], argument["untilDelay"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.saveText": new CommandDescriptor(
"dance.selections.saveText",
(_, argument) => _.runAsync((_) => selections_saveText(_.document, _.selections, getRegister(_, argument, "dquote", Register.Flags.CanWrite))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.select": new CommandDescriptor(
"dance.selections.select",
(_, argument) => _.runAsync((_) => selections_select(_, argument["interactive"], argument)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.sort": new CommandDescriptor(
"dance.selections.sort",
(_, argument) => _.runAsync((_) => selections_sort(_, getInputOr("expression", argument), getDirection(argument))),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.split": new CommandDescriptor(
"dance.selections.split",
(_, argument) => _.runAsync((_) => selections_split(_, argument["excludeEmpty"], argument["interactive"], argument)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.splitLines": new CommandDescriptor(
"dance.selections.splitLines",
(_, argument) => _.runAsync((_) => selections_splitLines(_, _.document, _.selections, getRepetitions(_, argument), argument["excludeEol"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.toggleIndices": new CommandDescriptor(
"dance.selections.toggleIndices",
(_, argument) => _.runAsync((_) => selections_toggleIndices(_, argument["display"], argument["until"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.trimLines": new CommandDescriptor(
"dance.selections.trimLines",
(_) => _.runAsync((_) => selections_trimLines(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.selections.trimWhitespace": new CommandDescriptor(
"dance.selections.trimWhitespace",
(_) => _.runAsync((_) => selections_trimWhitespace(_)),
CommandDescriptor.Flags.RequiresActiveEditor,
),
"dance.updateCount": new CommandDescriptor(
"dance.updateCount",
(_, argument) => _.runAsync((_) => updateCount(_, getCount(_, argument), _.extension, getInputOr("count", argument), argument["addDigits"])),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.updateRegister": new CommandDescriptor(
"dance.updateRegister",
(_, argument) => _.runAsync((_) => updateRegister(_, getRegister(_, argument, "dquote", Register.Flags.CanWrite), argument["copyFrom"], getInputOr("input", argument))),
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
),
"dance.view.line": new CommandDescriptor(
"dance.view.line",
(_, argument) => _.runAsync((_) => view_line(_, argument["at"])),
CommandDescriptor.Flags.RequiresActiveEditor,
),
};
// Additional commands.
describeAdditionalCommand(
commands,
"dance.edit.selectRegister-insert",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".selectRegister", { $include: ["register"] }], [".edit.insert", { $exclude: ["register"] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.paste.before",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { handleNewLine: true, where: "start", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.paste.after",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { handleNewLine: true, where: "end" , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.paste.before.select",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { handleNewLine: true, where: "start", shift: "select", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.paste.after.select",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { handleNewLine: true, where: "end" , shift: "select", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.pasteAll.before",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { handleNewLine: true, where: "start", all: true, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.pasteAll.after",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { handleNewLine: true, where: "end" , all: true, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.pasteAll.before.select",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { handleNewLine: true, where: "start", all: true, shift: "select", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.pasteAll.after.select",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { handleNewLine: true, where: "end" , all: true, shift: "select", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.delete",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".edit.insert", { register: "_", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.delete-insert",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".modes.set", { mode: "insert", $include: ["mode"] }], [".edit.insert", { register: "_", $exclude: ["mode"] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.yank-delete",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".selections.saveText", { $include: ["register"] }], [".edit.insert", { register: "_", $exclude: ["register"] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.yank-delete-insert",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".selections.saveText", { $include: ["register"] }], [".modes.set", { mode: "insert", $include: ["mode"] }], [".edit.insert", { register: "_", $exclude: ["register","mode"] }]],
);
describeAdditionalCommand(
commands,
"dance.edit.yank-replace",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".selections.saveText", { register: "tmp" }], [".edit.insert"], [".updateRegister", { copyFrom: "tmp", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.history.repeat.selection",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".history.repeat", { filter: "dance\\.(seek|select|selections)", $include: ["count"] }]],
);
describeAdditionalCommand(
commands,
"dance.history.repeat.seek",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".history.repeat", { filter: "dance\\.seek", $include: ["count"] }]],
);
describeAdditionalCommand(
commands,
"dance.modes.set.normal",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]],
);
describeAdditionalCommand(
commands,
"dance.modes.set.insert",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".modes.set", { mode: "insert" }]],
);
describeAdditionalCommand(
commands,
"dance.modes.set.visual",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".modes.set", { mode: "visual" }]],
);
describeAdditionalCommand(
commands,
"dance.modes.insert.lineStart",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".select.lineStart", { shift: "jump", skipBlank: true }], [".modes.set", { mode: "insert", $include: ["mode"] }], [".selections.reduce", { where: "start", record: false, empty: true, $exclude: ["mode"] }]],
);
describeAdditionalCommand(
commands,
"dance.modes.insert.lineEnd",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".select.lineEnd" , { shift: "jump" }], [".modes.set", { mode: "insert", $include: ["mode"] }], [".selections.reduce", { where: "end" , record: false, empty: true, $exclude: ["mode"] }]],
);
describeAdditionalCommand(
commands,
"dance.modes.set.temporarily.normal",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".modes.set.temporarily", { mode: "normal" }]],
);
describeAdditionalCommand(
commands,
"dance.modes.set.temporarily.insert",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".modes.set.temporarily", { mode: "insert" }]],
);
describeAdditionalCommand(
commands,
"dance.search.extend",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".search", { shift: "extend", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.search.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".search", { direction: -1 , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.search.backward.extend",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".search", { direction: -1, shift: "extend", $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.search.selection.smart",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".search.selection", { smart: true, $include: ["register"] }]],
);
describeAdditionalCommand(
commands,
"dance.search.next.add",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".search.next", { add: true, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.search.previous",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".search.next", { direction: -1 , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.search.previous.add",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".search.next", { direction: -1, add: true, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek", { direction: -1, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.included",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek", { include: true , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.included.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek", { include: true, direction: -1, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.extend",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek", { shift: "extend" , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.extend.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek", { shift: "extend", direction: -1, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.included.extend",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek", { include: true, shift: "extend" , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.included.extend.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek", { include: true, shift: "extend", direction: -1, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.enclosing.extend",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek.enclosing", { shift: "extend" , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.enclosing.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek.enclosing", { direction: -1, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.enclosing.extend.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek.enclosing", { shift: "extend", direction: -1, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.word.ws",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek.word", { ws: true , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.word.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek.word", { direction: -1, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.word.ws.backward",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek.word", { ws: true, direction: -1, $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.wordEnd",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek.word", { stopAtEnd: true , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.wordEnd.ws",
CommandDescriptor.Flags.RequiresActiveEditor | CommandDescriptor.Flags.DoNotReplay,
[[".seek.word", { stopAtEnd: true, ws: true , $exclude: [] }]],
);
describeAdditionalCommand(
commands,
"dance.seek.word.extend",