]> git.lizzy.rs Git - micro.git/blob - internal/buffer/buffer_generated_test.go
Add autoretab
[micro.git] / internal / buffer / buffer_generated_test.go
1 // This file is generated from VSCode model tests by the testgen tool.
2 // DO NOT EDIT THIS FILE BY HAND; your changes will be overwritten!
3
4 package buffer
5
6 import "testing"
7
8 func TestAuto1(t *testing.T) {
9         check(
10                 t,
11                 []string{
12                         "ioe",
13                         "",
14                         "yjct",
15                         "",
16                         "",
17                 },
18                 []operation{
19                         {
20                                 start: Loc{1, 0},
21                                 end:   Loc{1, 0},
22                                 text: []string{
23                                         "b",
24                                         "r",
25                                         "fq",
26                                 },
27                         },
28                         {
29                                 start: Loc{3, 0},
30                                 end:   Loc{0, 1},
31                                 text: []string{
32                                         "",
33                                         "",
34                                 },
35                         },
36                 },
37                 []string{
38                         "ib",
39                         "r",
40                         "fqoe",
41                         "",
42                         "yjct",
43                         "",
44                         "",
45                 },
46         )
47 }
48
49 func TestAuto2(t *testing.T) {
50         check(
51                 t,
52                 []string{
53                         "f",
54                         "littnhskrq",
55                         "utxvsizqnk",
56                         "lslqz",
57                         "jxn",
58                         "gmm",
59                 },
60                 []operation{
61                         {
62                                 start: Loc{1, 0},
63                                 end:   Loc{1, 0},
64                                 text: []string{
65                                         "",
66                                         "o",
67                                 },
68                         },
69                         {
70                                 start: Loc{3, 1},
71                                 end:   Loc{3, 1},
72                                 text: []string{
73                                         "zaq",
74                                         "avb",
75                                 },
76                         },
77                         {
78                                 start: Loc{4, 1},
79                                 end:   Loc{1, 5},
80                                 text: []string{
81                                         "jlr",
82                                         "zl",
83                                         "j",
84                                 },
85                         },
86                 },
87                 []string{
88                         "f",
89                         "o",
90                         "litzaq",
91                         "avbtjlr",
92                         "zl",
93                         "jmm",
94                 },
95         )
96 }
97
98 func TestAuto3(t *testing.T) {
99         check(
100                 t,
101                 []string{
102                         "ofw",
103                         "qsxmziuvzw",
104                         "rp",
105                         "qsnymek",
106                         "elth",
107                         "wmgzbwudxz",
108                         "iwsdkndh",
109                         "bujlbwb",
110                         "asuouxfv",
111                         "xuccnb",
112                 },
113                 []operation{
114                         {
115                                 start: Loc{2, 3},
116                                 end:   Loc{2, 3},
117                                 text: []string{
118                                         "",
119                                 },
120                         },
121                 },
122                 []string{
123                         "ofw",
124                         "qsxmziuvzw",
125                         "rp",
126                         "qsnymek",
127                         "elth",
128                         "wmgzbwudxz",
129                         "iwsdkndh",
130                         "bujlbwb",
131                         "asuouxfv",
132                         "xuccnb",
133                 },
134         )
135 }
136
137 func TestAuto4(t *testing.T) {
138         check(
139                 t,
140                 []string{
141                         "fefymj",
142                         "qum",
143                         "vmiwxxaiqq",
144                         "dz",
145                         "lnqdgorosf",
146                 },
147                 []operation{
148                         {
149                                 start: Loc{2, 0},
150                                 end:   Loc{4, 0},
151                                 text: []string{
152                                         "hp",
153                                 },
154                         },
155                         {
156                                 start: Loc{6, 0},
157                                 end:   Loc{0, 1},
158                                 text: []string{
159                                         "kcg",
160                                         "",
161                                         "mpx",
162                                 },
163                         },
164                         {
165                                 start: Loc{1, 1},
166                                 end:   Loc{1, 1},
167                                 text: []string{
168                                         "",
169                                         "aw",
170                                         "",
171                                 },
172                         },
173                         {
174                                 start: Loc{1, 1},
175                                 end:   Loc{1, 1},
176                                 text: []string{
177                                         "vqr",
178                                         "mo",
179                                 },
180                         },
181                         {
182                                 start: Loc{1, 3},
183                                 end:   Loc{2, 4},
184                                 text: []string{
185                                         "xyc",
186                                 },
187                         },
188                 },
189                 []string{
190                         "fehpmjkcg",
191                         "",
192                         "mpxq",
193                         "aw",
194                         "vqr",
195                         "moum",
196                         "vmiwxxaiqq",
197                         "dxycqdgorosf",
198                 },
199         )
200 }
201
202 func TestBug19872UndoIsFunky(t *testing.T) {
203         check(
204                 t,
205                 []string{
206                         "something",
207                         " A",
208                         "",
209                         " B",
210                         "something else",
211                 },
212                 []operation{
213                         {
214                                 start: Loc{0, 1},
215                                 end:   Loc{1, 1},
216                                 text: []string{
217                                         "",
218                                 },
219                         },
220                         {
221                                 start: Loc{0, 2},
222                                 end:   Loc{1, 3},
223                                 text: []string{
224                                         "",
225                                 },
226                         },
227                 },
228                 []string{
229                         "something",
230                         "A",
231                         "B",
232                         "something else",
233                 },
234         )
235 }
236
237 func TestBug19872UndoIsFunky_2(t *testing.T) {
238         check(
239                 t,
240                 []string{
241                         "something",
242                         "A",
243                         "B",
244                         "something else",
245                 },
246                 []operation{
247                         {
248                                 start: Loc{0, 1},
249                                 end:   Loc{0, 1},
250                                 text: []string{
251                                         " ",
252                                 },
253                         },
254                         {
255                                 start: Loc{0, 2},
256                                 end:   Loc{0, 2},
257                                 text: []string{
258                                         "",
259                                         " ",
260                                 },
261                         },
262                 },
263                 []string{
264                         "something",
265                         " A",
266                         "",
267                         " B",
268                         "something else",
269                 },
270         )
271 }
272
273 func TestInsertEmptyText(t *testing.T) {
274         check(
275                 t,
276                 []string{
277                         "My First Line",
278                         "\t\tMy Second Line",
279                         "    Third Line",
280                         "",
281                         "1",
282                 },
283                 []operation{
284                         {
285                                 start: Loc{0, 0},
286                                 end:   Loc{0, 0},
287                                 text: []string{
288                                         "",
289                                 },
290                         },
291                 },
292                 []string{
293                         "My First Line",
294                         "\t\tMy Second Line",
295                         "    Third Line",
296                         "",
297                         "1",
298                 },
299         )
300 }
301
302 func TestLastOpIsNoOp(t *testing.T) {
303         check(
304                 t,
305                 []string{
306                         "My First Line",
307                         "\t\tMy Second Line",
308                         "    Third Line",
309                         "",
310                         "1",
311                 },
312                 []operation{
313                         {
314                                 start: Loc{0, 0},
315                                 end:   Loc{1, 0},
316                                 text: []string{
317                                         "",
318                                 },
319                         },
320                         {
321                                 start: Loc{0, 3},
322                                 end:   Loc{0, 3},
323                                 text: []string{
324                                         "",
325                                 },
326                         },
327                 },
328                 []string{
329                         "y First Line",
330                         "\t\tMy Second Line",
331                         "    Third Line",
332                         "",
333                         "1",
334                 },
335         )
336 }
337
338 func TestInsertTextWithoutNewline1(t *testing.T) {
339         check(
340                 t,
341                 []string{
342                         "My First Line",
343                         "\t\tMy Second Line",
344                         "    Third Line",
345                         "",
346                         "1",
347                 },
348                 []operation{
349                         {
350                                 start: Loc{0, 0},
351                                 end:   Loc{0, 0},
352                                 text: []string{
353                                         "foo ",
354                                 },
355                         },
356                 },
357                 []string{
358                         "foo My First Line",
359                         "\t\tMy Second Line",
360                         "    Third Line",
361                         "",
362                         "1",
363                 },
364         )
365 }
366
367 func TestInsertTextWithoutNewline2(t *testing.T) {
368         check(
369                 t,
370                 []string{
371                         "My First Line",
372                         "\t\tMy Second Line",
373                         "    Third Line",
374                         "",
375                         "1",
376                 },
377                 []operation{
378                         {
379                                 start: Loc{2, 0},
380                                 end:   Loc{2, 0},
381                                 text: []string{
382                                         " foo",
383                                 },
384                         },
385                 },
386                 []string{
387                         "My foo First Line",
388                         "\t\tMy Second Line",
389                         "    Third Line",
390                         "",
391                         "1",
392                 },
393         )
394 }
395
396 func TestInsertOneNewline(t *testing.T) {
397         check(
398                 t,
399                 []string{
400                         "My First Line",
401                         "\t\tMy Second Line",
402                         "    Third Line",
403                         "",
404                         "1",
405                 },
406                 []operation{
407                         {
408                                 start: Loc{3, 0},
409                                 end:   Loc{3, 0},
410                                 text: []string{
411                                         "",
412                                         "",
413                                 },
414                         },
415                 },
416                 []string{
417                         "My ",
418                         "First Line",
419                         "\t\tMy Second Line",
420                         "    Third Line",
421                         "",
422                         "1",
423                 },
424         )
425 }
426
427 func TestInsertTextWithOneNewline(t *testing.T) {
428         check(
429                 t,
430                 []string{
431                         "My First Line",
432                         "\t\tMy Second Line",
433                         "    Third Line",
434                         "",
435                         "1",
436                 },
437                 []operation{
438                         {
439                                 start: Loc{2, 0},
440                                 end:   Loc{2, 0},
441                                 text: []string{
442                                         " new line",
443                                         "No longer",
444                                 },
445                         },
446                 },
447                 []string{
448                         "My new line",
449                         "No longer First Line",
450                         "\t\tMy Second Line",
451                         "    Third Line",
452                         "",
453                         "1",
454                 },
455         )
456 }
457
458 func TestInsertTextWithTwoNewlines(t *testing.T) {
459         check(
460                 t,
461                 []string{
462                         "My First Line",
463                         "\t\tMy Second Line",
464                         "    Third Line",
465                         "",
466                         "1",
467                 },
468                 []operation{
469                         {
470                                 start: Loc{2, 0},
471                                 end:   Loc{2, 0},
472                                 text: []string{
473                                         " new line",
474                                         "One more line in the middle",
475                                         "No longer",
476                                 },
477                         },
478                 },
479                 []string{
480                         "My new line",
481                         "One more line in the middle",
482                         "No longer First Line",
483                         "\t\tMy Second Line",
484                         "    Third Line",
485                         "",
486                         "1",
487                 },
488         )
489 }
490
491 func TestInsertTextWithManyNewlines(t *testing.T) {
492         check(
493                 t,
494                 []string{
495                         "My First Line",
496                         "\t\tMy Second Line",
497                         "    Third Line",
498                         "",
499                         "1",
500                 },
501                 []operation{
502                         {
503                                 start: Loc{2, 0},
504                                 end:   Loc{2, 0},
505                                 text: []string{
506                                         "",
507                                         "",
508                                         "",
509                                         "",
510                                         "",
511                                 },
512                         },
513                 },
514                 []string{
515                         "My",
516                         "",
517                         "",
518                         "",
519                         " First Line",
520                         "\t\tMy Second Line",
521                         "    Third Line",
522                         "",
523                         "1",
524                 },
525         )
526 }
527
528 func TestInsertMultipleNewlines(t *testing.T) {
529         check(
530                 t,
531                 []string{
532                         "My First Line",
533                         "\t\tMy Second Line",
534                         "    Third Line",
535                         "",
536                         "1",
537                 },
538                 []operation{
539                         {
540                                 start: Loc{2, 0},
541                                 end:   Loc{2, 0},
542                                 text: []string{
543                                         "",
544                                         "",
545                                         "",
546                                         "",
547                                         "",
548                                 },
549                         },
550                         {
551                                 start: Loc{14, 2},
552                                 end:   Loc{14, 2},
553                                 text: []string{
554                                         "a",
555                                         "b",
556                                 },
557                         },
558                 },
559                 []string{
560                         "My",
561                         "",
562                         "",
563                         "",
564                         " First Line",
565                         "\t\tMy Second Line",
566                         "    Third Linea",
567                         "b",
568                         "",
569                         "1",
570                 },
571         )
572 }
573
574 func TestDeleteEmptyText(t *testing.T) {
575         check(
576                 t,
577                 []string{
578                         "My First Line",
579                         "\t\tMy Second Line",
580                         "    Third Line",
581                         "",
582                         "1",
583                 },
584                 []operation{
585                         {
586                                 start: Loc{0, 0},
587                                 end:   Loc{0, 0},
588                                 text: []string{
589                                         "",
590                                 },
591                         },
592                 },
593                 []string{
594                         "My First Line",
595                         "\t\tMy Second Line",
596                         "    Third Line",
597                         "",
598                         "1",
599                 },
600         )
601 }
602
603 func TestDeleteTextFromOneLine(t *testing.T) {
604         check(
605                 t,
606                 []string{
607                         "My First Line",
608                         "\t\tMy Second Line",
609                         "    Third Line",
610                         "",
611                         "1",
612                 },
613                 []operation{
614                         {
615                                 start: Loc{0, 0},
616                                 end:   Loc{1, 0},
617                                 text: []string{
618                                         "",
619                                 },
620                         },
621                 },
622                 []string{
623                         "y First Line",
624                         "\t\tMy Second Line",
625                         "    Third Line",
626                         "",
627                         "1",
628                 },
629         )
630 }
631
632 func TestDeleteTextFromOneLine2(t *testing.T) {
633         check(
634                 t,
635                 []string{
636                         "My First Line",
637                         "\t\tMy Second Line",
638                         "    Third Line",
639                         "",
640                         "1",
641                 },
642                 []operation{
643                         {
644                                 start: Loc{0, 0},
645                                 end:   Loc{2, 0},
646                                 text: []string{
647                                         "a",
648                                 },
649                         },
650                 },
651                 []string{
652                         "a First Line",
653                         "\t\tMy Second Line",
654                         "    Third Line",
655                         "",
656                         "1",
657                 },
658         )
659 }
660
661 func TestDeleteAllTextFromALine(t *testing.T) {
662         check(
663                 t,
664                 []string{
665                         "My First Line",
666                         "\t\tMy Second Line",
667                         "    Third Line",
668                         "",
669                         "1",
670                 },
671                 []operation{
672                         {
673                                 start: Loc{0, 0},
674                                 end:   Loc{13, 0},
675                                 text: []string{
676                                         "",
677                                 },
678                         },
679                 },
680                 []string{
681                         "",
682                         "\t\tMy Second Line",
683                         "    Third Line",
684                         "",
685                         "1",
686                 },
687         )
688 }
689
690 func TestDeleteTextFromTwoLines(t *testing.T) {
691         check(
692                 t,
693                 []string{
694                         "My First Line",
695                         "\t\tMy Second Line",
696                         "    Third Line",
697                         "",
698                         "1",
699                 },
700                 []operation{
701                         {
702                                 start: Loc{3, 0},
703                                 end:   Loc{5, 1},
704                                 text: []string{
705                                         "",
706                                 },
707                         },
708                 },
709                 []string{
710                         "My Second Line",
711                         "    Third Line",
712                         "",
713                         "1",
714                 },
715         )
716 }
717
718 func TestDeleteTextFromManyLines(t *testing.T) {
719         check(
720                 t,
721                 []string{
722                         "My First Line",
723                         "\t\tMy Second Line",
724                         "    Third Line",
725                         "",
726                         "1",
727                 },
728                 []operation{
729                         {
730                                 start: Loc{3, 0},
731                                 end:   Loc{4, 2},
732                                 text: []string{
733                                         "",
734                                 },
735                         },
736                 },
737                 []string{
738                         "My Third Line",
739                         "",
740                         "1",
741                 },
742         )
743 }
744
745 func TestDeleteEverything(t *testing.T) {
746         check(
747                 t,
748                 []string{
749                         "My First Line",
750                         "\t\tMy Second Line",
751                         "    Third Line",
752                         "",
753                         "1",
754                 },
755                 []operation{
756                         {
757                                 start: Loc{0, 0},
758                                 end:   Loc{1, 4},
759                                 text: []string{
760                                         "",
761                                 },
762                         },
763                 },
764                 []string{
765                         "",
766                 },
767         )
768 }
769
770 func TestTwoUnrelatedEdits(t *testing.T) {
771         check(
772                 t,
773                 []string{
774                         "My First Line",
775                         "\t\tMy Second Line",
776                         "    Third Line",
777                         "",
778                         "123",
779                 },
780                 []operation{
781                         {
782                                 start: Loc{0, 1},
783                                 end:   Loc{2, 1},
784                                 text: []string{
785                                         "\t",
786                                 },
787                         },
788                         {
789                                 start: Loc{0, 2},
790                                 end:   Loc{4, 2},
791                                 text: []string{
792                                         "",
793                                 },
794                         },
795                 },
796                 []string{
797                         "My First Line",
798                         "\tMy Second Line",
799                         "Third Line",
800                         "",
801                         "123",
802                 },
803         )
804 }
805
806 func TestTwoEditsOnOneLine(t *testing.T) {
807         check(
808                 t,
809                 []string{
810                         "\t\tfirst\t    ",
811                         "\t\tsecond line",
812                         "\tthird line",
813                         "fourth line",
814                         "\t\t<!@#fifth#@!>\t\t",
815                 },
816                 []operation{
817                         {
818                                 start: Loc{2, 4},
819                                 end:   Loc{6, 4},
820                                 text: []string{
821                                         "",
822                                 },
823                         },
824                         {
825                                 start: Loc{11, 4},
826                                 end:   Loc{15, 4},
827                                 text: []string{
828                                         "",
829                                 },
830                         },
831                 },
832                 []string{
833                         "\t\tfirst\t    ",
834                         "\t\tsecond line",
835                         "\tthird line",
836                         "fourth line",
837                         "\t\tfifth\t\t",
838                 },
839         )
840 }
841
842 func TestManyEdits(t *testing.T) {
843         check(
844                 t,
845                 []string{
846                         "{\"x\" : 1}",
847                 },
848                 []operation{
849                         {
850                                 start: Loc{1, 0},
851                                 end:   Loc{1, 0},
852                                 text: []string{
853                                         "\n  ",
854                                 },
855                         },
856                         {
857                                 start: Loc{4, 0},
858                                 end:   Loc{5, 0},
859                                 text: []string{
860                                         "",
861                                 },
862                         },
863                         {
864                                 start: Loc{8, 0},
865                                 end:   Loc{8, 0},
866                                 text: []string{
867                                         "\n",
868                                 },
869                         },
870                 },
871                 []string{
872                         "{",
873                         "  \"x\": 1",
874                         "}",
875                 },
876         )
877 }
878
879 func TestManyEditsReversed(t *testing.T) {
880         check(
881                 t,
882                 []string{
883                         "{",
884                         "  \"x\": 1",
885                         "}",
886                 },
887                 []operation{
888                         {
889                                 start: Loc{1, 0},
890                                 end:   Loc{2, 1},
891                                 text: []string{
892                                         "",
893                                 },
894                         },
895                         {
896                                 start: Loc{5, 1},
897                                 end:   Loc{5, 1},
898                                 text: []string{
899                                         " ",
900                                 },
901                         },
902                         {
903                                 start: Loc{8, 1},
904                                 end:   Loc{0, 2},
905                                 text: []string{
906                                         "",
907                                 },
908                         },
909                 },
910                 []string{
911                         "{\"x\" : 1}",
912                 },
913         )
914 }
915
916 func TestReplacingNewlines1(t *testing.T) {
917         check(
918                 t,
919                 []string{
920                         "{",
921                         "\"a\": true,",
922                         "",
923                         "\"b\": true",
924                         "}",
925                 },
926                 []operation{
927                         {
928                                 start: Loc{1, 0},
929                                 end:   Loc{0, 1},
930                                 text: []string{
931                                         "",
932                                         "\t",
933                                 },
934                         },
935                         {
936                                 start: Loc{10, 1},
937                                 end:   Loc{0, 3},
938                                 text: []string{
939                                         "",
940                                         "\t",
941                                 },
942                         },
943                 },
944                 []string{
945                         "{",
946                         "\t\"a\": true,",
947                         "\t\"b\": true",
948                         "}",
949                 },
950         )
951 }
952
953 func TestReplacingNewlines2(t *testing.T) {
954         check(
955                 t,
956                 []string{
957                         "some text",
958                         "some more text",
959                         "now comes an empty line",
960                         "",
961                         "after empty line",
962                         "and the last line",
963                 },
964                 []operation{
965                         {
966                                 start: Loc{4, 0},
967                                 end:   Loc{0, 2},
968                                 text: []string{
969                                         " text",
970                                         "some more text",
971                                         "some more text",
972                                 },
973                         },
974                         {
975                                 start: Loc{1, 2},
976                                 end:   Loc{0, 3},
977                                 text: []string{
978                                         "o more lines",
979                                         "asd",
980                                         "asd",
981                                         "asd",
982                                 },
983                         },
984                         {
985                                 start: Loc{0, 4},
986                                 end:   Loc{5, 4},
987                                 text: []string{
988                                         "zzzzzzzz",
989                                 },
990                         },
991                         {
992                                 start: Loc{10, 4},
993                                 end:   Loc{15, 5},
994                                 text: []string{
995                                         "1",
996                                         "2",
997                                         "3",
998                                         "4",
999                                 },
1000                         },
1001                 },
1002                 []string{
1003                         "some text",
1004                         "some more text",
1005                         "some more textno more lines",
1006                         "asd",
1007                         "asd",
1008                         "asd",
1009                         "zzzzzzzz empt1",
1010                         "2",
1011                         "3",
1012                         "4ne",
1013                 },
1014         )
1015 }
1016
1017 func TestAdvanced1(t *testing.T) {
1018         check(
1019                 t,
1020                 []string{
1021                         " {       \"d\": [",
1022                         "             null",
1023                         "        ] /*comment*/",
1024                         "        ,\"e\": /*comment*/ [null] }",
1025                 },
1026                 []operation{
1027                         {
1028                                 start: Loc{0, 0},
1029                                 end:   Loc{1, 0},
1030                                 text: []string{
1031                                         "",
1032                                 },
1033                         },
1034                         {
1035                                 start: Loc{2, 0},
1036                                 end:   Loc{9, 0},
1037                                 text: []string{
1038                                         "",
1039                                         "  ",
1040                                 },
1041                         },
1042                         {
1043                                 start: Loc{15, 0},
1044                                 end:   Loc{13, 1},
1045                                 text: []string{
1046                                         "",
1047                                         "    ",
1048                                 },
1049                         },
1050                         {
1051                                 start: Loc{17, 1},
1052                                 end:   Loc{8, 2},
1053                                 text: []string{
1054                                         "",
1055                                         "  ",
1056                                 },
1057                         },
1058                         {
1059                                 start: Loc{21, 2},
1060                                 end:   Loc{8, 3},
1061                                 text: []string{
1062                                         "",
1063                                 },
1064                         },
1065                         {
1066                                 start: Loc{9, 3},
1067                                 end:   Loc{9, 3},
1068                                 text: []string{
1069                                         "",
1070                                         "  ",
1071                                 },
1072                         },
1073                         {
1074                                 start: Loc{27, 3},
1075                                 end:   Loc{27, 3},
1076                                 text: []string{
1077                                         "",
1078                                         "    ",
1079                                 },
1080                         },
1081                         {
1082                                 start: Loc{31, 3},
1083                                 end:   Loc{31, 3},
1084                                 text: []string{
1085                                         "",
1086                                         "  ",
1087                                 },
1088                         },
1089                         {
1090                                 start: Loc{32, 3},
1091                                 end:   Loc{33, 3},
1092                                 text: []string{
1093                                         "",
1094                                         "",
1095                                 },
1096                         },
1097                 },
1098                 []string{
1099                         "{",
1100                         "  \"d\": [",
1101                         "    null",
1102                         "  ] /*comment*/,",
1103                         "  \"e\": /*comment*/ [",
1104                         "    null",
1105                         "  ]",
1106                         "}",
1107                 },
1108         )
1109 }
1110
1111 func TestAdvancedSimplified(t *testing.T) {
1112         check(
1113                 t,
1114                 []string{
1115                         "   abc",
1116                         " ,def",
1117                 },
1118                 []operation{
1119                         {
1120                                 start: Loc{0, 0},
1121                                 end:   Loc{3, 0},
1122                                 text: []string{
1123                                         "",
1124                                 },
1125                         },
1126                         {
1127                                 start: Loc{6, 0},
1128                                 end:   Loc{1, 1},
1129                                 text: []string{
1130                                         "",
1131                                 },
1132                         },
1133                         {
1134                                 start: Loc{2, 1},
1135                                 end:   Loc{2, 1},
1136                                 text: []string{
1137                                         "",
1138                                         "",
1139                                 },
1140                         },
1141                 },
1142                 []string{
1143                         "abc,",
1144                         "def",
1145                 },
1146         )
1147 }
1148
1149 func TestIssue144(t *testing.T) {
1150         check(
1151                 t,
1152                 []string{
1153                         "package caddy",
1154                         "",
1155                         "func main() {",
1156                         "\tfmt.Println(\"Hello World! :)\")",
1157                         "}",
1158                         "",
1159                 },
1160                 []operation{
1161                         {
1162                                 start: Loc{0, 0},
1163                                 end:   Loc{0, 5},
1164                                 text: []string{
1165                                         "package caddy",
1166                                         "",
1167                                         "import \"fmt\"",
1168                                         "",
1169                                         "func main() {",
1170                                         "\tfmt.Println(\"Hello World! :)\")",
1171                                         "}",
1172                                         "",
1173                                 },
1174                         },
1175                 },
1176                 []string{
1177                         "package caddy",
1178                         "",
1179                         "import \"fmt\"",
1180                         "",
1181                         "func main() {",
1182                         "\tfmt.Println(\"Hello World! :)\")",
1183                         "}",
1184                         "",
1185                 },
1186         )
1187 }
1188
1189 func TestIssue2586ReplacingSelectedEndOfLineWithNewlineLocksUpTheDocument(t *testing.T) {
1190         check(
1191                 t,
1192                 []string{
1193                         "something",
1194                         "interesting",
1195                 },
1196                 []operation{
1197                         {
1198                                 start: Loc{9, 0},
1199                                 end:   Loc{0, 1},
1200                                 text: []string{
1201                                         "",
1202                                         "",
1203                                 },
1204                         },
1205                 },
1206                 []string{
1207                         "something",
1208                         "interesting",
1209                 },
1210         )
1211 }
1212
1213 func TestIssue3980(t *testing.T) {
1214         check(
1215                 t,
1216                 []string{
1217                         "class A {",
1218                         "    someProperty = false;",
1219                         "    someMethod() {",
1220                         "    this.someMethod();",
1221                         "    }",
1222                         "}",
1223                 },
1224                 []operation{
1225                         {
1226                                 start: Loc{7, 0},
1227                                 end:   Loc{8, 0},
1228                                 text: []string{
1229                                         "",
1230                                         "",
1231                                 },
1232                         },
1233                         {
1234                                 start: Loc{16, 2},
1235                                 end:   Loc{17, 2},
1236                                 text: []string{
1237                                         "",
1238                                         "",
1239                                 },
1240                         },
1241                         {
1242                                 start: Loc{17, 2},
1243                                 end:   Loc{17, 2},
1244                                 text: []string{
1245                                         "    ",
1246                                 },
1247                         },
1248                         {
1249                                 start: Loc{4, 3},
1250                                 end:   Loc{4, 3},
1251                                 text: []string{
1252                                         "    ",
1253                                 },
1254                         },
1255                 },
1256                 []string{
1257                         "class A",
1258                         "{",
1259                         "    someProperty = false;",
1260                         "    someMethod()",
1261                         "    {",
1262                         "        this.someMethod();",
1263                         "    }",
1264                         "}",
1265                 },
1266         )
1267 }
1268
1269 func TestTouchingEditsTwoInsertsAtTheSamePosition(t *testing.T) {
1270         check(
1271                 t,
1272                 []string{
1273                         "hello world",
1274                 },
1275                 []operation{
1276                         {
1277                                 start: Loc{0, 0},
1278                                 end:   Loc{0, 0},
1279                                 text: []string{
1280                                         "a",
1281                                 },
1282                         },
1283                         {
1284                                 start: Loc{0, 0},
1285                                 end:   Loc{0, 0},
1286                                 text: []string{
1287                                         "b",
1288                                 },
1289                         },
1290                 },
1291                 []string{
1292                         "abhello world",
1293                 },
1294         )
1295 }
1296
1297 func TestTouchingEditsInsertAndReplaceTouching(t *testing.T) {
1298         check(
1299                 t,
1300                 []string{
1301                         "hello world",
1302                 },
1303                 []operation{
1304                         {
1305                                 start: Loc{0, 0},
1306                                 end:   Loc{0, 0},
1307                                 text: []string{
1308                                         "b",
1309                                 },
1310                         },
1311                         {
1312                                 start: Loc{0, 0},
1313                                 end:   Loc{2, 0},
1314                                 text: []string{
1315                                         "ab",
1316                                 },
1317                         },
1318                 },
1319                 []string{
1320                         "babllo world",
1321                 },
1322         )
1323 }
1324
1325 func TestTouchingEditsTwoTouchingReplaces(t *testing.T) {
1326         check(
1327                 t,
1328                 []string{
1329                         "hello world",
1330                 },
1331                 []operation{
1332                         {
1333                                 start: Loc{0, 0},
1334                                 end:   Loc{1, 0},
1335                                 text: []string{
1336                                         "H",
1337                                 },
1338                         },
1339                         {
1340                                 start: Loc{1, 0},
1341                                 end:   Loc{2, 0},
1342                                 text: []string{
1343                                         "E",
1344                                 },
1345                         },
1346                 },
1347                 []string{
1348                         "HEllo world",
1349                 },
1350         )
1351 }
1352
1353 func TestTouchingEditsTwoTouchingDeletes(t *testing.T) {
1354         check(
1355                 t,
1356                 []string{
1357                         "hello world",
1358                 },
1359                 []operation{
1360                         {
1361                                 start: Loc{0, 0},
1362                                 end:   Loc{1, 0},
1363                                 text: []string{
1364                                         "",
1365                                 },
1366                         },
1367                         {
1368                                 start: Loc{1, 0},
1369                                 end:   Loc{2, 0},
1370                                 text: []string{
1371                                         "",
1372                                 },
1373                         },
1374                 },
1375                 []string{
1376                         "llo world",
1377                 },
1378         )
1379 }
1380
1381 func TestTouchingEditsInsertAndReplace(t *testing.T) {
1382         check(
1383                 t,
1384                 []string{
1385                         "hello world",
1386                 },
1387                 []operation{
1388                         {
1389                                 start: Loc{0, 0},
1390                                 end:   Loc{0, 0},
1391                                 text: []string{
1392                                         "H",
1393                                 },
1394                         },
1395                         {
1396                                 start: Loc{0, 0},
1397                                 end:   Loc{2, 0},
1398                                 text: []string{
1399                                         "e",
1400                                 },
1401                         },
1402                 },
1403                 []string{
1404                         "Hello world",
1405                 },
1406         )
1407 }
1408
1409 func TestTouchingEditsReplaceAndInsert(t *testing.T) {
1410         check(
1411                 t,
1412                 []string{
1413                         "hello world",
1414                 },
1415                 []operation{
1416                         {
1417                                 start: Loc{0, 0},
1418                                 end:   Loc{2, 0},
1419                                 text: []string{
1420                                         "H",
1421                                 },
1422                         },
1423                         {
1424                                 start: Loc{2, 0},
1425                                 end:   Loc{2, 0},
1426                                 text: []string{
1427                                         "e",
1428                                 },
1429                         },
1430                 },
1431                 []string{
1432                         "Hello world",
1433                 },
1434         )
1435 }
1436
1437 func TestSingleDelete1(t *testing.T) {
1438         check(
1439                 t,
1440                 []string{
1441                         "hello world",
1442                 },
1443                 []operation{
1444                         {
1445                                 start: Loc{0, 0},
1446                                 end:   Loc{1, 0},
1447                                 text: []string{
1448                                         "",
1449                                 },
1450                         },
1451                 },
1452                 []string{
1453                         "ello world",
1454                 },
1455         )
1456 }
1457
1458 func TestSingleDelete2(t *testing.T) {
1459         check(
1460                 t,
1461                 []string{
1462                         "helloworld",
1463                 },
1464                 []operation{
1465                         {
1466                                 start: Loc{2, 0},
1467                                 end:   Loc{7, 0},
1468                                 text: []string{
1469                                         "",
1470                                 },
1471                         },
1472                 },
1473                 []string{
1474                         "herld",
1475                 },
1476         )
1477 }
1478
1479 func TestSingleDelete3(t *testing.T) {
1480         check(
1481                 t,
1482                 []string{
1483                         "hello world",
1484                 },
1485                 []operation{
1486                         {
1487                                 start: Loc{0, 0},
1488                                 end:   Loc{5, 0},
1489                                 text: []string{
1490                                         "",
1491                                 },
1492                         },
1493                 },
1494                 []string{
1495                         " world",
1496                 },
1497         )
1498 }
1499
1500 func TestSingleDelete4(t *testing.T) {
1501         check(
1502                 t,
1503                 []string{
1504                         "hello world",
1505                 },
1506                 []operation{
1507                         {
1508                                 start: Loc{1, 0},
1509                                 end:   Loc{6, 0},
1510                                 text: []string{
1511                                         "",
1512                                 },
1513                         },
1514                 },
1515                 []string{
1516                         "hworld",
1517                 },
1518         )
1519 }
1520
1521 func TestSingleDelete5(t *testing.T) {
1522         check(
1523                 t,
1524                 []string{
1525                         "hello world",
1526                 },
1527                 []operation{
1528                         {
1529                                 start: Loc{0, 0},
1530                                 end:   Loc{11, 0},
1531                                 text: []string{
1532                                         "",
1533                                 },
1534                         },
1535                 },
1536                 []string{
1537                         "",
1538                 },
1539         )
1540 }
1541
1542 func TestMultiDelete6(t *testing.T) {
1543         check(
1544                 t,
1545                 []string{
1546                         "hello world",
1547                         "hello world",
1548                         "hello world",
1549                 },
1550                 []operation{
1551                         {
1552                                 start: Loc{5, 0},
1553                                 end:   Loc{5, 2},
1554                                 text: []string{
1555                                         "",
1556                                 },
1557                         },
1558                 },
1559                 []string{
1560                         "hello world",
1561                 },
1562         )
1563 }
1564
1565 func TestMultiDelete7(t *testing.T) {
1566         check(
1567                 t,
1568                 []string{
1569                         "hello world",
1570                         "hello world",
1571                         "hello world",
1572                 },
1573                 []operation{
1574                         {
1575                                 start: Loc{11, 0},
1576                                 end:   Loc{11, 2},
1577                                 text: []string{
1578                                         "",
1579                                 },
1580                         },
1581                 },
1582                 []string{
1583                         "hello world",
1584                 },
1585         )
1586 }
1587
1588 func TestMultiDelete8(t *testing.T) {
1589         check(
1590                 t,
1591                 []string{
1592                         "hello world",
1593                         "hello world",
1594                         "hello world",
1595                 },
1596                 []operation{
1597                         {
1598                                 start: Loc{0, 0},
1599                                 end:   Loc{0, 2},
1600                                 text: []string{
1601                                         "",
1602                                 },
1603                         },
1604                 },
1605                 []string{
1606                         "hello world",
1607                 },
1608         )
1609 }
1610
1611 func TestMultiDelete9(t *testing.T) {
1612         check(
1613                 t,
1614                 []string{
1615                         "hello world",
1616                         "hello world",
1617                         "hello world",
1618                 },
1619                 []operation{
1620                         {
1621                                 start: Loc{11, 0},
1622                                 end:   Loc{0, 2},
1623                                 text: []string{
1624                                         "",
1625                                 },
1626                         },
1627                 },
1628                 []string{
1629                         "hello worldhello world",
1630                 },
1631         )
1632 }
1633
1634 func TestSingleInsert1(t *testing.T) {
1635         check(
1636                 t,
1637                 []string{
1638                         "hello world",
1639                 },
1640                 []operation{
1641                         {
1642                                 start: Loc{0, 0},
1643                                 end:   Loc{0, 0},
1644                                 text: []string{
1645                                         "xx",
1646                                 },
1647                         },
1648                 },
1649                 []string{
1650                         "xxhello world",
1651                 },
1652         )
1653 }
1654
1655 func TestSingleInsert2(t *testing.T) {
1656         check(
1657                 t,
1658                 []string{
1659                         "hello world",
1660                 },
1661                 []operation{
1662                         {
1663                                 start: Loc{1, 0},
1664                                 end:   Loc{1, 0},
1665                                 text: []string{
1666                                         "xx",
1667                                 },
1668                         },
1669                 },
1670                 []string{
1671                         "hxxello world",
1672                 },
1673         )
1674 }
1675
1676 func TestSingleInsert3(t *testing.T) {
1677         check(
1678                 t,
1679                 []string{
1680                         "hello world",
1681                 },
1682                 []operation{
1683                         {
1684                                 start: Loc{5, 0},
1685                                 end:   Loc{5, 0},
1686                                 text: []string{
1687                                         "xx",
1688                                 },
1689                         },
1690                 },
1691                 []string{
1692                         "helloxx world",
1693                 },
1694         )
1695 }
1696
1697 func TestSingleInsert4(t *testing.T) {
1698         check(
1699                 t,
1700                 []string{
1701                         "hello world",
1702                 },
1703                 []operation{
1704                         {
1705                                 start: Loc{6, 0},
1706                                 end:   Loc{6, 0},
1707                                 text: []string{
1708                                         "xx",
1709                                 },
1710                         },
1711                 },
1712                 []string{
1713                         "hello xxworld",
1714                 },
1715         )
1716 }
1717
1718 func TestSingleInsert5(t *testing.T) {
1719         check(
1720                 t,
1721                 []string{
1722                         "hello world",
1723                 },
1724                 []operation{
1725                         {
1726                                 start: Loc{11, 0},
1727                                 end:   Loc{11, 0},
1728                                 text: []string{
1729                                         "xx",
1730                                 },
1731                         },
1732                 },
1733                 []string{
1734                         "hello worldxx",
1735                 },
1736         )
1737 }
1738
1739 func TestMultiInsert6(t *testing.T) {
1740         check(
1741                 t,
1742                 []string{
1743                         "hello world",
1744                 },
1745                 []operation{
1746                         {
1747                                 start: Loc{0, 0},
1748                                 end:   Loc{0, 0},
1749                                 text: []string{
1750                                         "\n",
1751                                 },
1752                         },
1753                 },
1754                 []string{
1755                         "",
1756                         "hello world",
1757                 },
1758         )
1759 }
1760
1761 func TestMultiInsert7(t *testing.T) {
1762         check(
1763                 t,
1764                 []string{
1765                         "hello world",
1766                 },
1767                 []operation{
1768                         {
1769                                 start: Loc{11, 0},
1770                                 end:   Loc{11, 0},
1771                                 text: []string{
1772                                         "\n",
1773                                 },
1774                         },
1775                 },
1776                 []string{
1777                         "hello world",
1778                         "",
1779                 },
1780         )
1781 }
1782
1783 func TestMultiInsert8(t *testing.T) {
1784         check(
1785                 t,
1786                 []string{
1787                         "hello world",
1788                 },
1789                 []operation{
1790                         {
1791                                 start: Loc{6, 0},
1792                                 end:   Loc{6, 0},
1793                                 text: []string{
1794                                         "\n",
1795                                 },
1796                         },
1797                 },
1798                 []string{
1799                         "hello ",
1800                         "world",
1801                 },
1802         )
1803 }
1804
1805 func TestMultiInsert9(t *testing.T) {
1806         check(
1807                 t,
1808                 []string{
1809                         "hello world",
1810                         "hello world",
1811                 },
1812                 []operation{
1813                         {
1814                                 start: Loc{6, 0},
1815                                 end:   Loc{6, 0},
1816                                 text: []string{
1817                                         "xx\nyy",
1818                                 },
1819                         },
1820                 },
1821                 []string{
1822                         "hello xx",
1823                         "yyworld",
1824                         "hello world",
1825                 },
1826         )
1827 }