primitivus (chat): fixed crash when removing focus_marker after a :search or :history command

This commit is contained in:
Goffi 2019-04-10 21:07:47 +02:00
commit 4a0d1701fc

View file

@ -436,12 +436,17 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat):
if self.handleUserMoved(message):
return
if (
self.host.selected_widget != self or not self.host.x_notify.hasFocus()
) and self.focus_marker_set is not None:
if ((self.host.selected_widget != self or not self.host.x_notify.hasFocus())
and self.focus_marker_set is not None):
if not self.focus_marker_set and not self._locked and self.mess_walker:
if self.focus_marker is not None:
self.mess_walker.remove(self.focus_marker)
try:
self.mess_walker.remove(self.focus_marker)
except ValueError:
# self.focus_marker may not be in mess_walker anymore if
# mess_walker has been cleared, e.g. when showing search
# result or using :history command
pass
self.focus_marker = urwid.Divider("—")
self.mess_walker.append(self.focus_marker)
self.focus_marker_set = True