xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.72k stars 1.63k forks source link

Remove alt -> ctrl+arrow hack in favor of embedder-specific solutions #4538

Open Tyriar opened 1 year ago

Tyriar commented 1 year ago

Context: https://github.com/xtermjs/xterm.js/issues/264#issuecomment-1505538266

Finding the commit they were added to confirm is also a good idea.

https://github.com/xtermjs/xterm.js/blob/8b422442b7079525dca8b2a1c6b167856d1d7e7e/src/common/input/Keyboard.ts#L114-L189

fifv commented 11 months ago

Thank you Tyriar for saving my life. I have spent hours to figure out why my Alt key doesn't work...

For anyone who wants a workaround, here is my hack for Tabby (other terminals should be similar):

  1. Open the file contains xterm.js's bundled codes (C:\Users\<USER>\AppData\Local\Programs\Tabby\resources\builtin-plugins\tabby-terminal\dist\index.js)

    • This is xterm.js ‘s problem, and Tabby use xterm.js as a plugin, note it belongs to builtin-plugins instead of main tabby app
  2. Fix for Arrows:

    Find [1;5D (may ~27452 at Tabby 1.0.196)

    Remove these selected

    image

  3. Fix for PageUp/PageDown:

    Find [5~ (may ~27479 at Tabby 1.0.196, just near the above ones)

    Add these selected

    image

dmarcuse commented 3 months ago

Is there any recent update on this? I've been frustrated by this behavior in VS code and finally figured out this was the cause (and found the linked workaround via VS code's shortcuts). I see the help wanted tag - if it's just a matter of getting someone to do it, I'm happy to make the changes.

Tyriar commented 3 months ago

@dmarcuse no updates, just needs someone to help out. We'll need this removed in xterm.js and then some default keybindings added to VS Code. So then disabling this in VS Code would be a matter or disabling keybindings (as opposed to creating new ones which is more difficult).

dmarcuse commented 3 months ago

Sounds good, I'll set aside some time to work on this over the weekend then.

balthild commented 1 month ago

You could just "fix" it by simply override the key binding if you're using vscode. Maybe the workbench.action.terminal.sendSequence action does not send sequences via xterm.js, but through conpty directly, so it would not be modified?


    {
        "key": "alt+left",
        "command": "workbench.action.terminal.sendSequence",
        "args": {
            "text": "\u001b[1;3D"
        },
        "when": "terminalFocus"
    },
    {
        "key": "alt+right",
        "command": "workbench.action.terminal.sendSequence",
        "args": {
            "text": "\u001b[1;3C"
        },
        "when": "terminalFocus"
    },

Result:

image

image

Tyriar commented 1 month ago

@balthild yep, we just need that keybinding built in to VS Code. So those keybindings added somewhere over here: https://github.com/microsoft/vscode/blob/3ae6c5ef651585b12870828230f214eed2e6ef07/src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts#L245-L249

And then remove the overrides from xterm.js