diff --git a/src/packages/bookmarks/lib/bookmarks-view.coffee b/src/packages/bookmarks/lib/bookmarks-view.coffee index a7bf235ee..dedaa7b7c 100644 --- a/src/packages/bookmarks/lib/bookmarks-view.coffee +++ b/src/packages/bookmarks/lib/bookmarks-view.coffee @@ -61,6 +61,7 @@ class BookmarksView getPreviousBookmark: (bufferRow) -> markers = @findBookmarkMarkers() return null unless markers.length + return markers[0] if markers.length == 1 bookmarkIndex = _.sortedIndex markers, bufferRow, (marker) -> if marker.getBufferRange then marker.getBufferRange().start.row else marker @@ -73,6 +74,7 @@ class BookmarksView getNextBookmark: (bufferRow) -> markers = @findBookmarkMarkers() return null unless markers.length + return markers[0] if markers.length == 1 bookmarkIndex = _.sortedIndex markers, bufferRow, (marker) -> if marker.getBufferRange then marker.getBufferRange().start.row else marker diff --git a/src/packages/bookmarks/spec/bookmarks-view-spec.coffee b/src/packages/bookmarks/spec/bookmarks-view-spec.coffee index 4af7b9b11..8a7dff928 100644 --- a/src/packages/bookmarks/spec/bookmarks-view-spec.coffee +++ b/src/packages/bookmarks/spec/bookmarks-view-spec.coffee @@ -62,6 +62,39 @@ describe "Bookmarks package", -> editor.trigger 'bookmarks:jump-to-previous-bookmark' expect(editSession.getCursor().getBufferPosition()).toEqual [5, 10] + describe "with one bookmark", -> + beforeEach -> + editSession.setCursorBufferPosition([2, 0]) + editor.trigger 'bookmarks:toggle-bookmark' + + it "jump-to-next-bookmark jumps to the right place", -> + editSession.setCursorBufferPosition([0, 0]) + + editor.trigger 'bookmarks:jump-to-next-bookmark' + expect(editSession.getCursor().getBufferPosition()).toEqual [2, 0] + + editor.trigger 'bookmarks:jump-to-next-bookmark' + expect(editSession.getCursor().getBufferPosition()).toEqual [2, 0] + + editSession.setCursorBufferPosition([5, 0]) + + editor.trigger 'bookmarks:jump-to-next-bookmark' + expect(editSession.getCursor().getBufferPosition()).toEqual [2, 0] + + it "jump-to-previous-bookmark jumps to the right place", -> + editSession.setCursorBufferPosition([0, 0]) + + editor.trigger 'bookmarks:jump-to-previous-bookmark' + expect(editSession.getCursor().getBufferPosition()).toEqual [2, 0] + + editor.trigger 'bookmarks:jump-to-previous-bookmark' + expect(editSession.getCursor().getBufferPosition()).toEqual [2, 0] + + editSession.setCursorBufferPosition([5, 0]) + + editor.trigger 'bookmarks:jump-to-previous-bookmark' + expect(editSession.getCursor().getBufferPosition()).toEqual [2, 0] + describe "with bookmarks", -> beforeEach -> editSession.setCursorBufferPosition([2, 0])