I found that Vim unexpectedly resets "curswant" in some
context. Try the following steps to reproduce the problem:
------------------------------------------------------------
$ cat foo
1234567890
12345
$ cat test.vim
edit foo
normal! ggf8j
echomsg 'before setting timeoutlen:' string(winsaveview())
let &timeoutlen = &timeoutlen
echomsg 'after setting timeoutlen:' string(winsaveview())
normal! ggf8j
echomsg 'before setting ttimeoutlen:' string(winsaveview())
let &ttimeoutlen = &ttimeoutlen
echomsg 'after setting ttimeoutlen:' string(winsaveview())
$ vim -u NONE -i NONE -c 'source test.vim'
------------------------------------------------------------
After running the script, I got the following result:
| before setting timeoutlen: {'lnum': 2, 'leftcol': 0, 'col': 4,
'topfill': 0, 'topline': 1, 'coladd': 0, 'skipcol': 0, 'curswant': 7}
| after setting timeoutlen: {'lnum': 2, 'leftcol': 0, 'col': 4,
'topfill': 0, 'topline': 1, 'coladd': 0, 'skipcol': 0, 'curswant': 4}
| before setting ttimeoutlen: {'lnum': 2, 'leftcol': 0, 'col': 4,
'topfill': 0, 'topline': 1, 'coladd': 0, 'skipcol': 0, 'curswant': 7}
| after setting ttimeoutlen: {'lnum': 2, 'leftcol': 0, 'col': 4,
'topfill': 0, 'topline': 1, 'coladd': 0, 'skipcol': 0, 'curswant': 4}
It's strange that "curswant" is reset by setting
'timeoutlen' and 'ttimeoutlen', because the cursor is not
moved explicitly. Is this behavior intended or not?
For example, I wrote a plugin (*) which allows users to map
simultaneously pressed keys to other key sequence. To
support this feature, it's necessary to tweak 'timeoutlen'
and 'ttimeoutlen' for each key press. And I define mapping
for simultaneously pressed "j" and "o" which is mapped to
:join a specific range. If "j" is not simultaneously
pressed with "o", the default behavior (moving the cursor to
the next line) will be invoked. But "curswant" is often
reset because of the above reason. So that it's annoying.
(*)
https://github.com/kana/vim-arpeggio