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

[patch] keepjumps command modifier not respected

Expand Messages
  • Lech Lorens
    Steps to reproduce: - create a file with 40 lines. E.g.: $ seq 1 40 test.txt - create a Vim script file (e.g. called do.vim) with the following contents: #v+
    Message 1 of 2 , Apr 5, 2010
    • 0 Attachment
      Steps to reproduce:
      - create a file with 40 lines. E.g.:
      $ seq 1 40 >test.txt
      - create a Vim script file (e.g. called do.vim) with the following contents:
      #v+
      let @a = "text put before line 1"
      let @b = "text put before line 11"
      let @c = "text put before line 21"
      normal 1G
      normal 10G
      normal 20G
      normal 30G
      normal 40G
      redir @z
      jumps
      keepjumps 1put! a
      keepjumps 11put! b
      keepjumps 21put! c
      jumps
      redir END
      $put z
      normal G
      #v-

      - execute the script on the previously created 40-line file:
      $ vim -i /dev/null -S do.vim test.txt

      The last lines of the file will be:

      #v+
      jump line col file/text
      4 1 0 1
      3 10 0 10
      2 20 0 20
      1 30 0 30
      >
      jump line col file/text
      4 2 0 1
      3 12 0 10
      2 23 0 20
      1 33 0 30
      >
      #v-

      (i.e. there will be difference in the "line" column between the two :jumps
      invocations), while they should be:

      #v+
      jump line col file/text
      4 1 0 1
      3 10 0 10
      2 20 0 20
      1 30 0 30
      >
      jump line col file/text
      4 1 0 text put before line 1
      3 10 0 9
      2 20 0 18
      1 30 0 27
      >
      #v-

      The attached patch fixes the problem.

      --
      Cheers,
      Lech

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

      To unsubscribe, reply using "remove me" as the subject.
    • Bram Moolenaar
      ... I now had time to look into this patch. It turns out there is no bug. You are mixing up the :keepjumps and :lockmarks modifiers. Only the last one
      Message 2 of 2 , May 14, 2010
      • 0 Attachment
        Lech Lorens wrote:

        > Steps to reproduce:
        > - create a file with 40 lines. E.g.:
        > $ seq 1 40 >test.txt
        > - create a Vim script file (e.g. called do.vim) with the following contents:
        > #v+
        > let @a = "text put before line 1"
        > let @b = "text put before line 11"
        > let @c = "text put before line 21"
        > normal 1G
        > normal 10G
        > normal 20G
        > normal 30G
        > normal 40G
        > redir @z
        > jumps
        > keepjumps 1put! a
        > keepjumps 11put! b
        > keepjumps 21put! c
        > jumps
        > redir END
        > $put z
        > normal G
        > #v-
        >
        > - execute the script on the previously created 40-line file:
        > $ vim -i /dev/null -S do.vim test.txt
        >
        > The last lines of the file will be:
        >
        > #v+
        > jump line col file/text
        > 4 1 0 1
        > 3 10 0 10
        > 2 20 0 20
        > 1 30 0 30
        > >
        > jump line col file/text
        > 4 2 0 1
        > 3 12 0 10
        > 2 23 0 20
        > 1 33 0 30
        > >
        > #v-
        >
        > (i.e. there will be difference in the "line" column between the two :jumps
        > invocations), while they should be:
        >
        > #v+
        > jump line col file/text
        > 4 1 0 1
        > 3 10 0 10
        > 2 20 0 20
        > 1 30 0 30
        > >
        > jump line col file/text
        > 4 1 0 text put before line 1
        > 3 10 0 9
        > 2 20 0 18
        > 1 30 0 27
        > >
        > #v-
        >
        > The attached patch fixes the problem.

        I now had time to look into this patch. It turns out there is no bug.
        You are mixing up the ":keepjumps" and ":lockmarks" modifiers. Only the
        last one doesn't adjust line numbers for inserted lines. With
        ":keepjumps" the mark stays at the same text line, but the line number
        will be adjusted for inserted and deleted lines.

        --
        Just remember...if the world didn't suck, we'd all fall off.

        /// Bram Moolenaar -- Bram@... -- 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.
        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.