From 09b5eb952c9376579ad22a923a50f9371699a037 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Thu, 8 Nov 2018 12:17:40 +0100 Subject: [PATCH] highlighter: Only recreate hi groups for visible buffers In a long editing session, there could happen to accumulate several highlighting groups for buffers that might no longer be visible. Therefore, only re-create the highlighting group for buffers that are actually displayed in the current tabpage. If not, skip them. references #1779 --- autoload/airline/highlighter.vim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index c803da7..5e85818 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -235,7 +235,11 @@ function! airline#highlighter#highlight(modes, ...) " draw the base mode, followed by any overrides let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val') let suffix = a:modes[0] == 'inactive' ? '_inactive' : '' - let airline_grouplist=[] + let airline_grouplist = [] + let buffers_in_tabpage = sort(tabpagebuflist()) + if exists("*uniq") + let buffers_in_tabpage = uniq(buffers_in_tabpage) + endif " mapped might be something like ['normal', 'normal_modified'] " if a group is in both modes available, only define the second " that is how this was done previously overwrite the previous definition @@ -248,6 +252,14 @@ function! airline#highlighter#highlight(modes, ...) if name is# 'airline_c' && !empty(bufnr) && suffix is# '_inactive' let name = 'airline_c'.bufnr endif + " do not re-create highlighting for buffers that are no longer visible + " in the current tabpage + if name[0:8] is# 'airline_c' + let bnr = matchstr(name, 'airline_c\\zs\d\+') + 0 + if index(buffers_in_tabpage, bnr) == -1 + continue + endif + endif if s:group_not_done(airline_grouplist, name.suffix) call airline#highlighter#exec(name.suffix, mode_colors) endif