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