Hi Ingo!

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


Mit freundlichen Grüßen
Christian
-- 
In dem Maße, wie der Aberglaube bei einem Volk abnimmt, muß die
Regierung die Vorsichtsmaßnahmen steigern und die Zügel der Autorität
und Ordnung straffer ziehen.
                -- Antoine Comte de Rivarol (Maximen und Reflexionen)

-- 
-- 
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.


Reply via email to