Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix behavior of visual mode {count}> and {count}< #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]
},

Expand Down
23 changes: 15 additions & 8 deletions vintage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down