In place of failure create new window ID in case of duplicate ID

Fixes #545
Fixes #537
This commit is contained in:
ZyX 2013-06-22 19:32:56 +04:00
parent 2758c349db
commit a85d9017fd
1 changed files with 3 additions and 3 deletions

View File

@ -101,6 +101,8 @@ class VimPowerline(Powerline):
for window in vim.windows: for window in vim.windows:
try: try:
curwindow_id = window.vars['powerline_window_id'] curwindow_id = window.vars['powerline_window_id']
if r is not None and curwindow_id == window_id:
raise KeyError
except KeyError: except KeyError:
curwindow_id = self.last_window_id curwindow_id = self.last_window_id
self.last_window_id += 1 self.last_window_id += 1
@ -109,7 +111,6 @@ class VimPowerline(Powerline):
if window.options['statusline'] != statusline: if window.options['statusline'] != statusline:
window.options['statusline'] = statusline window.options['statusline'] = statusline
if curwindow_id == window_id if window_id else window is vim.current.window: if curwindow_id == window_id if window_id else window is vim.current.window:
assert r is None, "Non-unique window ID"
r = (window, curwindow_id, window.number) r = (window, curwindow_id, window.number)
return r return r
else: else:
@ -120,7 +121,7 @@ class VimPowerline(Powerline):
r = None r = None
for winnr, window in zip(count(1), vim.windows): for winnr, window in zip(count(1), vim.windows):
curwindow_id = self._vim_getwinvar(winnr, 'powerline_window_id') curwindow_id = self._vim_getwinvar(winnr, 'powerline_window_id')
if curwindow_id: if curwindow_id and not (r is not None and curwindow_id == window_id):
curwindow_id = int(curwindow_id) curwindow_id = int(curwindow_id)
else: else:
curwindow_id = self.last_window_id curwindow_id = self.last_window_id
@ -130,7 +131,6 @@ class VimPowerline(Powerline):
if self._vim_getwinvar(winnr, '&statusline') != statusline: if self._vim_getwinvar(winnr, '&statusline') != statusline:
self._vim_setwinvar(winnr, '&statusline', statusline) self._vim_setwinvar(winnr, '&statusline', statusline)
if curwindow_id == window_id if window_id else window is vim.current.window: if curwindow_id == window_id if window_id else window is vim.current.window:
assert r is None, "Non-unique window ID"
r = (window, curwindow_id, winnr) r = (window, curwindow_id, winnr)
return r return r