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

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

Expand Messages
  • Roland Eggner
    Feb 18, 2013
      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
    • Show all 16 messages in this topic