Skip to content

Commit b577d37

Browse files
author
elfmz
authored
Merge pull request elfmz#3394 from michaellukashov/fix-vt-child-bracketed-paste-doubling
fix(vt): suppress key-up events for plain-text chars to prevent doubling chars
2 parents 9d64527 + 45f12dd commit b577d37

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

far2l/src/hmenu.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,18 @@ int HMenu::ProcessKey(FarKey Key)
172172
FrameManager->ProcessKey(KEY_ALTF9);
173173
break;
174174
case KEY_OP_PLAINTEXT: {
175-
const wchar_t *str = eStackAsString();
175+
FARString strText;
176+
if (!GPastedText.IsEmpty()) {
177+
strText = GPastedText;
178+
GPastedText.Clear();
179+
} else {
180+
strText = eStackAsString();
181+
}
176182

177-
if (!*str)
183+
if (strText.IsEmpty())
178184
return FALSE;
179185

180-
Key = *str;
186+
Key = strText[0];
181187
break;
182188
}
183189
case KEY_NONE:

far2l/src/vt/vtshell.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,11 @@ class VTShell : VTOutputReader::IProcessor, VTInputReader::IProcessor, IVTShell
900900
if (spec)
901901
return spec;
902902
}
903+
// For plain text characters (VK==0) there is no terminal-level key-release
904+
// representation. Writing the same raw char on UP would double every character
905+
// in bracketed paste and in any mode that forwards key-up events (win32/kitty).
906+
if (!KeyEvent.bKeyDown)
907+
return std::string();
903908

904909
wchar_t wz[3] = {KeyEvent.uChar.UnicodeChar, 0};
905910
if (_slavename.empty() && wz[0] == '\r') //pipes fallback

0 commit comments

Comments
 (0)