"curswant" is unexpectedly reset by setting 'timeoutlen'/'ttimeoutlen' in some context

28 views
Skip to first unread message

Kana Natsuno

unread,
Nov 11, 2011, 6:35:16 AM11/11/11
to vim_dev
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

Andy Wokula

unread,
Nov 11, 2011, 8:04:59 AM11/11/11
to vim...@googlegroups.com
Am 11.11.2011 12:35, schrieb Kana Natsuno:
> I found that Vim unexpectedly resets "curswant" in some
> context. Try the following steps to reproduce the problem:

I think this one explains it:

:h todo

7 Setting an option always sets "w_set_curswant", while this is only
required for a few options. Only do it for those options to avoid the
side effect.

--
Andy

Kana Natsuno

unread,
Nov 11, 2011, 8:20:51 AM11/11/11
to vim...@googlegroups.com

Thank you for the information.
I'll try to make a patch for the problem.

Kana Natsuno

unread,
Nov 11, 2011, 10:13:26 AM11/11/11
to vim...@googlegroups.com

I've made a patch and a test for the problem. See the
attached file. It's just a skeleton to solve the problem.
Please give me any suggestion to improve the patch.

vim-keep-curswant.patch

Bram Moolenaar

unread,
Nov 19, 2011, 3:33:04 PM11/19/11
to Kana Natsuno, vim...@googlegroups.com

Kana Natsuno wrote:

Thanks for the patch. I'll look into it later.

--
hundred-and-one symptoms of being an internet addict:
156. You forget your friend's name but not her e-mail address.

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

Reply all
Reply to author
Forward
0 new messages