paul-gauthier / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
14k stars 1.32k forks source link

Support typing/pasting tabs into the chat in all terminal environments #502

Open kripper opened 4 months ago

kripper commented 4 months ago

I see no way to copy & paste blocks containing tabs into the prompt. Multiline mode doesn't work either. session.prompt() is ignoring the tabs (they get lost and the context gets corrupted).

Aider v0.26.1-dev
VSCode terminal detected, pretty output has been disabled.
API key supports: gpt-3.5-turbo, gpt-3.5-turbo-0301, gpt-3.5-turbo-0613, gpt-3.5-turbo-16k, 
gpt-3.5-turbo-16k-0613, gpt-4, gpt-4-0314, gpt-4-0613
API key does not support gpt-4-1106-preview, falling back to gpt-3.5-turbo-0125
Model: gpt-3.5-turbo-0125 using whole edit format
Git repo: .git with 3 files
Repo-map: using 1024 tokens
paul-gauthier commented 4 months ago

Thanks for trying aider and filing this issue.

Pasting in tabs works just fine in my local Mac environment. There may be a problem with your terminal environment?

$ aider
Aider v0.26.2-dev
Model: gpt-4-1106-preview using udiff edit format
Git repo: .git with 0 files
Repo-map: using 1024 tokens
Use /help to see in-chat commands, run with --help to see cmd line args
───────────────────────────────────────────────────────────────────────────────────────────────
> what seperator is used in the following text: hello^Iworld^I!
cola^Icolb^Icolc

The separator used in the provided text is a tab character, often represented as \t in many
programming languages. This character is used to separate columns in tab-delimited text files
or strings.
kripper commented 4 months ago

Pasting in tabs works just fine in my local Mac environment. There may be a problem with your terminal environment?

Hi. I tested on Windows. I noticed the issue on the standard terminal, and then debugged the input inside visual code. There was no \t.

Did you try tabs or spaces?

I believe the tabs are ingested by PromptSession for the commands autocompleter (with the tab key). How does the stdin reader on Mac distinguish between pasted tabs and tabs pressed on the keyboard if both are merely tabs on stdin?

There is also another use case where pasting multiline text that does not begin with { is required.

paul-gauthier commented 4 months ago

I pasted tabs, worked fine. It looks like you are running aider inside the VSCode terminal, which is known to not be a fully functional terminal. That could be part of the issue.

Also, using { to start a multi-line paste is not intended to handle "text that starts with {". It's intended as a way to wrap any multi-line text you wish to enter into the chat.

kripper commented 4 months ago

I tested again in a normal cmd.exe window and confirmed that the tabs are lost. In general pressing the tab key doesn't generate any output. It does only autocomplete commands after entering /.

paul-gauthier commented 3 months ago

What are you trying to accomplish? Why are you trying to type bare tabs into the chat window?

kripper commented 3 months ago

What are you trying to accomplish? Why are you trying to type bare tabs into the chat window?

Yes. I have a prompt containing a JSON indented with tabs and I'm doing copy/paste. It could also be a prompt with python code.

paul-gauthier commented 3 months ago

As I mentioned above, pasting in tabs works just fine in my local Mac environment. There may be a problem with your terminal environment? Especially if you're in the VS Code terminal.

Also, JSON doesn't need tabs?

Another solution could be to make a file with the JSON and /add it to the chat and then reference it in your chat. "Use the JSON in foo.json to do blah blah blah".

kripper commented 3 months ago

I'm testing inside a normal cmd.exe window on Windows 10. If you are testing on a Mac, I guess pasting tabs only works on Mac. I prefer clean and general solutions. That's why I also mentioned pasting python code where tabs are important. I will be using the /block command I implemented in https://github.com/paul-gauthier/aider/pull/504/files Thanks.