Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix behavior of commands like '4>' and '4<' #98

Open
wants to merge 6 commits into from

4 participants

@skyronic

Previous Behavior:

Let's assume we have a code block, and we have selected the entire block:

foo()
{
    bar()
}

Selecting the entire block and entering the command '>>' results in the output

    foo()
    {
        bar()
    }

Which is the same as vim. But if we select the original block and issue the command '3>', we see the result:

            foo()
    {
        bar()
    }

Wheras, the same command issued through vim would result in:

            foo()
            {
                bar()
            }

After doing a little investigating, I realized that "3>" calls the "vi_indent" command three times.

The first time, it indents the entire block of text and deselects it. Since the caret is only on the first line for the second and third time the "vi_indent" function is called, only the first line gets indented.

The real proper fix for this bug would be to not call "transform_selection_regions" until the last call of vi_indent but this seemed like a simpler hack.

@skyronic skyronic Fix behaviour of commands like '4>' and '4<'
Previous Behavior:

Let's assume we have a code block, and we have selected the entire block:

	foo()
	{
		bar()
	}

Selecting the entire block and entering the command '>>' results in the output

		foo()
		{
			bar()
		}

Which is the same as vim. But if we select the original block and issue the command '3>',
we see the result:

				foo()
		{
			bar()
		}

Wheras, the same command issued through vim would result in:

				foo()
				{
					bar()
				}

After doing a little investigating, I realized that "3>" calls the "vi_indent" command three times.

The first time, it indents the entire block of text and deselects it. Since the caret is only on the first
line for the second and third time the "vi_indent" function is called, only the first line gets indented.

The real proper fix for this bug would be to not call "transform_selection_regions" until the last call of vi_indent
but this seemed like a simpler hack.
29e043e
@misfo misfo referenced this pull request from a commit in misfo/Vintage
@misfo misfo Fix behavior of visual mode `{count}>` and `{count}<`
fixes #98
2fbc589
guillermooo and others added some commits
@guillermooo guillermooo bypass registers if using the null register (:_) c64bb0a
@sublimehq Merge pull request #136 from rctay/rc/bookmark-no-space
'<*> jumps to first non-whitespace character on line
6fca78e
@sublimehq Merge pull request #130 from guillermooo/null-reg
bypass registers if using the null register (:_)
04e8e09
@skyronic skyronic Prevent motion mode going back into normal
For some reason, I am encountering a bug in certain syntaxes
where view.has_non_empty_selection_region returns False instead
of true.

It seems to work adequately well in case this change is turned off
19a6fc3
@skyronic skyronic Merge branch 'master' of github.com:skyronic/Vintage f139a4c
@bronson bronson referenced this pull request
Open

2> #162

@deanproxy

why in the world hasn't this been fixed yet? We're going into version 3 of sublime text and this issue still exists...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2012
  1. @skyronic

    Fix behaviour of commands like '4>' and '4<'

    skyronic authored
    Previous Behavior:
    
    Let's assume we have a code block, and we have selected the entire block:
    
    	foo()
    	{
    		bar()
    	}
    
    Selecting the entire block and entering the command '>>' results in the output
    
    		foo()
    		{
    			bar()
    		}
    
    Which is the same as vim. But if we select the original block and issue the command '3>',
    we see the result:
    
    				foo()
    		{
    			bar()
    		}
    
    Wheras, the same command issued through vim would result in:
    
    				foo()
    				{
    					bar()
    				}
    
    After doing a little investigating, I realized that "3>" calls the "vi_indent" command three times.
    
    The first time, it indents the entire block of text and deselects it. Since the caret is only on the first
    line for the second and third time the "vi_indent" function is called, only the first line gets indented.
    
    The real proper fix for this bug would be to not call "transform_selection_regions" until the last call of vi_indent
    but this seemed like a simpler hack.
Commits on May 19, 2012
  1. @guillermooo
Commits on Jul 19, 2012
  1. Merge pull request #136 from rctay/rc/bookmark-no-space

    authored
    '<*> jumps to first non-whitespace character on line
  2. Merge pull request #130 from guillermooo/null-reg

    authored
    bypass registers if using the null register (:_)
Commits on Aug 21, 2012
  1. @skyronic

    Prevent motion mode going back into normal

    skyronic authored
    For some reason, I am encountering a bug in certain syntaxes
    where view.has_non_empty_selection_region returns False instead
    of true.
    
    It seems to work adequately well in case this change is turned off
  2. @skyronic
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 3 deletions.
  1. +15 −3 vintage.py
View
18 vintage.py
@@ -8,6 +8,7 @@
# Registers are used for clipboards and macro storage
g_registers = {}
+REGISTER_NULL = '_'
# Represents the current input state. The primary commands that interact with
# this are:
@@ -135,7 +136,8 @@ def on_selection_modified(self, view):
# to clicking with the mouse
if (g_input_state.motion_mode == MOTION_MODE_LINE and
not view.has_non_empty_selection_region()):
- g_input_state.motion_mode = MOTION_MODE_NORMAL
+ # g_input_state.motion_mode = MOTION_MODE_NORMAL
+ pass
update_status_line(view)
def on_load(self, view):
@@ -831,6 +833,11 @@ def run(self, edit, register = '"', repeat = 1):
'register': register})
def set_register(view, register, forward):
+ if register == REGISTER_NULL:
+ # This is the null register; do nothing.
+ # More info in Vim: :help "_
+ return
+
delta = 1
if not forward:
delta = -1
@@ -865,6 +872,11 @@ def set_register(view, register, forward):
g_registers[reg] = text
def get_register(view, register):
+ if register == REGISTER_NULL:
+ # This is the null register; do nothing.
+ # More info in Vim: :help "_
+ return
+
use_sys_clipboard = view.settings().get('vintage_use_clipboard', False) == True
register = register.lower()
if register == '%':
@@ -1008,12 +1020,12 @@ def transform(pt):
class ViIndent(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command('indent')
- transform_selection_regions(self.view, shrink_to_first_char)
+ # transform_selection_regions(self.view, shrink_to_first_char)
class ViUnindent(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command('unindent')
- transform_selection_regions(self.view, shrink_to_first_char)
+ # transform_selection_regions(self.view, shrink_to_first_char)
class ViSetBookmark(sublime_plugin.TextCommand):
def run(self, edit, character):
Something went wrong with that request. Please try again.