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

Re: [patch] [test] test if :mksession saves cursor columns correctly in presence of tab and multibyte characters

Expand Messages
  • Christian Brabandt
    Hi Bram! ... Oh, I didn t know that. ... You mean w_cursor.col and using | instead of l . That won t help here, I am afraid. If we have a multi-byte built,
    Message 1 of 16 , Feb 17, 2013
    • 0 Attachment
      Hi Bram!

      On So, 17 Feb 2013, Bram Moolenaar wrote:

      > I think using mb_string2cells() is wrong, because it counts double-wide
      > characters as two, while "l" counts them as one.

      Oh, I didn't know that.

      > How about using w_cursor.vcol but move with "|" instead of "l"?

      You mean w_cursor.col and using '|' instead of 'l'. That won't help
      here, I am afraid.

      If we have a multi-byte built, we also have eval feature, right?
      So can't we use something like this:

      norm! 06l
      if 1
      call setpos('.', ....)
      endif

      Since getpos() or winsaveview uses the byte-value of w_cursor.col this
      should work.


      regards,
      Christian
      --

      --
      --
      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.
    • Roland Eggner
      ... The idea using setpos() looks promising. Two patches in attachments, the first implements setpos() in src/ex_docmd.c, the second adds adapted v2 of my
      Message 2 of 16 , Feb 18, 2013
      • 0 Attachment
        On 2013-02-17 Sunday at 22:15 +0100 Christian Brabandt wrote:
        > On So, 17 Feb 2013, Bram Moolenaar wrote:
        >
        > > I think using mb_string2cells() is wrong, because it counts double-wide
        > > characters as two, while "l" counts them as one.
        >
        > Oh, I didn't know that.
        >
        > > How about using w_cursor.vcol but move with "|" instead of "l"?
        >
        > You mean w_cursor.col and using '|' instead of 'l'. That won't help
        > here, I am afraid.
        >
        > If we have a multi-byte built, we also have eval feature, right?
        > So can't we use something like this:
        >
        > norm! 06l
        > if 1
        > call setpos('.', ....)
        > endif
        >
        > Since getpos() or winsaveview uses the byte-value of w_cursor.col this
        > should work.

        The idea using setpos() looks promising. Two patches in attachments, the first
        implements setpos() in src/ex_docmd.c, the second adds adapted v2 of my
        test{91,92} scripts. In C locale and in en_US.ISO-8859-1 locale both tests
        succeed here, but in en_US.utf8 locale test91 fails and only test92 succeeds:

        pushd path/to/sourcetree/vim-7.3.822
        patch -N -p1 -u -i attachment1.patch
        patch -N -p1 -u -i attachment2.patch
        pushd src/testdir
        rm -f test{91,92}.{out,failed,messages}
        env {LANG,LC_CTYPE,LC_MESSAGES}=en_US.utf8 make -j1
        > Test results:
        > test91 FAILED

        diff -u test91.{failed,ok}
        > --- test91.failed 2013-02-18 19:10:56.448951101 +0100
        > +++ test91.ok 2013-02-18 19:07:26.238965475 +0100
        > @@ -1,6 +1,6 @@
        > call setpos('.', [0, line('.'), 16, 0])
        > call setpos('.', [0, line('.'), 16, 0])
        > call setpos('.', [0, line('.'), 16, 0])
        > -call setpos('.', [0, line('.'), 15, 0])
        > +call setpos('.', [0, line('.'), 16, 0])
        > call setpos('.', [0, line('.'), 16, 0])
        > call setpos('.', [0, line('.'), 16, 0])

        grep '[=.]' test91.messages
        > LANG=en_US.utf8
        > LC_MESSAGES=en_US.utf8
        > LC_ALL=
        > test91.in
        > fileencoding=utf-8
        > termencoding=
        > encoding=utf-8

        --
        Regards
        Roland Eggner
      • Bram Moolenaar
        ... No, that doesn t work. I meant w_virtcol. It has to be validated before using it. Might be tricky in other windows than the current window. ... It is
        Message 3 of 16 , Feb 18, 2013
        • 0 Attachment
          Christian Brabandt wrote:

          > On So, 17 Feb 2013, Bram Moolenaar wrote:
          >
          > > I think using mb_string2cells() is wrong, because it counts double-wide
          > > characters as two, while "l" counts them as one.
          >
          > Oh, I didn't know that.
          >
          > > How about using w_cursor.vcol but move with "|" instead of "l"?
          >
          > You mean w_cursor.col and using '|' instead of 'l'. That won't help
          > here, I am afraid.

          No, that doesn't work. I meant w_virtcol. It has to be validated
          before using it. Might be tricky in other windows than the current
          window.

          > If we have a multi-byte built, we also have eval feature, right?
          > So can't we use something like this:
          >
          > norm! 06l
          > if 1
          > call setpos('.', ....)
          > endif
          >
          > Since getpos() or winsaveview uses the byte-value of w_cursor.col this
          > should work.

          It is possible to have multi-byte without eval.

          --
          "Lisp has all the visual appeal of oatmeal with nail clippings thrown in."
          -- Larry Wall

          /// 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 Bram! ... Hm, that was what the original patch was all about I think? If I know how to validate it, I can make a patch, using the already suggested test.
          Message 4 of 16 , Feb 18, 2013
          • 0 Attachment
            Hi Bram!

            On Mo, 18 Feb 2013, Bram Moolenaar wrote:

            >
            > Christian Brabandt wrote:
            >
            > > On So, 17 Feb 2013, Bram Moolenaar wrote:
            > >
            > > > I think using mb_string2cells() is wrong, because it counts double-wide
            > > > characters as two, while "l" counts them as one.
            > >
            > > Oh, I didn't know that.
            > >
            > > > How about using w_cursor.vcol but move with "|" instead of "l"?
            > >
            > > You mean w_cursor.col and using '|' instead of 'l'. That won't help
            > > here, I am afraid.
            >
            > No, that doesn't work. I meant w_virtcol. It has to be validated
            > before using it. Might be tricky in other windows than the current
            > window.

            Hm, that was what the original patch was all about I think? If I know
            how to validate it, I can make a patch, using the already suggested
            test.


            regards,
            Christian
            --
            Wenn Sie können, schieben sie diese Aufgabe (IT-Sicherheitschef) an
            einen Kollegen ab. Wenn nicht, arbeiten Sie professionell.
            -- Robert Niedermeier (Rechtsanwalt)

            --
            --
            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.
          • Roland Eggner
            Hi Bram and Christian! ... test91 v2 failed under certain conditions, because vim erroneously changed encoding and damaged file “test91.in”. Here is
            Message 5 of 16 , Feb 18, 2013
            • 0 Attachment
              Hi Bram and Christian!

              On 2013-02-18 Monday at 23:09 +0100 Christian Brabandt wrote:
              > On Mo, 18 Feb 2013, Bram Moolenaar wrote:
              >
              > >
              > > Christian Brabandt wrote:
              > >
              > > > On So, 17 Feb 2013, Bram Moolenaar wrote:
              > > >
              > > > > I think using mb_string2cells() is wrong, because it counts double-wide
              > > > > characters as two, while "l" counts them as one.
              > > >
              > > > Oh, I didn't know that.
              > > >
              > > > > How about using w_cursor.vcol but move with "|" instead of "l"?
              > > >
              > > > You mean w_cursor.col and using '|' instead of 'l'. That won't help
              > > > here, I am afraid.
              > >
              > > No, that doesn't work. I meant w_virtcol. It has to be validated
              > > before using it. Might be tricky in other windows than the current
              > > window.
              >
              > Hm, that was what the original patch was all about I think? If I know
              > how to validate it, I can make a patch, using the already suggested
              > test.

              test91 v2 failed under certain conditions, because vim erroneously changed
              encoding and damaged file “test91.in”.

              Here is test{91,92} v3.
              Now I can report: My patch for “src/ex_docmd.c” works for me (tm) :)
              I tried the following and all tests succeeded:

              pushd vim-7.3.822
              patch -p1 -N -u -i 'vim-7.3.816 src ex_docmd.c … .patch'
              patch -p1 -N -u -i 'vim-7.3.816 src testdir test91 test92 v3 … .patch'
              pushd src/testdir
              make clean
              env {LANG,LC_CTYPE,LC_MESSAGES}=C make -j1
              make clean
              env {LANG,LC_CTYPE,LC_MESSAGES}=en_US.ISO-8859-1 make -j1
              make clean
              env {LANG,LC_CTYPE,LC_MESSAGES}=en_US.utf8 make -j1

              Bram, if you wish the lines “debugging stuff” removed from test{91,92}.in or any
              other “final polish” … just let me know.

              --
              Regards
              Roland Eggner
            Your message has been successfully submitted and would be delivered to recipients shortly.