X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/24c7594d62d8d7fbbcdb64b11ce4adc5d8e6991a..6f0ffa58a34f6837bb6b3845c7c9dcdc4241b635:/atom/packages/vim-mode/lib/motions/find-motion.coffee diff --git a/atom/packages/vim-mode/lib/motions/find-motion.coffee b/atom/packages/vim-mode/lib/motions/find-motion.coffee index 58685d7..2a577a8 100644 --- a/atom/packages/vim-mode/lib/motions/find-motion.coffee +++ b/atom/packages/vim-mode/lib/motions/find-motion.coffee @@ -3,14 +3,27 @@ {Point, Range} = require 'atom' class Find extends MotionWithInput - constructor: (@editor, @vimState) -> + operatesInclusively: true + + constructor: (@editor, @vimState, opts={}) -> super(@editor, @vimState) - @vimState.currentFind = this - @viewModel = new ViewModel(this, class: 'find', singleChar: true, hidden: true) - @backwards = false - @repeatReversed = false @offset = 0 - @repeated = false + + if not opts.repeated + @viewModel = new ViewModel(this, class: 'find', singleChar: true, hidden: true) + @backwards = false + @repeated = false + @vimState.globalVimState.currentFind = this + + else + @repeated = true + + orig = @vimState.globalVimState.currentFind + @backwards = orig.backwards + @complete = orig.complete + @input = orig.input + + @reverse() if opts.reverse match: (cursor, count) -> currentPosition = cursor.getBufferPosition() @@ -38,17 +51,22 @@ class Find extends MotionWithInput if (match = @match(cursor, count))? cursor.setBufferPosition(match) - repeat: (opts={}) -> - opts.reverse = !!opts.reverse - @repeated = true - if opts.reverse isnt @repeatReversed - @reverse() - @repeatReversed = opts.reverse - this - class Till extends Find - constructor: (@editor, @vimState) -> - super(@editor, @vimState) + constructor: (@editor, @vimState, opts={}) -> + super(@editor, @vimState, opts) @offset = 1 + match: -> + @selectAtLeastOne = false + retval = super + if retval? and not @backwards + @selectAtLeastOne = true + retval + + moveSelectionInclusively: (selection, count, options) -> + super + if selection.isEmpty() and @selectAtLeastOne + selection.modifySelection -> + selection.cursor.moveRight() + module.exports = {Find, Till}