mirror of
https://github.com/powerline/powerline.git
synced 2025-07-30 01:05:42 +02:00
Don't use UUID for window IDs
This fix uses an incremented number instead. Fixes #180
This commit is contained in:
parent
861f7dc179
commit
3c62e060be
@ -18,7 +18,6 @@ endif
|
|||||||
let s:powerline_pycmd = substitute(get(g:, 'powerline_pycmd', 'py'), '\v^(py)%[thon](3?)$', '\1\2', '')
|
let s:powerline_pycmd = substitute(get(g:, 'powerline_pycmd', 'py'), '\v^(py)%[thon](3?)$', '\1\2', '')
|
||||||
let s:powerline_pyeval = get(g:, 'powerline_pyeval', s:powerline_pycmd.'eval')
|
let s:powerline_pyeval = get(g:, 'powerline_pyeval', s:powerline_pycmd.'eval')
|
||||||
|
|
||||||
exec s:powerline_pycmd 'import uuid'
|
|
||||||
try
|
try
|
||||||
exec s:powerline_pycmd 'from powerline.core import Powerline'
|
exec s:powerline_pycmd 'from powerline.core import Powerline'
|
||||||
catch
|
catch
|
||||||
@ -47,15 +46,17 @@ else
|
|||||||
\"endfunction"
|
\"endfunction"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let s:last_window_id = 0
|
||||||
function! s:GetWinID(winnr)
|
function! s:GetWinID(winnr)
|
||||||
let r = getwinvar(a:winnr, 'window_id')
|
let r = getwinvar(a:winnr, 'window_id')
|
||||||
if empty(r)
|
if empty(r)
|
||||||
let r = s:pyeval('str(uuid.uuid4())')
|
let r = s:last_window_id
|
||||||
|
let s:last_window_id += 1
|
||||||
call setwinvar(a:winnr, 'window_id', r)
|
call setwinvar(a:winnr, 'window_id', r)
|
||||||
endif
|
endif
|
||||||
" Without this condition it triggers unneeded statusline redraw
|
" Without this condition it triggers unneeded statusline redraw
|
||||||
if getwinvar(a:winnr, '&statusline') isnot# '%!Powerline("'.r.'")'
|
if getwinvar(a:winnr, '&statusline') isnot# '%!Powerline('.r.')'
|
||||||
call setwinvar(a:winnr, '&statusline', '%!Powerline("'.r.'")')
|
call setwinvar(a:winnr, '&statusline', '%!Powerline('.r.')')
|
||||||
endif
|
endif
|
||||||
return r
|
return r
|
||||||
endfunction
|
endfunction
|
||||||
@ -63,14 +64,14 @@ endfunction
|
|||||||
function! Powerline(window_id)
|
function! Powerline(window_id)
|
||||||
let winidx = index(map(range(1, winnr('$')), 's:GetWinID(v:val)'), a:window_id)
|
let winidx = index(map(range(1, winnr('$')), 's:GetWinID(v:val)'), a:window_id)
|
||||||
let current = w:window_id is# a:window_id
|
let current = w:window_id is# a:window_id
|
||||||
return s:pyeval('powerline.renderer.render("'. a:window_id .'", '. winidx .', '. current .')')
|
return s:pyeval('powerline.renderer.render('. a:window_id .', '. winidx .', '. current .')')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! PowerlineNew()
|
function! PowerlineNew()
|
||||||
call map(range(1, winnr('$')), 's:GetWinID(v:val)')
|
call map(range(1, winnr('$')), 's:GetWinID(v:val)')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Is immediately changed when Powerline() function is run. Good for global
|
" Is immediately changed when PowerlineNew() function is run. Good for global
|
||||||
" value.
|
" value.
|
||||||
set statusline=%!PowerlineNew()
|
set statusline=%!PowerlineNew()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user