Show More
@@ -51,6 +51,7 b' from .pt_inputhooks import get_inputhook_name_and_func' | |||
|
51 | 51 | from .prompts import Prompts, ClassicPrompts, RichPromptDisplayHook |
|
52 | 52 | from .ptutils import IPythonPTCompleter, IPythonPTLexer |
|
53 | 53 | from .shortcuts import ( |
|
54 | KEY_BINDINGS, | |
|
54 | 55 | create_ipython_shortcuts, |
|
55 | 56 | create_identifier, |
|
56 | 57 | RuntimeBinding, |
@@ -491,8 +492,8 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
491 | 492 | # for now we only allow adding shortcuts for commands which are already |
|
492 | 493 | # registered; this is a security precaution. |
|
493 | 494 | known_commands = { |
|
494 |
create_identifier(binding. |
|
|
495 |
for binding in |
|
|
495 | create_identifier(binding.command): binding.command | |
|
496 | for binding in KEY_BINDINGS | |
|
496 | 497 | } |
|
497 | 498 | shortcuts_to_skip = [] |
|
498 | 499 | shortcuts_to_add = [] |
@@ -513,11 +514,11 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
513 | 514 | ) |
|
514 | 515 | matching = [ |
|
515 | 516 | binding |
|
516 |
for binding in |
|
|
517 | for binding in KEY_BINDINGS | |
|
517 | 518 | if ( |
|
518 | 519 | (old_filter is None or binding.filter == old_filter) |
|
519 | 520 | and (old_keys is None or [k for k in binding.keys] == old_keys) |
|
520 |
and create_identifier(binding. |
|
|
521 | and create_identifier(binding.command) == command_id | |
|
521 | 522 | ) |
|
522 | 523 | ] |
|
523 | 524 | |
@@ -542,7 +543,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
542 | 543 | } |
|
543 | 544 | if len(matching) == 0: |
|
544 | 545 | raise ValueError( |
|
545 |
f"No shortcuts matching {specification} found in { |
|
|
546 | f"No shortcuts matching {specification} found in {KEY_BINDINGS}" | |
|
546 | 547 | ) |
|
547 | 548 | elif len(matching) > 1: |
|
548 | 549 | raise ValueError( |
@@ -274,6 +274,14 b' AUTO_SUGGEST_BINDINGS = [' | |||
|
274 | 274 | # no `has_suggestion` here to allow resuming if no suggestion |
|
275 | 275 | "default_buffer_focused & emacs_like_insert_mode", |
|
276 | 276 | ), |
|
277 | Binding( | |
|
278 | auto_suggest.resume_hinting, | |
|
279 | ["right"], | |
|
280 | # For now this binding is inactive (the filter includes `never`). | |
|
281 | # TODO: remove `never` if we reach a consensus in #13991 | |
|
282 | # TODO: use `emacs_like_insert_mode` once #13991 is in | |
|
283 | "never & default_buffer_focused & ((vi_insert_mode & ebivim) | emacs_insert_mode)", | |
|
284 | ), | |
|
277 | 285 | ] |
|
278 | 286 | |
|
279 | 287 |
@@ -261,14 +261,13 b' def _update_hint(buffer: Buffer):' | |||
|
261 | 261 | |
|
262 | 262 | def backspace_and_resume_hint(event: KeyPressEvent): |
|
263 | 263 | """Resume autosuggestions after deleting last character""" |
|
264 | current_buffer = event.current_buffer | |
|
264 | nc.backward_delete_char(event) | |
|
265 | _update_hint(event.current_buffer) | |
|
265 | 266 | |
|
266 | def resume_hinting(buffer: Buffer): | |
|
267 | _update_hint(buffer) | |
|
268 | current_buffer.on_text_changed.remove_handler(resume_hinting) | |
|
269 | 267 | |
|
270 | current_buffer.on_text_changed.add_handler(resume_hinting) | |
|
271 | nc.backward_delete_char(event) | |
|
268 | def resume_hinting(event: KeyPressEvent): | |
|
269 | """Resume autosuggestions""" | |
|
270 | return _update_hint(event.current_buffer) | |
|
272 | 271 | |
|
273 | 272 | |
|
274 | 273 | def up_and_update_hint(event: KeyPressEvent): |
@@ -17,6 +17,7 b' from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions' | |||
|
17 | 17 | from prompt_toolkit.filters import has_focus as has_focus_impl |
|
18 | 18 | from prompt_toolkit.filters import ( |
|
19 | 19 | Always, |
|
20 | Never, | |
|
20 | 21 | has_selection, |
|
21 | 22 | has_suggestion, |
|
22 | 23 | vi_insert_mode, |
@@ -174,6 +175,8 b' default_buffer_focused = has_focus(DEFAULT_BUFFER)' | |||
|
174 | 175 | |
|
175 | 176 | KEYBINDING_FILTERS = { |
|
176 | 177 | "always": Always(), |
|
178 | # never is used for exposing commands which have no default keybindings | |
|
179 | "never": Never(), | |
|
177 | 180 | "has_line_below": has_line_below, |
|
178 | 181 | "has_line_above": has_line_above, |
|
179 | 182 | "has_selection": has_selection, |
General Comments 0
You need to be logged in to leave comments.
Login now