From 173c47f780e25c63bf400704f5960e6fd0e5c143 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 22 Jul 2013 15:15:01 -0700 Subject: [PATCH] Fix issue in jumping to next bookmark --- src/packages/bookmarks/lib/bookmarks-view.coffee | 2 +- src/packages/bookmarks/spec/bookmarks-view-spec.coffee | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/packages/bookmarks/lib/bookmarks-view.coffee b/src/packages/bookmarks/lib/bookmarks-view.coffee index 5a871ecaa..06cb933ca 100644 --- a/src/packages/bookmarks/lib/bookmarks-view.coffee +++ b/src/packages/bookmarks/lib/bookmarks-view.coffee @@ -79,7 +79,7 @@ class BookmarksView bookmarkIndex = _.sortedIndex markers, bufferRow, (marker) -> if marker.getBufferRange then marker.getBufferRange().start.row else marker - bookmarkIndex++ if markers[bookmarkIndex].getBufferRange().start.row == bufferRow + bookmarkIndex++ if markers[bookmarkIndex] and markers[bookmarkIndex].getBufferRange().start.row == bufferRow bookmarkIndex = 0 if bookmarkIndex >= markers.length markers[bookmarkIndex] diff --git a/src/packages/bookmarks/spec/bookmarks-view-spec.coffee b/src/packages/bookmarks/spec/bookmarks-view-spec.coffee index 8a7dff928..7a39b9dc5 100644 --- a/src/packages/bookmarks/spec/bookmarks-view-spec.coffee +++ b/src/packages/bookmarks/spec/bookmarks-view-spec.coffee @@ -115,6 +115,11 @@ describe "Bookmarks package", -> editor.trigger 'bookmarks:jump-to-next-bookmark' expect(editSession.getCursor().getBufferPosition()).toEqual [2, 0] + editSession.setCursorBufferPosition([11, 0]) + + editor.trigger 'bookmarks:jump-to-next-bookmark' + expect(editSession.getCursor().getBufferPosition()).toEqual [2, 0] + it "jump-to-previous-bookmark finds previous bookmark", -> editSession.setCursorBufferPosition([0, 0]) @@ -126,3 +131,8 @@ describe "Bookmarks package", -> editor.trigger 'bookmarks:jump-to-previous-bookmark' expect(editSession.getCursor().getBufferPosition()).toEqual [10, 0] + + editSession.setCursorBufferPosition([11, 0]) + + editor.trigger 'bookmarks:jump-to-previous-bookmark' + expect(editSession.getCursor().getBufferPosition()).toEqual [10, 0]