@@ -645,6 +645,42 @@ func testBuffer(v *Nvim) func(*testing.T) {
645
645
t .Fatalf ("expected buffer is valid but got %t" , valid )
646
646
}
647
647
})
648
+
649
+ t .Run ("BufferMark" , func (t * testing.T ) {
650
+ lines := [][]byte {
651
+ []byte ("a" ),
652
+ []byte ("bit of" ),
653
+ []byte ("text" ),
654
+ }
655
+ if err := v .SetBufferLines (Buffer (0 ), - 1 , - 1 , true , lines ); err != nil {
656
+ t .Fatal (err )
657
+ }
658
+ if err := v .SetWindowCursor (Window (0 ), [2 ]int {3 , 4 }); err != nil {
659
+ t .Fatal (err )
660
+ }
661
+ if err := v .Command ("mark v" ); err != nil {
662
+ t .Fatal (err )
663
+ }
664
+
665
+ const (
666
+ wantLine = 3
667
+ wantCol = 0
668
+ )
669
+ pos , err := v .BufferMark (Buffer (0 ), "v" )
670
+ if err != nil {
671
+ t .Fatal (err )
672
+ }
673
+ if pos [0 ] != wantLine {
674
+ t .Fatalf ("got %d extMark line but want %d" , pos [0 ], wantLine )
675
+ }
676
+ if pos [1 ] != wantCol {
677
+ t .Fatalf ("got %d extMark col but want %d" , pos [1 ], wantCol )
678
+ }
679
+
680
+ t .Cleanup (func () {
681
+ clearBuffer (t , v , Buffer (0 ))
682
+ })
683
+ })
648
684
})
649
685
650
686
t .Run ("Batch" , func (t * testing.T ) {
@@ -903,6 +939,45 @@ func testBuffer(v *Nvim) func(*testing.T) {
903
939
t .Fatalf ("expected buffer is valid but got %t" , valid )
904
940
}
905
941
})
942
+
943
+ t .Run ("BufferMark" , func (t * testing.T ) {
944
+ b := v .NewBatch ()
945
+
946
+ lines := [][]byte {
947
+ []byte ("a" ),
948
+ []byte ("bit of" ),
949
+ []byte ("text" ),
950
+ }
951
+ b .SetBufferLines (Buffer (0 ), - 1 , - 1 , true , lines )
952
+ if err := b .Execute (); err != nil {
953
+ t .Fatal (err )
954
+ }
955
+ b .SetWindowCursor (Window (0 ), [2 ]int {3 , 4 })
956
+ b .Command ("mark v" )
957
+ if err := b .Execute (); err != nil {
958
+ t .Fatal (err )
959
+ }
960
+
961
+ const (
962
+ wantLine = 3
963
+ wantCol = 0
964
+ )
965
+ var pos [2 ]int
966
+ b .BufferMark (Buffer (0 ), "v" , & pos )
967
+ if err := b .Execute (); err != nil {
968
+ t .Fatal (err )
969
+ }
970
+ if pos [0 ] != wantLine {
971
+ t .Fatalf ("got %d extMark line but want %d" , pos [0 ], wantLine )
972
+ }
973
+ if pos [1 ] != wantCol {
974
+ t .Fatalf ("got %d extMark col but want %d" , pos [1 ], wantCol )
975
+ }
976
+
977
+ t .Cleanup (func () {
978
+ clearBuffer (t , v , Buffer (0 ))
979
+ })
980
+ })
906
981
})
907
982
}
908
983
}
0 commit comments