Skip to content

Commit 9cf25af

Browse files
committed
bugfix: views: Left strip search text to avoid empty search results.
Tests amended.
1 parent 49d3fa5 commit 9cf25af

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

tests/ui/test_ui_tools.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ def test_init(self, mocker, stream_view):
418418
('test', ['test here'], []),
419419
('here', ['test here'], []),
420420
('test here', ['test here'], []),
421+
(' ', ['bar', 'boo', 'BOO', 'fan', 'FOO', 'foo', 'FOOBAR',
422+
'test here'], []),
421423
# With 'foo' pinned.
422424
('f', ['foo', 'fan', 'FOO', 'FOOBAR'], [['foo'], ]),
423425
('FOO', ['foo', 'FOO', 'FOOBAR'], [['foo'], ]),
@@ -546,6 +548,8 @@ def test_init(self, mocker, topic_view):
546548
('FOO', ['FOO', 'FOOBAR', 'foo']),
547549
('(no', ['(no topic)']),
548550
('topic', ['(no topic)']),
551+
(' ', ['FOO', 'FOOBAR', 'foo', 'fan', 'boo', 'BOO', 'bar',
552+
'(no topic)']),
549553
])
550554
def test_update_topics(self, mocker, topic_view, new_text, expected_log):
551555
topic_names = [
@@ -979,9 +983,10 @@ def test_update_user_list_editor_mode(self, mocker, right_col_view):
979983
@pytest.mark.parametrize(['search_string', 'assert_list',
980984
'match_return_value'], [
981985
('U', ["USER1", "USER2"], True),
982-
('F', [], False)
986+
('F', [], False),
987+
(' ', ["USER1", "USER2"], True),
983988
], ids=[
984-
'user match', 'no user match',
989+
'user match', 'no user match', 'no search',
985990
])
986991
def test_update_user_list(self, right_col_view, mocker,
987992
search_string, assert_list, match_return_value):
@@ -1002,7 +1007,6 @@ def test_update_user_presence(self, right_col_view, mocker,
10021007
set_body = mocker.patch(VIEWS + ".urwid.Frame.set_body")
10031008

10041009
right_col_view.update_user_list(user_list=user_list)
1005-
10061010
right_col_view.users_view.assert_called_with(user_list)
10071011
set_body.assert_called_once_with(right_col_view.body)
10081012

zulipterminal/ui_tools/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def __init__(self, streams_btn_list: List[Any], view: Any) -> None:
264264

265265
@asynch
266266
def update_streams(self, search_box: Any, new_text: str) -> None:
267+
new_text = new_text.lstrip()
267268
if not self.view.controller.is_in_editor_mode():
268269
return
269270
# wait for any previously started search to finish to avoid
@@ -331,6 +332,7 @@ def __init__(self, topics_btn_list: List[Any], view: Any,
331332

332333
@asynch
333334
def update_topics(self, search_box: Any, new_text: str) -> None:
335+
new_text = new_text.lstrip()
334336
if not self.view.controller.is_in_editor_mode():
335337
return
336338
# wait for any previously started search to finish to avoid
@@ -563,6 +565,7 @@ def __init__(self, width: int, view: Any) -> None:
563565
def update_user_list(self, search_box: Any=None,
564566
new_text: str="",
565567
user_list: Any=None) -> None:
568+
new_text = new_text.lstrip()
566569

567570
assert ((user_list is None and search_box is not None)
568571
or (user_list is not None and search_box is None

0 commit comments

Comments
 (0)