readline bindings only on mac and windows. fixes simonw/llm#516 simonw/llm#582
fixes #516
@simonw I modified the PR to import readline and bind only on Darwin, this fixes the following 4 open issues: simonw/llm#516 simonw/llm#582 simonw/llm#585 simonw/llm#495
As commented elsewhere, digging through the history it seems like readline is used to fix this issue #376 which is the proper fix for #355 (so basically, the standard terminal on osx).
It's a simple PR, can you please give it a look?
I just hit this issue with readline on Windows 10. Claude Sonnet suggested this patch to use the codes readline recognizes for Windows. It works.
import platform
if platform.system() == 'Windows':
readline.parse_and_bind("Left: backward-char")
readline.parse_and_bind("Right: forward-char")
else:
readline.parse_and_bind("\\e[D: backward-char")
readline.parse_and_bind("\\e[C: forward-char") ```
Based on the analysis above, the two bindings were introduced to address an issue on macOS (darwin), specifically with the default iTerm app.
Considering the existing issues, I believe it’s fair to say that on Linux and Windows, these bindings have caused more problems than they've solved. So I stand by my original PR which removes the import and bindings on those platforms.
In fact, I don't think hardcoding these bindings is a good approach even on darwin. It wouldn’t surprise me if similar issues arose on macOS with other terminal emulators.
@simonw I'm asking you once again if can you please have a look at this simple PR of mine
@simonw just FYI, I rebased and rewritten the PR to perform readline bindings only on darwin and windows, as per the new code by @sukhbinder in #646.
closing, this issue is solved with a recent version of click