Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status line indicates wrong window as having focus #2551

Open
ghost opened this issue Jul 15, 2022 · 14 comments
Open

Status line indicates wrong window as having focus #2551

ghost opened this issue Jul 15, 2022 · 14 comments

Comments

@ghost
Copy link

ghost commented Jul 15, 2022

environment

  • vim: 9.0
  • vim-airline: 0.11
  • OS: Ubuntu
  • Have you reproduced with a minimal vimrc: Yes
  • What is your airline configuration:

let g:airline_extensions = []
let g:airline_section_y = 'B:%{bufnr("%")}'

if you are using terminal:

  • terminal: alacritty
  • $TERM variable: tmux-256color
  • color configuration (:set t_Co?): t_Co=256
    if you are using Neovim:
  • does it happen in Vim: ???

actual behavior

Status line stays active in the quickfix window after running :make, even though the cursor is in the other window:

screenshot-220714-2357-23

Pressing a key shows the status line in the right window:

screenshot-220714-2357-43

expected behavior

The status line should indicate the window with the cursor after running :make

It is not clear if this bug is the same as #1914. The suggested fix there didn't work in this issue.

@chrisbra
Copy link
Member

do you have a quickfix plugin installed?

@ghost
Copy link
Author

ghost commented Jul 26, 2022

@chrisbra No quickfix plugin installed

@chrisbra
Copy link
Member

hm, so wait, please clariy:

  1. You type :make and Vim compiles your project and opens the quickfix window.
  2. You select a line in the quickfix window, type <cr> and Vim jumps to that line and opens that in a (possibly new) buffer but the status line is not updated?

What have you set for :set ei? makeprg?

@ghost
Copy link
Author

ghost commented Aug 17, 2022

The following screencast shows the same behavior in a different environment. Notice that the window focused by vim-airline is not the same window that contains the cursor. After moving the cursor to the right, vim-airline changes the highlighted window. In summary:

  1. That's possible, but you can just open the quickfix window manually, then run :make and you will see the same behavior.
  2. Not really. The cursor stays in the same position, but vim-airline highlights the quickfix window. After moving your cursor in any way, then vim-airline highlights the correct window.

makeprg's value doesn't seem to be important. It was set to go run % in my previous example and python3 % in this screencast. ei is set to its default value (eventignore=).

screencast-220817-1508-25.mp4

@chrisbra
Copy link
Member

Okay, let's back up and try to reproduce with a minimum vimrc file:

 vim --clean -u <(cat <<EOF
set nocompatible
set bg=dark
set termguicolors
filetype plugin indent on
syntax enable
let &rtp  = '~/.vim/pack/minpac/start/vim-airline,' . &rtp
EOF
) -c ":call setqflist([{'filename': expand('~/.vim/vimrc'), 'lnum': 1}])" -c ':copen'

Now press enter in the quickfix window. Does this update the statusline?

@chrisbra
Copy link
Member

if it does, there is something wrong with your configuration (possibly a plugin), if it does not, there is something wrong with vim. You may need to debug the on_window_changed() function in plugin/airline.vim

@ghost
Copy link
Author

ghost commented Aug 18, 2022

I don't think I ever said anything about pressing enter in the quickfix window. As I said before, I'm simply pressing l to move the cursor to the right. Just to be clarify that point, the cursor is not moving to other windows, but vim-airline shows the status line in the wrong window (in this case, the quickfix window).

I was able to replicate the same behavior using your configuration. As you can see, it is a bit inconsistent (the second :make failed to trigger this behavior) but it is easy to replicate the bug.

screencast-220817-1948-20.mp4

For the record, the default status line (or even lightline.vim) doesn't show the same behavior, so I don't think there is anything wrong with vim.

@chrisbra
Copy link
Member

ah I forgot, when typing :make vim will automatically place the cursor on the first line with error. I usually do not use this.
But still, Vim should execute WinEnter autocommands and this should make vim-airline update. Can you please set :set verbose=9 verbosefile=/tmp/vim_verbose.log and share the file?

@chrisbra
Copy link
Member

oh and can you possibly try the following patch please?

diff --git a/plugin/airline.vim b/plugin/airline.vim
index e2d0d28..7b311e6 100644
--- a/plugin/airline.vim
+++ b/plugin/airline.vim
@@ -62,13 +62,13 @@ function! s:on_window_changed(event)
   " Handle each window only once, since we might come here several times for
   " different autocommands.
   let l:key = [bufnr('%'), s:active_winnr, winnr('$'), tabpagenr(), &ft]
-  if get(g:, 'airline_last_window_changed', []) == l:key
-        \ && &stl is# '%!airline#statusline('.s:active_winnr.')'
-        \ && &ft !~? 'gitcommit'
-    " fugitive is special, it changes names and filetypes several times,
-    " make sure the caching does not get into its way
-    return
-  endif
+"  if get(g:, 'airline_last_window_changed', []) == l:key
+"        \ && &stl is# '%!airline#statusline('.s:active_winnr.')'
+"        \ && &ft !~? 'gitcommit'
+"    " fugitive is special, it changes names and filetypes several times,
+"    " make sure the caching does not get into its way
+"    return
+"  endif
   let g:airline_last_window_changed = l:key
   call s:init()
   call airline#update_statusline()

@ghost
Copy link
Author

ghost commented Aug 18, 2022

Sure, here you can see the log file: http://ix.io/47Ve

Are you sure that's the right patch? I can't see any difference.

@chrisbra
Copy link
Member

Sure, here you can see the log file: http://ix.io/47Ve

thanks, so the WinEnter autocommand is executed. Did you run :make 3 times?

Are you sure that's the right patch? I can't see any difference.

Well debugging here and my guess was that that check skips the update. So apparently this wasn't the case.

I still don't not sure, why it wouldn't update the statusline.

@ghost
Copy link
Author

ghost commented Aug 18, 2022

thanks, so the WinEnter autocommand is executed. Did you run :make 3 times?

That's correct. I believe the first try didn't replicate the issue, so I ran :make two more times.

Well debugging here and my guess was that that check skips the update. So apparently this wasn't the case.

The thing is that I applied the patch, but that didn't fix the issue. However, I can't see which lines are changing with respect to the previous version, which is why I asked if this is the right patch.

@chrisbra
Copy link
Member

chrisbra commented Sep 8, 2022

sorry, I did not follow. Did you apply the patch or not? And did it work or not?

@ghost
Copy link
Author

ghost commented Sep 8, 2022

Yes, I applied the patch and it didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant