Comments (10)
When Kakoune initialises a terminal, it asks the terminal if it supports mode 2026 (output synchronisation):
\033[?2026$p
The terminal is supposed to respond with "I've never heard of that mode", "yes, and it's currently enabled", or "yes, and it's currently disabled":
\033[?2026;0$y // never heard of it
\033[?2026;1$y // enabled
\033[?2026;2$y // disabled
It seems your terminal is instead sending:
\033[0$y
...which is vaguely like a query response, but I can't see a situation where a terminal should send a response like that.
Here's a command that sends all the control sequences Kakoune sends at startup, then
reset; printf '\033[?1049h\033[?1004h\033[>4;1m\033[>5u\033[22t\033[?25l\033=\033[?2026$p\033[?2004h'; read
If you paste that command into a terminal then press Enter twice, it should clear the screen and then you'll see whatever the terminal sends back, which I expect will look something like this:
^[[I^[[0$y
Is that what happens?
from kakoune.
Can confirm the same here. Doesn't happen in tmux
, which is probably to be expected.
from kakoune.
As the Microsoft Terminal issue suggests, a control-sequence sent by the terminal to Kakoune is being interpreted as keys. If you can reproduce this, try :set global debug keys
before hitting <c-z>
, and then when you bring Kakoune back, if the problem reproduces, go check the *debug*
buffer and see what keys have been pressed. It would be interesting to know if it's always the same bytes being misinterpreted as keys (meaning, possibly a problem in Kakoune's input state machine) or if it's sometimes different (meaning, the input stream being split across packets, preventing Kakoune from detecting them as a single control sequence).
from kakoune.
I seem to be always getting the same keys when it reproduces
Client 'client0' got key '<a-[>'
Client 'client0' got key '0'
Client 'client0' got key '$'
Client 'client0' got key 'y'
and nothing when it does not reproduce
from kakoune.
This also happens if I open a second client
# First shell
kak -s myproject
# Second shell
kak -c myproject
# keep pipe:y
from kakoune.
tmux and command prompt send nothing.
Terminal sends
^[[?2026;0$y
from kakoune.
You said originally that the problem reproduces 50% of the time in Kakoune - when you run the printf
command, does it always respond ^[[?2026;0$y
or just some of the time?
from kakoune.
Your printf
command has returned the same thing every time I tried it. However, the response very slow, and there may be a timing problem.
If I hit <enter>
before the text appears then I get 2026;0$y
in my terminal prompt (with ^[[?2026;0$y
in the line above).
If I hit enter twice (as instructed) this is what I get
^[[?2026;0$y
$ 2026;0$y # first $ here is the shell prompt
I'm using the starship prompt (the problem was reproducing before I installed it), without that I get
# empty line
$ 2026;0$y # first $ here is the shell prompt
It also makes the cursor disappear, and causes the terminal to make a notification sound when navigated away from, and to.
from kakoune.
I've seen problems from the startup query for terminal synchronisation support too. In my case, it was over a networked serial console, whose slowness can break atomic read() of escape sequences by kakoune. (Interestingly, this is the only breakage I experience in practice with kak on a slow serial console.)
Unfortunately, disabling sync support with
set-option -add global ui_options terminal_synchronized=false
in kakrc
doesn't stop the query being sent, so Tom can't just do that to work around it.
For my own build, I have a local patch
diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc
index 86f7d09..71dedb1 100644
--- a/src/terminal_ui.cc
+++ b/src/terminal_ui.cc
@@ -1485,7 +1485,6 @@ void TerminalUI::setup_terminal()
"\033[22t" // save the current window title
"\033[?25l" // hide cursor
"\033=" // set application keypad mode, so the keypad keys send unique codes
- "\033[?2026$p" // query support for synchronize output
"\033[?2004h" // force enable bracketed-paste events
);
}
@@ -1555,6 +1554,10 @@ void TerminalUI::set_ui_options(const Options& options)
auto synchronized = find("terminal_synchronized").map(to_bool);
m_synchronized.set = (bool)synchronized;
m_synchronized.requested = synchronized.value_or(false);
+ if (not m_synchronized.queried and not m_synchronized.set) {
+ write(STDOUT_FILENO, "\033[?2026$p");
+ m_synchronized.queried = true;
+ }
m_shift_function_key = find("terminal_shift_function_key").map(str_to_int_ifp).value_or(default_shift_function_key);
diff --git a/src/terminal_ui.hh b/src/terminal_ui.hh
index e1a9633..774b436 100644
--- a/src/terminal_ui.hh
+++ b/src/terminal_ui.hh
@@ -158,6 +158,7 @@ private:
struct Synchronized
{
+ bool queried : 1;
bool supported : 1;
bool set : 1;
bool requested : 1;
to skip the query when I've explicitly disabled support. Possibly worth sending upstream if others are seeing problems too - I assumed I was the only one who used kakoune in a weird enough niche that it could cause issues.
from kakoune.
This is no longer reproducing for me anymore. Windows Terminal patched?
from kakoune.
Related Issues (20)
- [REQUEST] `close-daemonized-session` command HOT 4
- [BUG] Receiving `'vfork' is deprecated:` warnings while compiling Kakoune from source HOT 2
- [BUG] 2024.05.09 tests failing on Alpine Linux HOT 16
- [BUG] Tests failing on OpenBSD HOT 10
- [BUG] Files getting created when using autocomplete HOT 3
- [BUG] HOT 1
- [REQUEST] revert f26d4ea4 for putting tmux into background again HOT 7
- [BUG] Viewport motion no longer takes scrolloff into account
- [BUG] WhitespaceIndent face overridden by language highlighting HOT 1
- [BUG] setting a face to itself in kakrc causes hang HOT 5
- License on Logo HOT 2
- [BUG][CRASH] regex is broken HOT 1
- [BUG/QUESTION] UTF-8 characters render as question marks in kak under WezTerm on MacOS HOT 2
- [BUG] inconsistent syntax in asciidoc for buffers enclosed by stars such as scratch HOT 2
- [BUG] rendering issue in asciidoc with nested stars and backticks HOT 6
- [BUG] Alternations in lookarounds produce an unhelpful error message
- cygwin compilation error using gcc (windows10) HOT 7
- How to remove the format charaters in the man buffer [QUESTION] HOT 3
- [BUG] Numpad/Keypad numbers produce garbage
- [BUG] (?S) flag strangely changes lookaround behavior HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kakoune.