zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.51k stars 2.9k forks source link

Support key repetition in terminal #4740

Open failable opened 1 year ago

failable commented 1 year ago

Check for existing issues

Describe the feature

Keyboard repetition does not work for some keys like a-z in terminal while it works in Alacritty.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

bswinnerton commented 1 year ago

Adding support for this would be particularly helpful for holding the j or k keys when scrolling through a large command output like git diff.

Kristoffer commented 9 months ago

This also affects running vi and vim in terminal, which causes arrowkeys (h j k l) to not perform as expected, for instance showing the possiblity of inserting a ķ instead of moving cursor up. This happens on os x 14.2.1, US english.

mrnugget commented 9 months ago

Do you have concrete steps to reproduce? I have Vim mode enabled in Zed and can hold down j to scroll down the buffer. I can do the same thing inside the built-in terminal: keep typing j in the shell, or scroll in Vim inside that built-in terminal.

https://github.com/zed-industries/community/assets/1185253/1fb0f128-b92f-46a4-9c23-0f289532585e

Do you use this setting too?

defaults write -g ApplePressAndHoldEnabled -bool false

That disables press-and-hold to type special characters.

(Doesn't mean that users should have to use that to make it work in Zed, but just trying to find out why it works for me and not for you)

Kristoffer commented 9 months ago

aha, that works, to disable ApplePressAndHoldEnabled.

So to me it looks like vi and vim in

bypasses ApplePressAndHoldEnabled when in VI mode.

But the Zed terminal does not.

I see I'm actually using en_DK, from defaults read -g if that has any relevance:


    AKLastLocale = "en_DK";
    AppleInterfaceStyleSwitchesAutomatically = 1;
    AppleKeyboardUIMode = 3;
    AppleLanguages =     (
        "en-DK"
    );
    AppleLanguagesDidMigrate = "13.4.1";
    AppleLanguagesSchemaVersion = 4000;
    AppleLocale = "en_DK";
    AppleMenuBarVisibleInFullscreen = 0;
    AppleMiniaturizeOnDoubleClick = 0;
    ApplePressAndHoldEnabled = 0;
    AppleShowAllExtensions = 1;
    InitialKeyRepeat = 15;
    "KB_DoubleQuoteOption" = "\\U201cabc\\U201d";
    "KB_SingleQuoteOption" = "\\U2018abc\\U2019";
    "KB_SpellingLanguage" =     {
        "KB_SpellingLanguageIsAutomatic" = 1;
    };
    KeyRepeat = 2;
    NSAutomaticCapitalizationEnabled = 0;
    NSAutomaticPeriodSubstitutionEnabled = 0;
    NSAutomaticSpellingCorrectionEnabled = 0;
    NSLinguisticDataAssetsRequestLastInterval = 86400;
    NSLinguisticDataAssetsRequestTime = "2024-01-21 14:51:34 +0000";
    NSLinguisticDataAssetsRequested =     (
        da,
        en,
        fr,
        nb,
        nn,
        de,
        sv,
        cs,
        nl,
        fi,
        it
    );
    NSLinguisticDataAssetsRequestedByChecker =     (
        da,
        en,
        fr,
        nb,
        nn,
        de,
        sv,
        cs,
        nl,
        fi,
        it
    );```
mrnugget commented 8 months ago

bypasses ApplePressAndHoldEnabled when in VI mode.

But the Zed terminal does not.

Yeah, that's very interesting. Thanks for digging into this. We'll need to look into this a bit more.

ovidius72 commented 3 months ago

Do you have concrete steps to reproduce? I have Vim mode enabled in Zed and can hold down j to scroll down the buffer. I can do the same thing inside the built-in terminal: keep typing j in the shell, or scroll in Vim inside that built-in terminal.

screenshot-2024-01-22-09.26.12.mp4 Do you use this setting too?

defaults write -g ApplePressAndHoldEnabled -bool false

That disables press-and-hold to type special characters.

(Doesn't mean that users should have to use that to make it work in Zed, but just trying to find out why it works for me and not for you)

That's ok if you want to disable press and hold globally. I'd like to disable only for zed and its integrated terminal but while it just works for the editor, it does not for the terminal.

mrnugget commented 3 months ago

I'd like to disable only for zed and its integrated terminal but while it just works for the editor, it does not for the terminal.

Can you clarify? You did disable it only for Zed? If so, how?

ovidius72 commented 3 months ago

@mrnugget usually with vscode and jetbrains products i run the following command:

defaults write [app_id] ApplePressAndHoldEnabled -bool false

if you instead run:

defaults write -g ApplePressAndHoldEnabled -bool false (without specifying the app_id)

this will affects the feature globally and disable the hold and press feature for all apps. Most likely you want to keep this enabled for apps like office apps, pages, numbers, and so on, where i find it to be very handy.

So I did this for zed:

defaults write zed.Zed ApplePressAndHoldEnabled -bool false and defaults write zed.Zed-Preview ApplePressAndHoldEnabled -bool false

This turned out to disable press and hold when I'm in the editor panels, but did not in the terminal panels.

Most of the time I found it hard to find the app_id to be used. Here is a useful post: https://stackoverflow.com/questions/33152551/how-can-i-disable-applepressandholdenabled-for-a-specific-application-repeat

mrnugget commented 3 months ago

Thank you! That's very helpful.

Calinou commented 3 months ago

Note that this issue does not seem to affect Linux (X11) – key repetition works fine on my end in the terminal.

Zed: v0.143.7 (Zed) OS: Linux X11 fedora 40 Memory: 62.5 GiB Architecture: x86_64

ovidius72 commented 3 months ago

Note that this issue does not seem to affect Linux (X11) – key repetition works fine on my end in the terminal.

Zed: v0.143.7 (Zed) OS: Linux X11 fedora 40 Memory: 62.5 GiB Architecture: x86_64

Yes. this is only a mac issue.

brittlewis12 commented 3 weeks ago

After I hit this myself, I did a cursory search into how iTerm 2 handles this (in iTerm windows, I can hold motion keys (jk) and navigate a paged diff/file/etc; in Zed windows, the integrated terminal moves a single line and stops).

I'm not sure it's relevant, but I found this change: Add auto-repeat mode

Is it possible DECARM would improve or resolve the desired key repeat behavior for macOS?

There seems to be an equivalent change for microsoft terminal

This behavior doesn't affect Alacritty, so perhaps it's matter of configuration rather than outright support?