]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee
0187620abf09c640a9e1f4620170d2c35889edc0
[rbdr/dotfiles] / atom / packages / vim-mode / lib / motions / move-to-mark-motion.coffee
1 {MotionWithInput, MoveToFirstCharacterOfLine} = require './general-motions'
2 {ViewModel} = require '../view-models/view-model'
3 {Point, Range} = require 'atom'
4
5 module.exports =
6 class MoveToMark extends MotionWithInput
7 operatesInclusively: false
8
9 constructor: (@editor, @vimState, @linewise=true) ->
10 super(@editor, @vimState)
11 @operatesLinewise = @linewise
12 @viewModel = new ViewModel(this, class: 'move-to-mark', singleChar: true, hidden: true)
13
14 isLinewise: -> @linewise
15
16 moveCursor: (cursor, count=1) ->
17 markPosition = @vimState.getMark(@input.characters)
18
19 if @input.characters is '`' # double '`' pressed
20 markPosition ?= [0, 0] # if markPosition not set, go to the beginning of the file
21 @vimState.setMark('`', cursor.getBufferPosition())
22
23 cursor.setBufferPosition(markPosition) if markPosition?
24 if @linewise
25 cursor.moveToFirstCharacterOfLine()