Loading ...
Sorry, an error occurred while loading the content.

BUG: Yank of "exclusive" selection set via marks is off-by-one at first

Expand Messages
  • Ingo Karkat
    Hello Vim developers, Patch 7.3.590 allows to set the visual selection directly via the marks
    Message 1 of 4 , Jul 26 7:00 AM
    • 0 Attachment
      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.

      -- regards, ingo

      --
      --
      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+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Bram Moolenaar
      ... I ll add it to the todo list. -- How To Keep A Healthy Level Of Insanity: 3. Every time someone asks you to do something, ask if they want fries with that.
      Message 2 of 4 , Jul 27 4:59 AM
      • 0 Attachment
        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.

        I'll add it to the todo list.

        --
        How To Keep A Healthy Level Of Insanity:
        3. Every time someone asks you to do something, ask if they want fries
        with that.

        /// Bram Moolenaar -- Bram@... -- 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+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Christian Brabandt
        Hi Ingo! ... 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
        Message 3 of 4 , Jul 29 12:36 PM
        • 0 Attachment
          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+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Bram Moolenaar
          ... Thanks! -- The startling truth finally became apparent, and it was this: Numbers written on restaurant checks within the confines of restaurants do not
          Message 4 of 4 , Jul 30 7:07 AM
          • 0 Attachment
            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 -- Bram@... -- 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+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.