Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab char ' '(\t) displays as ^I when pasting into input #1868

Open
huangyxi opened this issue Apr 16, 2024 · 0 comments
Open

Tab char ' '(\t) displays as ^I when pasting into input #1868

huangyxi opened this issue Apr 16, 2024 · 0 comments

Comments

@huangyxi
Copy link

In some downstream applications, we want to paste code directly into the input. If a tab character is included in the code, the prompt displays it as ^I.

For a specific instance, when coding in an R script in VSCode, the "vscode-R" extension could send a block of code into the REPL of the Python package radian, which utilizes prompt-toolkit as the IO in the REPL. If the block of code contains tabs, the REPL will display abnormally. randy3k/radian#313

Screenshot

Thankfully, reproducing this behavior is not a hard task.

  1. Make a simple prompt:
>>> from prompt_toolkit import prompt
>>> prompt("Input: ")
Input: 
  1. Paste tab char > <, resulting in:
Input: tab char >^I<

I have tried a solution mentioned in tmbo/questionary#154 (comment), which patches prompt_toolkit.layout.screen .Char.display_mappings['\t'] = '\t', and a solution in Issue #1452, which listens for the tab key to insert spaces. However, it still does not work properly. I also found a workaround mentioned in Issue #556, but it is not suitable in our situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant