Refactor _incremental_search() based on PR review

This commit is contained in:
Justin Partain 2017-10-27 08:49:53 -04:00
parent bcd9d13684
commit aff6510e35

View File

@ -243,12 +243,13 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
@pyqtSlot(str) @pyqtSlot(str)
def _incremental_search(self, text): def _incremental_search(self, text):
if config.val.search.incremental: if not config.val.search.incremental:
return
search_prefixes = { search_prefixes = {
'/': 'search -- ', '/': 'search -- ',
'?': 'search -r -- ', '?': 'search -r -- ',
} }
# `if text` check is for when user presses <Esc> and `len(text)` is 0 if self.prefix() in ['/', '?']:
if self.prefix() in '/?' and text:
self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:]) self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:])