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

component_expand not called on badd command #341

Closed
mengelbrecht opened this Issue Jan 5, 2019 · 6 comments

Comments

Projects
None yet
2 participants
@mengelbrecht
Copy link

mengelbrecht commented Jan 5, 2019

I have a function registered as component_expand which displays the list of open buffers in the tabline section.
When adding a new buffer to the buffer list using e.g. :badd foo the registered component_expand function is not called and thus the list of buffers not updated (reported in mengelbrecht/lightline-bufferline#26).

When adding an autocmd group to call lightline#update on the BufAdd event the lightline#update function is called. However the lightline#update call somehow does not call the the registered component_expand function.

Minimal example vim config:

call plug#begin()
Plug 'itchyny/lightline.vim'
Plug 'mengelbrecht/lightline-bufferline'
call plug#end()

set nocompatible
set laststatus=2
set showtabline=2
set hidden
if has('gui_running')
  " Do not use gui tab apperance
  set guioptions-=e
endif

let g:lightline = {}
let g:lightline.tabline          = {'left': [['buffers']], 'right': [['close']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type   = {'buffers': 'tabsel'}

augroup Test
  au BufAdd    * call lightline#update()
augroup END
@itchyny

This comment has been minimized.

Copy link
Owner

itchyny commented Jan 6, 2019

I think this is a bug of vim and reported the problem to the vim repository vim/vim#3770.

@itchyny

This comment has been minimized.

Copy link
Owner

itchyny commented Jan 7, 2019

Note that lightline#update is not related to the tabline. The plugin sets &tabline to %!lightline#tabline() and Vim should reevaluate the function automatically.

@mengelbrecht

This comment has been minimized.

Copy link

mengelbrecht commented Jan 7, 2019

Thank you for explaining how the tabline feature works internally and for submitting the issue in the vim repository.
I guess this issue can be closed since it is a general vim issue and not related to lightline.

@itchyny

This comment has been minimized.

Copy link
Owner

itchyny commented Jan 8, 2019

We're discussing on the topic at the vim repo and not sure it will be fixed in Vim in short time. I suggest using au BufAdd * let &tabline = &tabline hack to force redraw instead of calling lightline#update.

@itchyny

This comment has been minimized.

Copy link
Owner

itchyny commented Jan 9, 2019

New command redrawtabline is added in Vim 8.1.0706. vim/vim@e12bab3, https://groups.google.com/d/msg/vim_dev/Vw2VyNmvHlc/FYVbnePcDwAJ
au BufAdd * redrawtabline should fix this problem.

@mengelbrecht

This comment has been minimized.

Copy link

mengelbrecht commented Jan 9, 2019

Thank you for your help. It works fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment