11# pylint: disable=function-redefined
2+ from typing import Dict , Union
3+
24from prompt_toolkit .application .current import get_app
35from prompt_toolkit .buffer import Buffer , SelectionType , indent , unindent
46from prompt_toolkit .completion import CompleteEvent
1416 shift_selection_mode ,
1517 vi_search_direction_reversed ,
1618)
19+ from prompt_toolkit .key_binding .key_bindings import Binding
1720from prompt_toolkit .key_binding .key_processor import KeyPressEvent
1821from prompt_toolkit .keys import Keys
1922
@@ -395,7 +398,7 @@ def unshift_move(event: E) -> None:
395398 return
396399
397400 # the other keys are handled through their readline command
398- key_to_command = {
401+ key_to_command : Dict [ Union [ Keys , str ], str ] = {
399402 Keys .ShiftLeft : 'backward-char' ,
400403 Keys .ShiftRight : 'forward-char' ,
401404 Keys .ShiftHome : 'beginning-of-line' ,
@@ -412,7 +415,10 @@ def unshift_move(event: E) -> None:
412415 except KeyError :
413416 pass
414417 else : # (`else` is not really needed here.)
415- handler (event )
418+ if not isinstance (handler , Binding ):
419+ # (It should always be a normal callable here, for these
420+ # commands.)
421+ handler (event )
416422
417423 @handle ('s-left' , filter = ~ has_selection )
418424 @handle ('s-right' , filter = ~ has_selection )
0 commit comments