File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 2626from prompt_toolkit import PromptSession , prompt
2727from prompt_toolkit .completion import Completer , Completion
2828from prompt_toolkit .document import Document
29+ from prompt_toolkit .filters import has_completions
2930from prompt_toolkit .formatted_text import ANSI
3031from prompt_toolkit .history import FileHistory
32+ from prompt_toolkit .key_binding import KeyBindings
3133from prompt_toolkit .shortcuts import clear
3234from pypsrp .complex_objects import PSInvocationState
3335from pypsrp .exceptions import AuthenticationError , WinRMTransportError , WSManFaultError
@@ -1166,6 +1168,16 @@ def interactive_shell(r_pool: RunspacePool) -> None:
11661168 # Set up command completer
11671169 completer = CommandPathCompleter (r_pool )
11681170
1171+ # Set up key bindings
1172+ kb = KeyBindings ()
1173+
1174+ @kb .add ("enter" , filter = has_completions )
1175+ def _ (event ):
1176+ """Accept the highlighted completion without executing the command."""
1177+ event .current_buffer .apply_completion (
1178+ event .current_buffer .complete_state .current_completion
1179+ )
1180+
11691181 while True :
11701182 try :
11711183 try :
@@ -1176,6 +1188,7 @@ def interactive_shell(r_pool: RunspacePool) -> None:
11761188 prompt_text ,
11771189 completer = completer ,
11781190 complete_while_typing = False ,
1191+ key_bindings = kb ,
11791192 )
11801193
11811194 if not command :
You can’t perform that action at this time.
0 commit comments