X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/24c7594d62d8d7fbbcdb64b11ce4adc5d8e6991a..ea8982397a1ce09223736c396901809e5f75a398:/atom/packages/vim-mode/lib/operators/indent-operators.coffee diff --git a/atom/packages/vim-mode/lib/operators/indent-operators.coffee b/atom/packages/vim-mode/lib/operators/indent-operators.coffee index 0ad37e0..ba3c155 100644 --- a/atom/packages/vim-mode/lib/operators/indent-operators.coffee +++ b/atom/packages/vim-mode/lib/operators/indent-operators.coffee @@ -1,17 +1,24 @@ +_ = require 'underscore-plus' {Operator} = require './general-operators' class AdjustIndentation extends Operator - execute: (count=1) -> + execute: (count) -> mode = @vimState.mode @motion.select(count) - {start} = @editor.getSelectedBufferRange() + originalRanges = @editor.getSelectedBufferRanges() - @indent() + if mode is 'visual' + @editor.transact => + _.times(count ? 1, => @indent()) + else + @indent() - if mode isnt 'visual' - @editor.setCursorBufferPosition([start.row, 0]) - @editor.moveToFirstCharacterOfLine() - @vimState.activateCommandMode() + @editor.clearSelections() + @editor.getLastCursor().setBufferPosition([originalRanges.shift().start.row, 0]) + for range in originalRanges + @editor.addCursorAtBufferPosition([range.start.row, 0]) + @editor.moveToFirstCharacterOfLine() + @vimState.activateNormalMode() class Indent extends AdjustIndentation indent: ->