change events for updating the statusline, from BufWinEnter,FileType to BufEnter (close #352)

- fix the active statusline after updating the quickfix/location list
- use g:qf_disable_statusline to disable the statusline of the default ftplugin
- for before Vim 8.1.1715, keep using FileType event to overwrite the statusline of the quickfix window
This commit is contained in:
itchyny
2019-07-30 18:52:28 +09:00
parent f2a1f47c85
commit 1afe1e9bd5
5 changed files with 43 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ cache:
- $HOME/vim-$VIM_VERSION
env:
- VIM_VERSION=8.1.1775
- VIM_VERSION=8.1.1700
- VIM_VERSION=8.1.0000
- VIM_VERSION=8.0.0000

View File

@@ -2,7 +2,7 @@
" Filename: autoload/lightline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2019/07/20 12:00:00.
" Last Change: 2019/07/30 12:00:00.
" =============================================================================
let s:save_cpo = &cpo
@@ -46,7 +46,10 @@ function! lightline#enable() abort
call lightline#update()
augroup lightline
autocmd!
autocmd WinEnter,BufWinEnter,FileType,SessionLoadPost * call lightline#update()
autocmd WinEnter,BufEnter,SessionLoadPost * call lightline#update()
if !has('patch-8.1.1715')
autocmd FileType qf call lightline#update()
endif
autocmd SessionLoadPost * call lightline#highlight()
autocmd ColorScheme * if !has('vim_starting') || expand('<amatch>') !=# 'macvim'
\ | call lightline#update() | call lightline#highlight() | endif

View File

@@ -2,7 +2,7 @@
" Filename: plugin/lightline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2018/06/22 08:49:00.
" Last Change: 2019/07/30 12:00:00.
" =============================================================================
if exists('g:loaded_lightline') || v:version < 700
@@ -15,12 +15,20 @@ set cpo&vim
augroup lightline
autocmd!
autocmd WinEnter,BufWinEnter,FileType,SessionLoadPost * call lightline#update()
autocmd WinEnter,BufEnter,SessionLoadPost * call lightline#update()
if !has('patch-8.1.1715')
autocmd FileType qf call lightline#update()
endif
autocmd SessionLoadPost * call lightline#highlight()
autocmd ColorScheme * if !has('vim_starting') || expand('<amatch>') !=# 'macvim'
\ | call lightline#update() | call lightline#highlight() | endif
autocmd CursorMoved,BufUnload * call lightline#update_once()
augroup END
" This quickfix option was introduced at Vim 85850f3a5ef9, which is the commit
" just before 8.1.1715. Before this patch, autocmd FileType is required to
" overwrite the statusline of the quickfix and location windows.
let g:qf_disable_statusline = 1
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@@ -18,3 +18,5 @@ endfunction
function! SID(name) abort
return function(printf("\<SNR>%d_%s", s:sid('autoload/lightline.vim'), a:name))
endfunction
filetype plugin on

25
test/quickfix.vim Normal file
View File

@@ -0,0 +1,25 @@
let s:suite = themis#suite('quickfix')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
let g:lightline = {}
call lightline#init()
tabnew
tabonly
endfunction
function! s:suite.quickfix_statusline()
call setloclist(winnr(), [])
lopen
wincmd p
call setloclist(winnr(), [])
for n in range(1, winnr('$'))
let statusline = getwinvar(n, '&statusline')
call s:assert.match(statusline, 'lightline')
if has('patch-8.1.1715')
call s:assert.match(statusline, n == 1 ? '_active_' : '_inactive_')
else
call s:assert.match(statusline, n != 1 ? '_active_' : '_inactive_')
endif
endfor
endfunction