strange vim-airline bug

18 views
Skip to first unread message

Christian Brabandt

unread,
Oct 31, 2019, 5:19:22 AM10/31/19
to vim...@vim.org
Hi,
I just received a bug for vim-airline for which I suspect this might be
caused by a vim particularity. The bug is here:
https://github.com/vim-airline/vim-airline/issues/1989

The symptom is, that if one uses 'R' and replaces a bit, and right after
that presses 'r' the statusline switches to 'REPLACE' mode, which is
wrong. However the next time you press 'r', it won't switch to
'REPLACE'. However I see this behaviour only on Windows gvim, not in
the terminal.

The whole mode, is always updated every time the statusline is
re-evaluated, by throwing a function airline#check_mode into the
statusline.

What this function does essentially is check `mode(1)` and update the
string that will be displayed (and if the mode changes, it might as well
update a couple of highlighting groups).

Now, I did debug this a bit and the thing is, that apparently `mode(1)`
keeps returning `R`, even so, it should return 'n' after pressing `r`. I
am a bit at loss at why this happens and I looked at the source f_mode()
but don't see what would cause this. In nv_replace I see that sometimes
the State will be updated to `REPLACE` for the 'r' command and I guess
this might be the cause for that, perhaps because it recursively forces
a screen update, but I am wondering why I only see this with gvim and
I don't see this behaviour with a `vim --clean -c'set stl=%{mode(1)}'`.

Anybody has an idea how to "fix" this behaviour? However, I am not sure
it is worth the trouble at all.

Best,
Christian
--
Als ich die Lust zur Sinnnlichkeit entdeckte, habe ich an Gott zu
glauben aufgehört. Denn er stahl mir die Erde.
-- Simone de Beauvoir

Bram Moolenaar

unread,
Oct 31, 2019, 2:58:19 PM10/31/19
to vim...@googlegroups.com, Christian Brabandt, vim...@vim.org
AFAIK mode() will return "R" when the user just typed "r". It's not
really replace mode, but it's in the state similar to replace mode.

However, it may be different if CURSOR_SHAPE is not defined. I suppose
that's a bit inconsistent. We can change that.

--
hundred-and-one symptoms of being an internet addict:
15. Your heart races faster and beats irregularly each time you see a new WWW
site address in print or on TV, even though you've never had heart
problems before.

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