Skip to content

Instantly share code, notes, and snippets.

@t9md
Created September 21, 2017 18:33
Show Gist options
  • Save t9md/c70f5d6528904601755422ae66124f26 to your computer and use it in GitHub Desktop.
Save t9md/c70f5d6528904601755422ae66124f26 to your computer and use it in GitHub Desktop.
class setCursorAtStart extends Operator
@extend()
restorePositions: false
mutateSelection: (selection) ->
selection.cursor.setBufferPosition(@getPointForSelection(selection))
getPointForSelection: (selection) ->
@swrap(selection).getBufferPositionFor("start")
class setCursorAtEnd extends setCursorAtStart
@extend()
getPointForSelection: (selection) ->
@swrap(selection).getBufferPositionFor("end").translate([0, -1])
class setCursorAtHead extends setCursorAtEnd
@extend()
getPointForSelection: (selection) ->
if selection.isReversed()
@swrap(selection).getBufferPositionFor("start")
else
super
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment