@@ -125,6 +125,65 @@ describe("marksman.nvim", function()
125125 assert .equals (3 , vim .fn .col (" ." ))
126126 end )
127127
128+ it (" jumps to next mark with wrap-around" , function ()
129+ -- open the test file and place marks on lines 1, 2, and 3
130+ vim .cmd (" edit " .. test_file )
131+
132+ vim .fn .cursor (1 , 1 )
133+ marksman .add_mark (" m1" )
134+
135+ vim .fn .cursor (2 , 1 )
136+ marksman .add_mark (" m2" )
137+
138+ vim .fn .cursor (3 , 1 )
139+ marksman .add_mark (" m3" )
140+
141+ -- start at m1
142+ vim .fn .cursor (1 , 1 )
143+ local result = marksman .goto_next ()
144+ assert .is_true (result .success )
145+ assert .equals (2 , vim .fn .line (" ." ), " Should jump from m1 to m2" )
146+
147+ -- now at m2 -> next should be m3
148+ result = marksman .goto_next ()
149+ assert .is_true (result .success )
150+ assert .equals (3 , vim .fn .line (" ." ), " Should jump from m2 to m3" )
151+
152+ -- now at m3 -> next should wrap back to m1
153+ result = marksman .goto_next ()
154+ assert .is_true (result .success )
155+ assert .equals (1 , vim .fn .line (" ." ), " Should wrap from m3 to m1" )
156+ end )
157+
158+ it (" jumps to previous mark with wrap-around" , function ()
159+ vim .cmd (" edit " .. test_file )
160+
161+ vim .fn .cursor (1 , 1 )
162+ marksman .add_mark (" m1" )
163+
164+ vim .fn .cursor (2 , 1 )
165+ marksman .add_mark (" m2" )
166+
167+ vim .fn .cursor (3 , 1 )
168+ marksman .add_mark (" m3" )
169+
170+ -- start at m1 -> previous should wrap to m3
171+ vim .fn .cursor (1 , 1 )
172+ local result = marksman .goto_previous ()
173+ assert .is_true (result .success )
174+ assert .equals (3 , vim .fn .line (" ." ), " Should wrap from m1 to m3" )
175+
176+ -- now at m3 -> previous should be m2
177+ result = marksman .goto_previous ()
178+ assert .is_true (result .success )
179+ assert .equals (2 , vim .fn .line (" ." ), " Should jump from m3 to m2" )
180+
181+ -- now at m2 -> previous should be m1
182+ result = marksman .goto_previous ()
183+ assert .is_true (result .success )
184+ assert .equals (1 , vim .fn .line (" ." ), " Should jump from m2 to m1" )
185+ end )
186+
128187 it (" deletes marks" , function ()
129188 vim .cmd (" edit " .. test_file )
130189 marksman .add_mark (" delete_me" )
0 commit comments