aider/aider
Paul Gauthier 6244df8352 aider: get_input now treats control+enter as a newline with prompt toolkit KeyBindings.
# 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.
2023-07-16 14:12:01 -03:00
..
coders Whitelist more /cmds for no dirty commit 2023-07-16 13:42:36 -03:00
__init__.py set version to 0.9.0-dev 2023-07-16 09:47:35 -03:00
commands.py notify when preparing dirty commit; skip if /exit or /commit is input 2023-07-11 13:21:36 -07:00
diffs.py use utf-8 2023-07-05 20:51:35 -07:00
dump.py isort 2023-05-28 22:47:38 -07:00
io.py aider: get_input now treats control+enter as a newline with prompt toolkit KeyBindings. 2023-07-16 14:12:01 -03:00
main.py aider: Scrub sensitive information from verbose logs before saving. 2023-07-13 12:28:05 -07:00
models.py Disabled general availability of gpt-4 (it's rolling out, not 100% available yet) 2023-07-08 05:57:56 -07:00
prompts.py refactor Editors 2023-06-20 16:26:00 -07:00
repomap.py Anchor the cache to the project root 2023-07-13 14:01:07 -07:00
utils.py Adopt safe_abs_path 2023-07-07 17:17:33 -07:00