diff --git a/autoload/wrapwidth.vim b/autoload/wrapwidth.vim index 1e9a86e..b8d52e6 100644 --- a/autoload/wrapwidth.vim +++ b/autoload/wrapwidth.vim @@ -87,9 +87,10 @@ function! s:SetEvent() abort let bl = filter(range(1, bufnr('$')), 'getbufvar(v:val, s:ww, 0) != 0') let ac = ['augroup ' . s:ww, 'autocmd!'] if !empty(bl) - for ev in ['OptionSet', 'WinScrolled', 'TextChanged,InsertLeave'] + " shane: adding 'BufEnter' is to make it work when/if switched buf by 'c-^' + for ev in ['OptionSet', 'WinScrolled', 'TextChanged,InsertLeave', 'BufEnter'] let [ea, eb] = ['autocmd ' . ev, 'call s:CheckEvent(''' . ev[0] . ''')'] - if ev[0] == 'T' + if ev[0] == 'T' || ev[0] == 'B' for bn in bl | let ac += [ea . ' ' . eb] | endfor else let ac += [ea . ' * ' . eb] @@ -126,6 +127,8 @@ function! s:CheckEvent(ev) abort endfor elseif a:ev == 'T' " TextChanged or InsertLeave let wl += [cw] + elseif a:ev == 'B' " BufEnter + let wl += [cw] endif " select one win per buf (in case of splitted) let bw = {}