]> git.r.bdr.sh - rbdr/dotfiles/blobdiff - atom/packages/vim-mode/lib/operators/indent-operators.coffee
Adds atom packages
[rbdr/dotfiles] / atom / packages / vim-mode / lib / operators / indent-operators.coffee
index 0ad37e0296d984729d61ca60abe219b362f194bf..ba3c155efcff0436cc97ee4a4291b5d30f7e0231 100644 (file)
@@ -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: ->