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

Tabline showing wrongnames #2365

Open
Deshdeepak1 opened this issue Apr 20, 2021 · 17 comments
Open

Tabline showing wrongnames #2365

Deshdeepak1 opened this issue Apr 20, 2021 · 17 comments

Comments

@Deshdeepak1
Copy link

environment

  • vim: nvim 0.5
  • vim-airline: 0.11
  • OS: arch linux
  • Have you reproduced with a minimal vimrc: Yes
  • What is your airline configuration:
set nocompatible
set runtimepath^=~/.local/share/nvim/plugged/vim-airline
set runtimepath^=~/.local/share/nvim/plugged/gruvbox
syntax on
colo gruvbox
filetype plugin indent on
let g:airline#extensions#tabline#enabled = 1

if you are using terminal:

  • terminal: Konsole
  • $TERM variable: xterm-256color
  • color configuration (:set t_Co?):
    if you are using Neovim:
  • does it happen in Vim: Don't know

actual behavior

See Tabline, Both 2nd and 3rd have same name, but actually have different files in them if I navigate.

Screenshot_20210420_135903

expected behavior

After :AirlineToggle . We can see the last tab had starify.vim instead vim-which-key.vim
So Airline was creating the problem.

Screenshot_20210420_140214

@chrisbra
Copy link
Member

how to reproduce?

@Deshdeepak1
Copy link
Author

I just noticed it works completely fine, but this only happens if I open startify.vim

  1. Create mini.vim with my code.
  2. Open startify.vim : vim -u ~/mini.vim ~/.config/nvim/plug_config/startify.vim . Write anything in it .
  3. Open New tabs with different files.

@chrisbra
Copy link
Member

is startify needed? Also, what do you mean with open new tabs with different files? Please be precise.

@Deshdeepak1
Copy link
Author

is startify needed?
I don't think its needed, because I didn't use startify in mini.vim, but maybe a file with same path as mentioned above might be required.
Also, what do you mean with open new tabs with different files? Please be precise.
:tabnew ~/.bashrc
:tabnew ~/.tmux.conf
,etc

@chrisbra
Copy link
Member

I cannot reproduce:

" make it work with tiny Vim
if 1
  set nocp bs=2
  filetype plugin indent on
  syn on
  set t_Co=256 bg=dark wildmenu
  packloadall
  let g:airline#extensions#tabline#enabled = 1
endif

image
image

That means, the tabs are exactly as they should. Please also show the output of :tabs

@katawful
Copy link

I also experience this, but cannot find a way to replicate it

@ChunYoLin
Copy link

also experience this, very hard to reproduce

@yuanshi1602
Copy link

yuanshi1602 commented Sep 1, 2021

this happens if call:NERDTreeToggle

@chrisbra
Copy link
Member

chrisbra commented Dec 3, 2021

please provide exact reproduction steps.

@teranex
Copy link

teranex commented Jan 26, 2022

I see the same behaviour. When I use Vimwiki with different tabs, they seem to show the correct titles, but when I then do :tab help vimwiki (for example) and switch back to a vimwiki buffer, then the tab with the help file shows the filename from a vimwiki file as the tab title

Example after opening the help file:
20220126_001

After switching back to the vimwiki file with gt
20220126_002

@UglyNoob
Copy link

I don't know how to reproduce wrongnames of tabs of actual files, but the problem of wrongnames of nvim-builtin terminals is easy to reproduce. Create a terminal tab and switch to anothor tab, the label will change to be the same as current tab's, which is not the expected behavior.

@KSR-Yasuda
Copy link
Contributor

KSR-Yasuda commented Apr 5, 2022

When I use Vimwiki with different tabs, they seem to show the correct titles, but when I then do :tab help vimwiki (for example) and switch back to a vimwiki buffer, then the tab with the help file shows the filename from a vimwiki file as the tab title

Perhaps some plugin's window is likely to make this issue
(I don't see actually WHAT, though...).

Opening netrw window is the same:

  1. Open any directory by netrw (tab # 1)
    • :e ./
  2. Open another tab (tab # 2) and set some name
    • :tabnew
    • :f a
  3. Then you find the netrw tab # 1 is labeled as the name of tab # 2
    • Looks active tab name is used.
      If open another tab # 3 and move to it, the tab # 1 is labeled as the tab # 3's name.

@KSR-Yasuda
Copy link
Contributor

Changing below fixes to show correct netrw tab name.

Probably windows not listed in all_buffers makes the problem.

--- a/autoload/airline/extensions/tabline.vim
+++ b/autoload/airline/extensions/tabline.vim
@@ -215,7 +215,7 @@ if !exists(":def") || !airline#util#has_vim9_script()
       let buflist = tabpagebuflist(a:n)
       let winnr = tabpagewinnr(a:n)
       let all_buffers = airline#extensions#tabline#buflist#list()
-      let curbuf = filter(buflist, 'index(all_buffers, v:val) != -1')
+      let curbuf = buflist
       if len(curbuf) ==  0
         call add(curbuf, tabpagebuflist()[0])
       endif

@KSR-Yasuda
Copy link
Contributor

Or, changing as below:

--- a/autoload/airline/extensions/tabline/buflist.vim
+++ b/autoload/airline/extensions/tabline/buflist.vim
@@ -52,7 +52,7 @@ function! airline#extensions#tabline#buflist#list()
   " Basically branch 535 already does it, but since it relies on
   " BufAdd autocommand, I'd like to avoid this if possible.
   for nr in list
-    if buflisted(nr)
+    if bufloaded(nr)
       " Do not add to the bufferlist, if either
       " 1) bufnr is exclude_buffers list
       " 2) buffername matches one of exclude_paths patterns

So, nobuflisted windows are dropped here, and considered non-existent buffers to make this problem.

@KSR-Yasuda
Copy link
Contributor

#2169 is the same?

@KSR-Yasuda
Copy link
Contributor

Also, this looks a bug:

--- a/autoload/airline/extensions/tabline.vim
+++ b/autoload/airline/extensions/tabline.vim
@@ -217,7 +217,7 @@ if !exists(":def") || !airline#util#has_vim9_script()
       let all_buffers = airline#extensions#tabline#buflist#list()
       let curbuf = filter(buflist, 'index(all_buffers, v:val) != -1')
       if len(curbuf) ==  0
-        call add(curbuf, tabpagebuflist()[0])
+        call add(curbuf, tabpagebuflist(a:n)[0])
       endif
       return airline#extensions#tabline#get_buffer_name(curbuf[0], curbuf)
     endif

@KSR-Yasuda
Copy link
Contributor

Anyway raised a pull request, though, went bad with the tests...

Can anyone fix it?

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

8 participants