neovim / neovim

Vim-fork focused on extensibility and usability
https://neovim.io
Other
83.17k stars 5.69k forks source link

ruler doesn't update on `:redrawstatus` with `laststatus=1` #22804

Closed lucy closed 1 year ago

lucy commented 1 year ago

Problem

Ruler doesn't seem to get updated on :redrawstatus if you set laststatus=1. I encountered this because my lsp status indicator stopped working properly. This seems to also be broken in upstream vim but works in neovim v0.8.3.

Steps to reproduce

let g:n = 0
function! T(t)
    let g:n += 1
    redrawstatus
endfunction
call timer_start(1000, function('T'), {'repeat': -1})
set laststatus=1
set ruler
set rulerformat=%{g:n}

Expected behavior

Counter in ruler should increment every 1000ms.

Neovim version (nvim -v)

NVIM v0.9.0-dev-1292+geac75a971d

Vim (not Nvim) behaves the same?

yes, surprisingly. VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Mar 21 2023 20:51:42) Included patches: 1-1420

Operating system/version

Arch in WSL

Terminal name/version

Windows Terminal

$TERM environment variable

xterm-256color

Installation

AUR

justinmk commented 1 year ago

Related: https://github.com/neovim/neovim/issues/22683 , mentions a potential fix

luukvbaal commented 1 year ago

22843 fixes this issue but is actually not documented that :redrawstatus should redraw the commandline. Using :echo instead of :redrawstatus fixes the repro example, could that also apply to your lsp status indicator?

zeertzjq commented 1 year ago

In v0.8.3 the ruler is redrawn even without the :redrawstatus:

let g:n = 0
function! T(t)
    let g:n += 1
endfunction
call timer_start(1000, function('T'), {'repeat': -1})
set laststatus=1
set ruler
set rulerformat=%{g:n}

So I think the ruler being redrawn is actually a bug.

luukvbaal commented 1 year ago

The fact that it was redrawn was a "bug", the timer redrawed it implicitly. This was fixed in #22547.

luukvbaal commented 1 year ago

Nothing happens in the timer callback that should trigger a status redraw. Thus, if the user should want to update they should trigger it explicitly, in this case by :echo?

bfredl commented 1 year ago

I think with laststatus=0 or 1 and running redrawstatus in the last window (when it has a ruler instead of a full statusline), it should actually redraw the ruler (regardless of what vim/earlier nvim did or didn't do). I think that is more readable and less surprising than :echo (and more efficient in practice, unless plugins replicate a big-if statement for doing one or the other)

luukvbaal commented 1 year ago

OK, let me know if I should re-open https://github.com/neovim/neovim/pull/22843. Or take it up with Bram?

bfredl commented 1 year ago

our model has diverged from vim quite significantly. something like https://github.com/neovim/neovim/pull/22843 would be the fix for us.

luukvbaal commented 1 year ago

our model has diverged from vim quite significantly.

The problem is present in vim as well (like OP mentioned), so perhaps it makes sense to propose the patch anyways? It seems compatible still with their status_redraw_curbuf().

bfredl commented 1 year ago

Sure you (anyone) can post it on vim/vim if you want. The point was just we wanted get it done ourselves for 0.9 regardless.