[patch] Problem with block right-shifting with multi-byte 'enc'

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] Problem with block right-shifting with multi-byte 'enc'

Lech Lorens
The right shift of a block is not performed well in certain situations
if 'enc' is set to a multi-byte value.

Observe it by editing a file with the following contents in Vim (1 and
2 are line numbers, not the contents of the file):

#v+
1 s|
2  |
#v-

$ vim -u NONE -U NONE --noplugin file.txt

:set enc=utf-8 number list listchars=tab:>-
:1
:normal 2|
:normal  j>gv>

The result is (note that the '|' characters are not in the same column):

#v+
1 s   |
2  |
#v-

If you change the steps to:

:set enc=utf-8 number list listchars=tab:>-
:1
:normal 2|
:normal  j>gv>gv>

The result will be (the '|' character in the second line stops moving):

#v+
1 s   |
2  |
#v-

The attached patch fixes the problem.

--
Cheers,
Lech

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---


bad-right-shift.patch (287 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [patch] Problem with block right-shifting with multi-byte 'enc'

James Vega-3

On Wed, Nov 4, 2009 at 5:04 PM, Lech Lorens <[hidden email]> wrote:

> The right shift of a block is not performed well in certain situations
> if 'enc' is set to a multi-byte value.
>
> Observe it by editing a file with the following contents in Vim (1 and
> 2 are line numbers, not the contents of the file):
>
> #v+
> 1 s|
> 2  |
> #v-
>
> $ vim -u NONE -U NONE --noplugin file.txt
>
> :set enc=utf-8 number list listchars=tab:>-
> :1
> :normal 2|
> :normal  j>gv>

I think this is supposed to be

  :exe "normal \<C-v>j>gv>"

Similarly for the other example.

|v_b_>_example| exhibits a similar issue, but it also results in a
character being deleted from the text!

Given a file that contains the following 4 lines, run in a UTF-8
environment or setting 'enc' to UTF-8:

abcdefghijklmnopqrstuvwxyz
abc defghijklmnopqrstuvwxyz
abcdef  ghi jklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz

vim -u NONE -c 'set list listchars=tab:>-' test.txt
:exe "normal fo\<C-v>3j>"

will result in

abcdefghijklmn      opqrstuvwxyz
abc efghijklmnopqrstuvwxyz
abcdef  ghi jklmnopqrstuvwxyz
abcdefghijklmn      opqrstuvwxyz

The d on line 2 has disappeared and line 3 wasn't shifted at all.

Does your patch also fix this situation, Lech?  I'm unable to test
right now.

--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[hidden email]>

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: [patch] Problem with block right-shifting with multi-byte 'enc'

Bram Moolenaar
In reply to this post by Lech Lorens


Lech Lorens wrote:

> The right shift of a block is not performed well in certain situations
> if 'enc' is set to a multi-byte value.
>
> Observe it by editing a file with the following contents in Vim (1 and
> 2 are line numbers, not the contents of the file):
>
> #v+
> 1 s|
> 2  |
> #v-
>
> $ vim -u NONE -U NONE --noplugin file.txt
>
> :set enc=utf-8 number list listchars=tab:>-
> :1
> :normal 2|
> :normal  j>gv>
>
> The result is (note that the '|' characters are not in the same column):
>
> #v+
> 1 s   |
> 2  |
> #v-
>
> If you change the steps to:
>
> :set enc=utf-8 number list listchars=tab:>-
> :1
> :normal 2|
> :normal  j>gv>gv>
>
> The result will be (the '|' character in the second line stops moving):
>
> #v+
> 1 s   |
> 2  |
> #v-
>
> The attached patch fixes the problem.

Thanks.  Keep them coming!

--
Kisses may last for as much as, but no more than, five minutes.
                [real standing law in Iowa, United States of America]

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: [patch] Problem with block right-shifting with multi-byte 'enc'

Lech Lorens
In reply to this post by James Vega-3

On 04-Nov-2009 James Vega <[hidden email]> wrote:

>
> Given a file that contains the following 4 lines, run in a UTF-8
> environment or setting 'enc' to UTF-8:
>
> abcdefghijklmnopqrstuvwxyz
> abc defghijklmnopqrstuvwxyz
> abcdef  ghi jklmnopqrstuvwxyz
> abcdefghijklmnopqrstuvwxyz
>
> vim -u NONE -c 'set list listchars=tab:>-' test.txt
> :exe "normal fo\<C-v>3j>"
>
> will result in
>
> abcdefghijklmn      opqrstuvwxyz
> abc efghijklmnopqrstuvwxyz
> abcdef  ghi jklmnopqrstuvwxyz
> abcdefghijklmn      opqrstuvwxyz
>
> The d on line 2 has disappeared and line 3 wasn't shifted at all.
>
> Does your patch also fix this situation, Lech?  I'm unable to test
> right now.

Thanks for noticing this. Luckily - it does. Hooray!
:-)

--
Cheers,
Lech

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---