Handle one bookmark

This commit is contained in:
Ben Ogle
2013-07-22 15:03:58 -07:00
parent ece0c76158
commit 8db9551700
2 changed files with 35 additions and 0 deletions

View File

@@ -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

View File

@@ -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])