]>
Commit | Line | Data |
---|---|---|
455f099b | 1 | _ = require 'underscore-plus' |
24c7594d BB |
2 | {Operator} = require './general-operators' |
3 | ||
4 | class AdjustIndentation extends Operator | |
455f099b | 5 | execute: (count) -> |
24c7594d BB |
6 | mode = @vimState.mode |
7 | @motion.select(count) | |
455f099b | 8 | originalRanges = @editor.getSelectedBufferRanges() |
24c7594d | 9 | |
455f099b BB |
10 | if mode is 'visual' |
11 | @editor.transact => | |
12 | _.times(count ? 1, => @indent()) | |
13 | else | |
14 | @indent() | |
24c7594d | 15 | |
455f099b BB |
16 | @editor.clearSelections() |
17 | @editor.getLastCursor().setBufferPosition([originalRanges.shift().start.row, 0]) | |
18 | for range in originalRanges | |
19 | @editor.addCursorAtBufferPosition([range.start.row, 0]) | |
20 | @editor.moveToFirstCharacterOfLine() | |
21 | @vimState.activateNormalMode() | |
24c7594d BB |
22 | |
23 | class Indent extends AdjustIndentation | |
24 | indent: -> | |
25 | @editor.indentSelectedRows() | |
26 | ||
27 | class Outdent extends AdjustIndentation | |
28 | indent: -> | |
29 | @editor.outdentSelectedRows() | |
30 | ||
31 | class Autoindent extends AdjustIndentation | |
32 | indent: -> | |
33 | @editor.autoIndentSelectedRows() | |
34 | ||
35 | module.exports = {Indent, Outdent, Autoindent} |