Tmux causes <a-O> lag

Add new line above <a-O> and below <a-o> lags when using Kakoune in tmux.

Can anyone satisfy my curiosity about this?

I’m still a tmux beginner, and a naïve google search about tmux and alt reveals nothing.

I’m not sure about <a-o>, but I can explain <a-O>.

When you press <a-O>, the bytes your terminal actually sends Kakoune are \x1BO (where \x1B is the ASCII code for Escape).

When you press the up arrow on your keyboard, the bytes your terminal actually sends Kakoune are \x1BOA.

So when you press <a-O>, Kakoune has to wait a little while to see if an A shows up, to determine whether it should execute the mappings for <a-O> or <up>.

In actual fact, Kakoune assumes that the terminal sends an entire escape sequence in a single packet, so it waits 0 milliseconds to distinguish <a-O> from <up>, so it’s quite responsive running natively in a terminal, but it can be glitchy if you’re running it over a very laggy intercontinental SSH connection.

tmux adds another layer on top. When you press <a-O>, then tmux has to wait a little while to see if an A shows up, so it can decide what bytes to send to Kakoune. tmux’s default configuration is much more conservative, waiting 500 milliseconds before it’ll let you do anything else. That makes trans-Pacific connections much more reliable, but if you’re running it locally, the delay can be quite frustrating.

Since I generally run tmux from a low-latency connection, I have the following in my tmux config:

set-option -g escape-time 50

That sets tmux’s delay to only 50 milliseconds, which is much more comfortable.

3 Likes

Can confirm it’s just <a-O> that lags, and that your fix works.

Thanks for the explanation