From 1afe1e9bd5726550014d78ee244499d65beeb686 Mon Sep 17 00:00:00 2001 From: itchyny Date: Tue, 30 Jul 2019 18:52:28 +0900 Subject: [PATCH] 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 --- .travis.yml | 1 + autoload/lightline.vim | 7 +++++-- plugin/lightline.vim | 12 ++++++++++-- test/.themisrc | 2 ++ test/quickfix.vim | 25 +++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 test/quickfix.vim diff --git a/.travis.yml b/.travis.yml index b0225d8..12a0d2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/autoload/lightline.vim b/autoload/lightline.vim index 59abb23..a3de485 100644 --- a/autoload/lightline.vim +++ b/autoload/lightline.vim @@ -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('') !=# 'macvim' \ | call lightline#update() | call lightline#highlight() | endif diff --git a/plugin/lightline.vim b/plugin/lightline.vim index fc8f598..d08517d 100644 --- a/plugin/lightline.vim +++ b/plugin/lightline.vim @@ -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('') !=# '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 diff --git a/test/.themisrc b/test/.themisrc index c226c08..6e0121c 100644 --- a/test/.themisrc +++ b/test/.themisrc @@ -18,3 +18,5 @@ endfunction function! SID(name) abort return function(printf("\%d_%s", s:sid('autoload/lightline.vim'), a:name)) endfunction + +filetype plugin on diff --git a/test/quickfix.vim b/test/quickfix.vim new file mode 100644 index 0000000..df4fce7 --- /dev/null +++ b/test/quickfix.vim @@ -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