macOS: Fix using multi-key sequences to input text ignoring the first few key presses if the sequence is aborted

Fixes #1311
This commit is contained in:
Kovid Goyal 2019-02-14 15:10:13 +05:30
parent 3b25081353
commit b40ca5800d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 1 deletions

View File

@ -35,6 +35,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Fix window title for minimized windows not being updated (:iss:`1332`)
- macOS: Fix using multi-key sequences to input text ignoring the
first few key presses if the sequence is aborted (:iss:`1311`)
0.13.3 [2019-01-19]
------------------------------

View File

@ -1033,7 +1033,9 @@ is_ascii_control_char(char x) {
characters = [string string];
else
characters = (NSString*) string;
snprintf(_glfw.ns.text, sizeof(_glfw.ns.text), "%s", [characters UTF8String]);
// insertText can be called multiple times for a single key event
char *s = _glfw.ns.text + strnlen(_glfw.ns.text, sizeof(_glfw.ns.text));
snprintf(s, sizeof(_glfw.ns.text) - (s - _glfw.ns.text), "%s", [characters UTF8String]);
_glfw.ns.text[sizeof(_glfw.ns.text) - 1] = 0;
}