-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSuggest: offer default suggestion #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that! Nicely blends with existing code
WebSuggest/websuggest.ini
Outdated
@@ -37,6 +37,12 @@ | |||
# * Default: yes | |||
#enable_predefined_items = yes | |||
|
|||
# Time that the plugin will wait before sending the request. | |||
# * Time in seconds (can be used with float type) | |||
# * The minimum value is 0.25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please specify a hard-coded maximum value to prevent mistyping. 3 seconds should do it I think
WebSuggest/websuggest.py
Outdated
# avoid doing unnecessary network requests in case user is still typing | ||
if len(user_input) < 2 or self.should_terminate(0.25): | ||
if len(user_input) < 2 or self.should_terminate(self.waiting_time): | ||
self.set_suggestions(suggestions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_suggestions()
call is useless here since suggestions will be discarded by KP anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for the case of entering one character. But I agree that this is unnecessary. Nobody is looking for 1 character. :)
WebSuggest/websuggest.py
Outdated
self.set_suggestions(suggestions, kp.Match.ANY, kp.Sort.NONE) | ||
if not provider_suggestions: # change default item | ||
suggestions[0].set_short_desc("No suggestions found (default action: {})".format( | ||
profile['default_action'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please indent to align with above parenthesis. profile[...
should be aligned with "No suggestions ...
(I know it may not be the case everywhere in the repo)
WebSuggest/websuggest.py
Outdated
@@ -405,6 +424,9 @@ def _read_config(self): | |||
enable_predefined_items = settings.get_bool( | |||
"enable_predefined_items", self.CONFIG_SECTION_MAIN, | |||
fallback=self.DEFAULT_ENABLE_PREDEFINED_ITEMS) | |||
self.waiting_time = settings.get_float( | |||
"waiting_time", self.CONFIG_SECTION_MAIN, | |||
fallback=self.DEFAULT_WAITING_TIME, min=0.25) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(max value)
WebSuggest/websuggest.ini
Outdated
# * Time in seconds (can be used with float type) | ||
# * The minimum value is 0.25 | ||
# * Default: 0.25 | ||
#waiting_time = 0.25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think idle_time
is more appropriate than waiting_time
Please PR on the |
Looks good. Thanks again! |
Note: if arguments empty - open the search home page.