llm icon indicating copy to clipboard operation
llm copied to clipboard

readline bindings only on mac and windows. fixes simonw/llm#516 simonw/llm#582

Open grota opened this issue 1 year ago • 4 comments

fixes #516

grota avatar Aug 27 '24 15:08 grota

@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?

grota avatar Oct 25 '24 06:10 grota

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") ```

knorthover avatar Nov 02 '24 17:11 knorthover

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

grota avatar Nov 02 '24 17:11 grota

@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.

grota avatar Dec 02 '24 17:12 grota

closing, this issue is solved with a recent version of click

grota avatar Aug 10 '25 19:08 grota