Show More
@@ -317,11 +317,33 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
317 | 317 | help="Allows to enable/disable the prompt toolkit history search" |
|
318 | 318 | ).tag(config=True) |
|
319 | 319 | |
|
320 |
|
|
|
321 | help="Allows to enable/disable the prompt autosuggestions based on " | |
|
322 | "the prompt toolkit history.", | |
|
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, | |
|
323 | 326 | ).tag(config=True) |
|
324 | 327 | |
|
328 | prompt_includes_vi_mode = Bool( | |
|
329 | True, help="Display the current vi mode (when using vi editing mode)." | |
|
330 | ).tag(config=True) | |
|
331 | ||
|
332 | def _set_autosuggestions(self, provider): | |
|
333 | if provider is None: | |
|
334 | self.auto_suggest = None | |
|
335 | elif provider == "AutoSuggestFromHistory": | |
|
336 | self.auto_suggest = AutoSuggestFromHistory() | |
|
337 | else: | |
|
338 | raise ValueError("No valid provider.") | |
|
339 | if self.pt_app: | |
|
340 | self.pt_app.auto_suggest = self.auto_suggest | |
|
341 | ||
|
342 | @observe("autosuggestions_provider") | |
|
343 | def _autosuggestions_provider_changed(self, change): | |
|
344 | provider = change.new | |
|
345 | self._set_autosuggestions(provider) | |
|
346 | ||
|
325 | 347 | prompt_includes_vi_mode = Bool(True, |
|
326 | 348 | help="Display the current vi mode (when using vi editing mode)." |
|
327 | 349 | ).tag(config=True) |
@@ -375,16 +397,11 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
375 | 397 | self._style = self._make_style_from_name_or_cls(self.highlighting_style) |
|
376 | 398 | self.style = DynamicStyle(lambda: self._style) |
|
377 | 399 | |
|
378 | if self.enable_autosuggestions: | |
|
379 | auto_suggest = AutoSuggestFromHistory() | |
|
380 | else: | |
|
381 | auto_suggest = None | |
|
382 | ||
|
383 | 400 | editing_mode = getattr(EditingMode, self.editing_mode.upper()) |
|
384 | 401 | |
|
385 | 402 | self.pt_loop = asyncio.new_event_loop() |
|
386 | 403 | self.pt_app = PromptSession( |
|
387 | auto_suggest=auto_suggest, | |
|
404 | auto_suggest=self.auto_suggest, | |
|
388 | 405 | editing_mode=editing_mode, |
|
389 | 406 | key_bindings=key_bindings, |
|
390 | 407 | history=history, |
@@ -586,6 +603,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
586 | 603 | |
|
587 | 604 | def __init__(self, *args, **kwargs): |
|
588 | 605 | super(TerminalInteractiveShell, self).__init__(*args, **kwargs) |
|
606 | self._set_autosuggestions(self.autosuggestions_provider) | |
|
589 | 607 | self.init_prompt_toolkit_cli() |
|
590 | 608 | self.init_term_title() |
|
591 | 609 | self.keep_running = True |
General Comments 0
You need to be logged in to leave comments.
Login now