Christian Brabandt wrote:

> On Fr, 26 Jul 2013, Ingo Karkat wrote:
> 
> > Hello Vim developers,
> > 
> > Patch 7.3.590 allows to set the visual selection directly via the marks
> > '< and '>. I've found a problem with :set selection=exclusive (while
> > developing a custom mapping): When the first selection after Vim startup
> > is defined via setpos(), then reselected (gv) and yanked (y), it
> > includes one character too much, as if the non-default 'selection'
> > setting isn't taken into account (even though gv displays the correct
> > selection).
> > 
> > #v+
> > fun! Test()
> >     call setpos("'<", [0, 1, 2, 0]) | call setpos("'>", [0, 1, 4, 0])
> >     normal! gvy
> >     echomsg string(@@)
> > endfun
> > 
> > set selection=exclusive
> > call setline(1, 'foobar')
> > call Test()
> > " Should print "oo", actually prints "oob"
> > " Observe that a ":normal! gv" will correctly select only 2 characters.
> > " Do a different selection the usual way.
> > normal! 03lvlly
> > " Repeat the test.
> > call Test()
> > " Now prints "oo" correctly.
> > #v-
> > 
> > To reproduce, use above scriptlet or the identical attached script:
> >     vim -N -u NONE -S bug-exclusive-selection-register-set.vim
> > 
> > Reproducible on huge builds of Vim 7.4a.44 on Linux/x64 and Vim 7.3.823
> > on Windows/x64.
> 
> This happens, because the visual mode has not yet been set and is 
> therefore undefined. This patch fixes it to make it default to 'v' in 
> case visual_mode has not been set before:
> 
> #ifdef FEAT_VISUAL
>     if (c == '<')
>     {
>         curbuf->b_visual.vi_start = *pos;
>         /* visual_mode might not yet have been set, so set it to a sane 
> default */
>         if (!curbuf->b_visual.vi_mode)
>             curbuf->b_visual.vi_mode = 'v';
>         return OK;
>     }
>     if (c == '>')
>     {
>         curbuf->b_visual.vi_end = *pos;
>         /* visual_mode might not yet have been set, so set it to a sane 
> default */
>         if (!curbuf->b_visual.vi_mode)
>             curbuf->b_visual.vi_mode = 'v';
>         return OK;
>     }
> #endif

Thanks!

-- 
The startling truth finally became apparent, and it was this: Numbers
written on restaurant checks within the confines of restaurants do not follow
the same mathematical laws as numbers written on any other pieces of paper in
any other parts of the Universe.  This single statement took the scientific
world by storm.  So many mathematical conferences got held in such good
restaurants that many of the finest minds of a generation died of obesity and
heart failure, and the science of mathematics was put back by years.
                -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui