Giter Club home page Giter Club logo

Comments (10)

Screwtapello avatar Screwtapello commented on June 18, 2024 2

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.

caksoylar avatar caksoylar commented on June 18, 2024

Can confirm the same here. Doesn't happen in tmux, which is probably to be expected.

from kakoune.

Screwtapello avatar Screwtapello commented on June 18, 2024

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.

tom-huntington avatar tom-huntington commented on June 18, 2024

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.

tom-huntington avatar tom-huntington commented on June 18, 2024

This also happens if I open a second client

# First shell
kak -s myproject
# Second shell
kak -c myproject
# keep pipe:y

from kakoune.

tom-huntington avatar tom-huntington commented on June 18, 2024

tmux and command prompt send nothing.

Terminal sends

^[[?2026;0$y

from kakoune.

Screwtapello avatar Screwtapello commented on June 18, 2024

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.

tom-huntington avatar tom-huntington commented on June 18, 2024

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.

arachsys avatar arachsys commented on June 18, 2024

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.

tom-huntington avatar tom-huntington commented on June 18, 2024

This is no longer reproducing for me anymore. Windows Terminal patched?

from kakoune.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.