Increase min debounce period, stop searching on user nav selection

symbol_search
Tyler Goodlet 2021-05-28 09:41:24 -04:00
parent 50aff72f8e
commit c56c7b8540
1 changed files with 16 additions and 16 deletions

View File

@ -404,8 +404,17 @@ class CompleterView(QTreeView):
# this stuff is super finicky and if not done right will cause # this stuff is super finicky and if not done right will cause
# Qt crashes out our buttz. it's required in order to get the # Qt crashes out our buttz. it's required in order to get the
# view to show right after typing input. # view to show right after typing input.
self.select_first() self.select_first()
# TODO: the way we might be able to do this more sanely is,
# 1. for the currently selected item, when start rewriting
# a section figure out the row, column, parent "abstract"
# position in the tree view and store it
# 2. take that position and re-apply the selection to the new
# model/tree by looking up the new "equivalent element" and
# selecting
self.show_matches() self.show_matches()
def show_matches(self) -> None: def show_matches(self) -> None:
@ -681,7 +690,7 @@ async def fill_results(
recv_chan: trio.abc.ReceiveChannel, recv_chan: trio.abc.ReceiveChannel,
# kb debouncing pauses (bracket defaults) # kb debouncing pauses (bracket defaults)
min_pause_time: float = 0.0616, min_pause_time: float = 0.1,
max_pause_time: float = 6/16, max_pause_time: float = 6/16,
) -> None: ) -> None:
@ -697,7 +706,6 @@ async def fill_results(
last_text = bar.text() last_text = bar.text()
repeats = 0 repeats = 0
last_patt = None
# cache of prior patterns to search results # cache of prior patterns to search results
matches = defaultdict(list) matches = defaultdict(list)
@ -776,7 +784,7 @@ async def fill_results(
) )
else: # already has results for this input text else: # already has results for this input text
results = matches[(provider, text)] results = matches[(provider, text)]
if results: if results and provider != 'cache':
view.set_section_entries( view.set_section_entries(
section=provider, section=provider,
values=results, values=results,
@ -784,10 +792,6 @@ async def fill_results(
else: else:
view.clear_section(provider) view.clear_section(provider)
if last_patt is None or last_patt != text:
view.select_first()
last_patt = text
bar.show() bar.show()
@ -874,11 +878,13 @@ async def handle_keyboard_input(
Qt.Key_D, Qt.Key_D,
}: }:
view.next_section(direction='down') view.next_section(direction='down')
_search_enabled = False
elif ctl and key in { elif ctl and key in {
Qt.Key_U, Qt.Key_U,
}: }:
view.next_section(direction='up') view.next_section(direction='up')
_search_enabled = False
# selection navigation controls # selection navigation controls
elif (ctl and key in { elif (ctl and key in {
@ -903,14 +909,8 @@ async def handle_keyboard_input(
if parent_item and parent_item.text() == 'cache': if parent_item and parent_item.text() == 'cache':
value = search.get_current_item() # if it's a cache item, switch and show it immediately
if value is not None: search.chart_current_item(clear_to_cache=False)
provider, symbol = value
chart.load_symbol(
provider,
symbol,
'info',
)
elif not ctl: elif not ctl:
# relay to completer task # relay to completer task
@ -950,7 +950,7 @@ async def register_symbol_search(
global _searcher_cache global _searcher_cache
pause_period = pause_period or 0.061 pause_period = pause_period or 0.125
# deliver search func to consumer # deliver search func to consumer
try: try: