From a85d9017fd68f4d51c8d80a888fba7e8f0681497 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 22 Jun 2013 19:32:56 +0400 Subject: [PATCH] In place of failure create new window ID in case of duplicate ID Fixes #545 Fixes #537 --- powerline/vim.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerline/vim.py b/powerline/vim.py index b658b8df..b9cf5820 100644 --- a/powerline/vim.py +++ b/powerline/vim.py @@ -101,6 +101,8 @@ class VimPowerline(Powerline): for window in vim.windows: try: curwindow_id = window.vars['powerline_window_id'] + if r is not None and curwindow_id == window_id: + raise KeyError except KeyError: curwindow_id = self.last_window_id self.last_window_id += 1 @@ -109,7 +111,6 @@ class VimPowerline(Powerline): if window.options['statusline'] != statusline: window.options['statusline'] = statusline 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) return r else: @@ -120,7 +121,7 @@ class VimPowerline(Powerline): r = None for winnr, window in zip(count(1), vim.windows): 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) else: curwindow_id = self.last_window_id @@ -130,7 +131,6 @@ class VimPowerline(Powerline): if self._vim_getwinvar(winnr, '&statusline') != statusline: self._vim_setwinvar(winnr, '&statusline', statusline) 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) return r