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

Inconsistent jump after undo of multi-line change

Expand Messages
  • bootleq
    Hi, I found a inconsistent behavior. Original text: 1 foo 2 foo 3 foo Put cursor at line 3, then `:call setline(1, bar )` text become: 1 bar 2 foo 3 foo Then
    Message 1 of 5 , Sep 3, 2011
    • 0 Attachment
      Hi, I found a inconsistent behavior.

      Original text:

      1 foo
      2 foo
      3 foo

      Put cursor at line 3, then `:call setline(1, 'bar')`
      text become:

      1 bar
      2 foo
      3 foo

      Then press 'u' to undo 'bar' to 'foo'.

      1) There will be a jump to line 1 (the first line in changed lines)
      2) However, if we called `:call setline(2, 'bar')` in previous step, no jump will be added.

      About the automatically added jump:
      It' reasonable when undoing a single change.
      But if we do many changes at one function,  one undo block,
      we might want to keep the cursor unchanged after undo.

      My suggestion is when undoing a change,
      if it contains multi-line changes, don't add a jump.

      --
      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
    • James Vega
      ... You can use the :keepjumps command to perform an action without altering the jump list. -- James GPG Key: 1024D/61326D40 2003-09-02 James Vega
      Message 2 of 5 , Sep 4, 2011
      • 0 Attachment
        On Sun, Sep 04, 2011 at 10:47:53AM +0800, bootleq wrote:
        > About the automatically added jump:
        > It' reasonable when undoing a single change.
        > But if we do many changes at one function, one undo block,
        > we might want to keep the cursor unchanged after undo.

        You can use the :keepjumps command to perform an action without altering
        the jump list.

        --
        James
        GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>
      • bootleq
        Yes, thanks, but in this case, with 1) :keepjumps | call setline(1, bar ) 2) :keepjumps | undo it still jump to line 1. 2011/9/5 James Vega
        Message 3 of 5 , Sep 4, 2011
        • 0 Attachment
          Yes, thanks, but in this case, with
          1) :keepjumps | call setline(1, 'bar')
          2) :keepjumps | undo
          it still jump to line 1.

          2011/9/5 James Vega <jamessan@...>
          On Sun, Sep 04, 2011 at 10:47:53AM +0800, bootleq wrote:
          > About the automatically added jump:
          > It' reasonable when undoing a single change.
          > But if we do many changes at one function,  one undo block,
          > we might want to keep the cursor unchanged after undo.

          You can use the :keepjumps command to perform an action without altering
          the jump list.

          --
          James
          GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>

          --
          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
        • Jürgen Krämer
          Hi, ... don t use bars after :keepjumps. :keepjumps takes a command as argument. Putting the bars there told Vim to execute :keepjumps without arguments (which
          Message 4 of 5 , Sep 4, 2011
          • 0 Attachment
            Hi,

            bootleq wrote:
            >
            > 2011/9/5 James Vega <jamessan@... <mailto:jamessan@...>>
            >>
            >> On Sun, Sep 04, 2011 at 10:47:53AM +0800, bootleq wrote:
            >> > About the automatically added jump:
            >> > It' reasonable when undoing a single change.
            >> > But if we do many changes at one function, one undo block,
            >> > we might want to keep the cursor unchanged after undo.
            >>
            >> You can use the :keepjumps command to perform an action without altering
            >> the jump list.
            >>
            >> --
            >> James
            >> GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@... <mailto:jamessan@...>>
            >
            > Yes, thanks, but in this case, with
            > 1) :keepjumps | call setline(1, 'bar')
            > 2) :keepjumps | undo
            > it still jump to line 1.

            don't use bars after :keepjumps. :keepjumps takes a command as argument.
            Putting the bars there told Vim to execute :keepjumps without arguments
            (which is a no-op), and than to execute :call and :undo, respectively.

            Regards,
            Jürgen

            --
            Sometimes I think the surest sign that intelligent life exists elsewhere
            in the universe is that none of it has tried to contact us. (Calvin)

            --
            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
          • bootleq
            Thank you, I can keep jumplist unchanged now. But back to my first message, the cursor still silently move to first changed line. 2011/9/5 Jürgen Krämer
            Message 5 of 5 , Sep 5, 2011
            • 0 Attachment
              Thank you, I can keep jumplist unchanged now.

              But back to my first message, the cursor still silently move to first changed line.

              2011/9/5 Jürgen Krämer <jottkaerr@...>

              Hi,

              bootleq wrote:
              >
              > 2011/9/5 James Vega <jamessan@... <mailto:jamessan@...>>
              >>
              >>     On Sun, Sep 04, 2011 at 10:47:53AM +0800, bootleq wrote:
              >>     > About the automatically added jump:
              >>     > It' reasonable when undoing a single change.
              >>     > But if we do many changes at one function,  one undo block,
              >>     > we might want to keep the cursor unchanged after undo.
              >>
              >>     You can use the :keepjumps command to perform an action without altering
              >>     the jump list.
              >>
              >>     --
              >>     James
              >>     GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@... <mailto:jamessan@...>>
              >
              > Yes, thanks, but in this case, with
              > 1) :keepjumps | call setline(1, 'bar')
              > 2) :keepjumps | undo
              > it still jump to line 1.

              don't use bars after :keepjumps. :keepjumps takes a command as argument.
              Putting the bars there told Vim to execute :keepjumps without arguments
              (which is a no-op), and than to execute :call and :undo, respectively.

              Regards,
              Jürgen

              --
              Sometimes I think the surest sign that intelligent life exists elsewhere
              in the universe is that none of it has tried to contact us.     (Calvin)

              --
              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 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
            Your message has been successfully submitted and would be delivered to recipients shortly.