Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix behavior of visual mode `{count}>` and `{count}<`

fixes #98
  • Loading branch information...
commit 2fbc589e4c593ff5b112d4434cdbfabc76a5b578 1 parent 8ceecfc
@misfo authored
Showing with 17 additions and 10 deletions.
  1. +2 −2 Default.sublime-keymap
  2. +15 −8 vintage.py
View
4 Default.sublime-keymap
@@ -421,11 +421,11 @@
"context": [{"key": "setting.command_mode"}]
},
- { "keys": [">"], "command": "set_action", "args": {"action": "vi_indent", "description": "Indent"},
+ { "keys": [">"], "command": "set_action", "args": {"action": "vi_indent", "description": "Indent", "action_args": {"repeat": 1}},
"context": [{"key": "setting.command_mode"}]
},
- { "keys": ["<"], "command": "set_action", "args": {"action": "vi_unindent", "description": "Unindent"},
+ { "keys": ["<"], "command": "set_action", "args": {"action": "vi_unindent", "description": "Unindent", "action_args": {"repeat": 1}},
"context": [{"key": "setting.command_mode"}]
},
View
23 vintage.py
@@ -541,8 +541,15 @@ def run(self, edit, action_command, action_args,
motion_repeat *= prefix_repeat
prefix_repeat = 1
- # Check if the motion command would like to handle the repeat itself
- if motion_args and 'repeat' in motion_args:
+ visual_mode = self.view.has_non_empty_selection_region()
+
+ # Check if the action or motion command would like to handle the repeat
+ # themselves.
+ if visual_mode and action_args and 'repeat' in action_args:
+ action_args['repeat'] = motion_repeat * prefix_repeat
+ motion_repeat = 1
+ prefix_repeat = 1
+ elif motion_args and 'repeat' in motion_args:
motion_args['repeat'] = motion_repeat * prefix_repeat
motion_repeat = 1
prefix_repeat = 1
@@ -553,8 +560,6 @@ def run(self, edit, action_command, action_args,
if motion_args and 'explicit_repeat' in motion_args:
motion_args['explicit_repeat'] = explicit_repeat
- visual_mode = self.view.has_non_empty_selection_region()
-
# Let the motion know if we're in visual mode, if it wants to know
if motion_args and 'visual' in motion_args:
motion_args['visual'] = visual_mode
@@ -1006,13 +1011,15 @@ def transform(pt):
class ViIndent(sublime_plugin.TextCommand):
- def run(self, edit):
- self.view.run_command('indent')
+ def run(self, edit, repeat=1):
+ for n in xrange(repeat):
+ self.view.run_command('indent')
transform_selection_regions(self.view, shrink_to_first_char)
class ViUnindent(sublime_plugin.TextCommand):
- def run(self, edit):
- self.view.run_command('unindent')
+ def run(self, edit, repeat=1):
+ for n in xrange(repeat):
+ self.view.run_command('unindent')
transform_selection_regions(self.view, shrink_to_first_char)
class ViSetBookmark(sublime_plugin.TextCommand):
Please sign in to comment.
Something went wrong with that request. Please try again.