mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 19:24:59 +00:00
![]() # Aider chat conversation: USER: can we have `get_input` treat control+enter as a newline with prompt toolkit KeyBindings ASSISTANT: To implement this feature, we need to modify the `get_input` method in the `InputOutput` class in the `aider/io.py` file. We will use the `KeyBindings` class from `prompt_toolkit.keys` to bind the `Control+Enter` key combination to insert a newline. Here are the changes: ```python aider/io.py <<<<<<< ORIGINAL from prompt_toolkit.shortcuts import CompleteStyle, PromptSession, prompt ======= from prompt_toolkit.shortcuts import CompleteStyle, PromptSession, prompt from prompt_toolkit.keys import Keys from prompt_toolkit.key_binding import KeyBindings >>>>>>> UPDATED ```python aider/io.py <<<<<<< ORIGINAL session = PromptSession(**session_kwargs) ======= kb = KeyBindings() @kb.add(Keys.ControlJ, eager=True) def _(event): event.current_buffer.insert_text('\n') session = PromptSession(key_bindings=kb, **session_kwargs) >>>>>>> UPDATED ``` This code creates a new `KeyBindings` instance and adds a binding for `Control+Enter` (represented by `Keys.ControlJ`) to insert a newline. Then, it passes this key bindings instance to the `PromptSession` constructor. |
||
---|---|---|
.. | ||
coders | ||
__init__.py | ||
commands.py | ||
diffs.py | ||
dump.py | ||
io.py | ||
main.py | ||
models.py | ||
prompts.py | ||
repomap.py | ||
utils.py |