Show More
@@ -317,6 +317,29 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
317 | help="Allows to enable/disable the prompt toolkit history search" |
|
317 | help="Allows to enable/disable the prompt toolkit history search" | |
318 | ).tag(config=True) |
|
318 | ).tag(config=True) | |
319 |
|
319 | |||
|
320 | autosuggestions_provider = Unicode( | |||
|
321 | "AutoSuggestFromHistory", | |||
|
322 | help="Specifies from which source automatic suggestions are provided. " | |||
|
323 | "Can be set to `'AutoSuggestFromHistory`' or `None` to disable" | |||
|
324 | "automatic suggestions. Default is `'AutoSuggestFromHistory`'.", | |||
|
325 | allow_none=True, | |||
|
326 | ).tag(config=True) | |||
|
327 | ||||
|
328 | def _set_autosuggestions(self, provider): | |||
|
329 | if provider is None: | |||
|
330 | self.auto_suggest = None | |||
|
331 | elif provider == "AutoSuggestFromHistory": | |||
|
332 | self.auto_suggest = AutoSuggestFromHistory() | |||
|
333 | else: | |||
|
334 | raise ValueError("No valid provider.") | |||
|
335 | if self.pt_app: | |||
|
336 | self.pt_app.auto_suggest = self.auto_suggest | |||
|
337 | ||||
|
338 | @observe("autosuggestions_provider") | |||
|
339 | def _autosuggestions_provider_changed(self, change): | |||
|
340 | provider = change.new | |||
|
341 | self._set_autosuggestions(provider) | |||
|
342 | ||||
320 | prompt_includes_vi_mode = Bool(True, |
|
343 | prompt_includes_vi_mode = Bool(True, | |
321 | help="Display the current vi mode (when using vi editing mode)." |
|
344 | help="Display the current vi mode (when using vi editing mode)." | |
322 | ).tag(config=True) |
|
345 | ).tag(config=True) | |
@@ -374,7 +397,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
374 |
|
397 | |||
375 | self.pt_loop = asyncio.new_event_loop() |
|
398 | self.pt_loop = asyncio.new_event_loop() | |
376 | self.pt_app = PromptSession( |
|
399 | self.pt_app = PromptSession( | |
377 |
auto_suggest= |
|
400 | auto_suggest=self.auto_suggest, | |
378 | editing_mode=editing_mode, |
|
401 | editing_mode=editing_mode, | |
379 | key_bindings=key_bindings, |
|
402 | key_bindings=key_bindings, | |
380 | history=history, |
|
403 | history=history, | |
@@ -576,6 +599,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
576 |
|
599 | |||
577 | def __init__(self, *args, **kwargs): |
|
600 | def __init__(self, *args, **kwargs): | |
578 | super(TerminalInteractiveShell, self).__init__(*args, **kwargs) |
|
601 | super(TerminalInteractiveShell, self).__init__(*args, **kwargs) | |
|
602 | self._set_autosuggestions(self.autosuggestions_provider) | |||
579 | self.init_prompt_toolkit_cli() |
|
603 | self.init_prompt_toolkit_cli() | |
580 | self.init_term_title() |
|
604 | self.init_term_title() | |
581 | self.keep_running = True |
|
605 | self.keep_running = True |
General Comments 0
You need to be logged in to leave comments.
Login now