Maximus5 / ConEmu

Customizable Windows terminal with tabs, splits, quake-style, hotkeys and more
https://conemu.github.io/
BSD 3-Clause "New" or "Revised" License
8.58k stars 573 forks source link

Sometimes pressing on arrow keys prints symbols #1691

Open lazycoder-ru opened 6 years ago

lazycoder-ru commented 6 years ago

Versions

ConEmu build: 180626 x64 OS version: Windows 10 x32/x64 Used shell version: bash.exe from WSL(debian)

Problem description

Sometimes arrow keys(and PgUp, PgDn) do not move the cursur, but prints symbols. It appears only with ConEmu, but when I run bash.exe directly from Windows I have no problems.

Steps to reproduce

  1. Open ConEmu;
  2. Run task Bash(from linux subsystem);
  3. ssh to remote server;
  4. open text editor and move cursor by arrow keys;

Actual results

Arrow keys sometimes prints symbols(A,B,C,D).

Expected results

Arrow keys just moving cursor in editor.

Additional files

conemu_error

grable0 commented 1 year ago

@chrisant996

Im sorry, spoke too soon :/ After further testing it seems i can reproduce it even without Clink after all, dont know how i missed it yesterday :(. Even removing the prompt changes nothing. Funny enough doing the same in the ConEmu->Debug->RealConsole window does not exhibit the behavior. Im gonna have to chalk it up to my ancient windows version...

But il dump all the relevant info below just in case.

Windows 10 1511. ConEmu 230724 (Stable). Clink v1.5.4.6f56dd.

The task: cmd -new_console:n:C:"C:\Projects\cmd_exe_16x16.ico" /k "%ConEmuBaseDir%\CmdInit_Lean.cmd"

Im sidestepping CmdInit.cmd with my own CmdInit_Lean.cmd:

prompt $E[32m$E]9;8;"USERNAME"$E\@$E]9;8;"COMPUTERNAME"$E\$S$E[92m$P$E[90m$_$$$E[m$S$E]9;12$E\
"%ConEmuBaseDir%\clink\clink_x64.exe" inject

So since im injecting clink manually, it is disabled in the ConEmu settings. And i checked that Clink is not set to autorun.

Decoded RealConsole modes from the statusbar (0x1b8,0x07):

input mode:
        ENABLE_INSERT_MODE
        ENABLE_MOUSE_INPUT
        ENABLE_WINDOW_INPUT
output mode:
        ENABLE_PROCESSED_OUTPUT
        ENABLE_WRAP_AT_EOL_OUTPUT
        ENABLE_VIRTUAL_TERMINAL_PROCESSING

They never change.

clink.log, from a fresh console running find and pressing up and enter

19a4 start_logger              160 ---- 2023/09/03 10:19:36.124 -------------------------------------------------
19a4 start_logger              166 Host process is 'cmd.exe' (pid 6564)
19a4 start_logger              170 DLL path is 'C:\Program Files\ConEmu\ConEmu\clink'
19a4 start_logger              185 Windows version 10.0.10586 (x64)
19a4 start_logger              187 Clink version 1.5.4.6f56dd (x64)
19a4 hook_setter::hook_setter  159 >>> Started hook transaction.
19a4 hook_setter::attach_iat   316 Attempting to hook SetEnvironmentVariableW in IAT for module 00007FF7077B0000.
19a4 pe_info::iterate_imports  195 Found import in 'api-ms-win-core-processenvironment-l1-2-0.dll'
19a4 find_iat                  124 Found import at 00007FF7077D8378 (value is 00007FFD9AA3A3F0).
19a4 hook_setter::attach_iat   316 Attempting to hook WriteConsoleW in IAT for module 00007FF7077B0000.
19a4 pe_info::iterate_imports  195 Found import in 'api-ms-win-core-console-l1-1-0.dll'
19a4 find_iat                  124 Found import at 00007FF7077D8010 (value is 00007FFD9AA0C360).
19a4 hook_setter::attach_iat   316 Attempting to hook GetEnvironmentVariableW in IAT for module 00007FF7077B0000.
19a4 pe_info::iterate_imports  195 Found import in 'api-ms-win-core-processenvironment-l1-2-0.dll'
19a4 find_iat                  124 Found import at 00007FF7077D8350 (value is 00007FFD9A9FC580).
19a4 hook_setter::commit       207 <<< Hook transaction committed.
19a4 hook_setter::hook_setter  159 >>> Started hook transaction.
19a4 hook_setter::detach_iat   359 Attempting to unhook 00007FFD6608BC80 from GetEnvironmentVariableW in IAT for module 00007FF7077B0000.
19a4 pe_info::iterate_imports  195 Found import in 'api-ms-win-core-processenvironment-l1-2-0.dll'
19a4 find_iat                  124 Found import at 00007FF7077D8350 (value is 00007FFD6608BC80).
19a4 hook_setter::commit       207 <<< Hook transaction committed.
19a4 hook_setter::hook_setter  159 >>> Started hook transaction.
19a4 hook_setter::attach_iat   316 Attempting to hook ReadConsoleW in IAT for module 00007FF7077B0000.
19a4 pe_info::iterate_imports  195 Found import in 'api-ms-win-core-console-l1-1-0.dll'
19a4 find_iat                  124 Found import at 00007FF7077D8038 (value is 00007FFD9A9E6AA0).
19a4 hook_setter::commit       207 <<< Hook transaction committed.
19a4 hook_setter::hook_setter  159 >>> Started hook transaction.
19a4 hook_setter::attach_iat   316 Attempting to hook SetConsoleTitleW in IAT for module 00007FF7077B0000.
19a4 pe_info::iterate_imports  195 Found import in 'api-ms-win-core-console-l2-1-0.dll'
19a4 find_iat                  124 Found import at 00007FF7077D8078 (value is 00007FFD9AA4E800).
19a4 hook_setter::commit       207 <<< Hook transaction committed.
19a4 win_screen_buffer::begin  366 Using native terminal support (auto mode found 'ConEmuHk64.dll').
19a4 LOGCURSORPOS              471 CURSORPOS 0,2
19a4 terminal_log_write        871 RL_OUTSTREAM "[?12l[?25h", 12
19a4 load_user_inputrc        1818 Found Readline inputrc at 'C:\Users\grable\.inputrc'
19a4 host_lua::load_scripts    158 Loaded 1 Lua scripts in 0 ms
19a4 ={update.lua}               0 Clink updater: too soon to check for updates (1693555327 vs 1693729176).
19a4 history_db::initialise   1264 master bank ctag: |CTAG_1693084509_44832578_6892_0
19a4 history_db::compact      1526 History:  9463 active, 929 deleted
19a4 rl_module::rl_module     2315 terminal size 140 x 42
19a4 LOGCURSORPOS              471 CURSORPOS 0,5
19a4 terminal_log_write        871 RL_OUTSTREAM "[?12l[?25h", 12
19a4 LOGCURSORPOS              471 CURSORPOS 0,5
19a4 terminal_log_write        871 RL_OUTSTREAM "grable@GRABLE-DESKTOP C:\

$ ]9;12\", 63
19a4 rl_module::on_input      2838 INPUT "f", 1
19a4 LOGCURSORPOS              471 CURSORPOS 2,6
19a4 terminal_log_write        871 RL_OUTSTREAM "f", 17
19a4 LOGCURSORPOS              471 CURSORPOS 3,6
19a4 terminal_log_write        871 RL_OUTSTREAM "fmpeg -version", 31
19a4 LOGCURSORPOS              471 CURSORPOS 3,6
19a4 terminal_log_write        871 RL_OUTSTREAM "f", 22
19a4 rl_module::on_input      2838 INPUT "i", 1
19a4 LOGCURSORPOS              471 CURSORPOS 3,6
19a4 terminal_log_write        871 RL_OUTSTREAM "fi             ", 39
19a4 LOGCURSORPOS              471 CURSORPOS 4,6
19a4 terminal_log_write        871 RL_OUTSTREAM "nd /?", 22
19a4 rl_module::on_input      2838 INPUT "n", 1
19a4 LOGCURSORPOS              471 CURSORPOS 4,6
19a4 terminal_log_write        871 RL_OUTSTREAM "n", 17
19a4 rl_module::on_input      2838 INPUT "d", 1
19a4 LOGCURSORPOS              471 CURSORPOS 5,6
19a4 terminal_log_write        871 RL_OUTSTREAM "d", 17
19a4 LOGCURSORPOS              471 CURSORPOS 6,6
19a4 terminal_log_write        871 RL_OUTSTREAM "find", 25
19a4 rl_module::on_input      2838 INPUT "
", 1
19a4 LOGCURSORPOS              471 CURSORPOS 6,6
19a4 terminal_log_write        871 RL_OUTSTREAM "   ", 7
19a4 LOGCURSORPOS              471 CURSORPOS 6,6
19a4 terminal_log_write        871 RL_OUTSTREAM "
", 1
19a4 LOGCURSORPOS              471 CURSORPOS 0,7
19a4 terminal_log_write        871 RL_OUTSTREAM "
", 1
19a4 LOGCURSORPOS              471 CURSORPOS 0,7
19a4 terminal_log_write        871 RL_OUTSTREAM "
", 1
19a4 LOGCURSORPOS              471 CURSORPOS 0,7
19a4 terminal_log_write        871 RL_OUTSTREAM "", 3
19a4 LOGCURSORPOS              471 CURSORPOS 0,7
19a4 terminal_log_write        871 RL_OUTSTREAM "", 3
19a4 LOGCURSORPOS              471 CURSORPOS 0,6
19a4 terminal_log_write        871 RL_OUTSTREAM "
", 1
19a4 history_db::compact      1526 History:  9460 active, 932 deleted
19a4 LOGCURSORPOS              471 CURSORPOS 0,9
19a4 terminal_log_write        871 RL_OUTSTREAM "[?12l[?25h", 12
19a4 LOGCURSORPOS              471 CURSORPOS 0,9
19a4 terminal_log_write        871 RL_OUTSTREAM "grable@GRABLE-DESKTOP C:\

$ ]9;12\", 63
19a4 rl_module::on_input      2838 INPUT "", 1
19a4 rl_module::on_input      2838 INPUT "[", 1
19a4 rl_module::on_input      2838 INPUT "2", 1
19a4 rl_module::on_input      2838 INPUT "7", 1
19a4 rl_module::on_input      2838 INPUT ";", 1
19a4 rl_module::on_input      2838 INPUT "2", 1
19a4 rl_module::on_input      2838 INPUT "7", 1
19a4 rl_module::on_input      2838 INPUT "~", 1
19a4 rl_module::on_input      2838 INPUT "[", 1
19a4 LOGCURSORPOS              471 CURSORPOS 2,10
19a4 terminal_log_write        871 RL_OUTSTREAM "[A", 31
19a4 rl_module::on_input      2838 INPUT "", 1
19a4 rl_module::on_input      2838 INPUT "[", 1
19a4 rl_module::on_input      2838 INPUT "2", 1
19a4 rl_module::on_input      2838 INPUT "7", 1
19a4 rl_module::on_input      2838 INPUT ";", 1
19a4 rl_module::on_input      2838 INPUT "2", 1
19a4 rl_module::on_input      2838 INPUT "7", 1
19a4 rl_module::on_input      2838 INPUT "~", 1
19a4 LOGCURSORPOS              471 CURSORPOS 4,10
19a4 terminal_log_write        871 RL_OUTSTREAM "  ", 10
19a4 rl_module::on_input      2838 INPUT "[", 1
19a4 LOGCURSORPOS              471 CURSORPOS 2,10
19a4 terminal_log_write        871 RL_OUTSTREAM "[A", 31
19a4 rl_module::on_input      2838 INPUT "
", 1
19a4 LOGCURSORPOS              471 CURSORPOS 4,10
19a4 terminal_log_write        871 RL_OUTSTREAM "
", 1
19a4 LOGCURSORPOS              471 CURSORPOS 0,11
19a4 terminal_log_write        871 RL_OUTSTREAM "
", 1
19a4 LOGCURSORPOS              471 CURSORPOS 0,11
19a4 terminal_log_write        871 RL_OUTSTREAM "
", 1
19a4 LOGCURSORPOS              471 CURSORPOS 0,11
19a4 terminal_log_write        871 RL_OUTSTREAM "", 3
19a4 LOGCURSORPOS              471 CURSORPOS 0,11
19a4 terminal_log_write        871 RL_OUTSTREAM "", 3
19a4 LOGCURSORPOS              471 CURSORPOS 0,10
19a4 terminal_log_write        871 RL_OUTSTREAM "
", 1
19a4 history_db::compact      1526 History:  9459 active, 933 deleted
19a4 LOGCURSORPOS              471 CURSORPOS 0,14
19a4 terminal_log_write        871 RL_OUTSTREAM "[?12l[?25h", 12
19a4 LOGCURSORPOS              471 CURSORPOS 0,14
19a4 terminal_log_write        871 RL_OUTSTREAM "grable@GRABLE-DESKTOP C:\

$ ]9;12\", 63
chrisant996 commented 1 year ago

@grable0 Thank you for sharing the update, and that Clink isn't the cause. It might be related to your version of Windows, but it might just be a ConEmu issue.

FWIW, it looks like clink set terminal.raw_esc true will make it so even when ConEmu is in XK mode, Clink will be able to interpret the input. But you'll lose the ability for pressing Esc to clear the input line; the Esc key will instead work how it does in Unix/Linux, with the same quirks about Esc and the same situations where input can get locked up, etc. But adding [$E]9;10;0$E\](https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC) to your prompt is the better option.

There is one more thing we can do, if you're interested to get to the bottom of this: We could use Time Travel Debugging to capture a log of what ConEmu does, you could send me the log, and I could analyze it to find precisely why ConEmu is activating XTerm input mode. If you're interested/willing, here is what it would involve:

If you're up for that, send an email to the address in my github profile.

P.S. The log file you shared helped me discover a loophole in the input logging in Clink (regression introduced in v1.5.2), where it can miss logging part of the input in some cases. I've updated the logging to fix the loophole.