From 18fc8dad37c944e9f3cfe708df8648ac234ac3c8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 29 Jan 2023 19:49:50 +0530 Subject: [PATCH] Instead of calling insertText duplicate some of its code so we arent limited in the size of text we can insert --- glfw/cocoa_window.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index e5b754d2c..290112d48 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1617,7 +1617,16 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) { } if (text && [text length] > 0) { // Terminal.app inserts the output, do the same - [self insertText:text replacementRange:NSMakeRange(0, [markedText length])]; + const char *utf8 = polymorphic_string_as_utf8(text); + if ([self hasMarkedText]) { + [self unmarkText]; + debug_key("Clearing pre-edit because insertText called from readSelectionFromPasteboard\n"); + GLFWkeyevent glfw_keyevent = {.ime_state = GLFW_IME_PREEDIT_CHANGED}; + _glfwInputKeyboard(window, &glfw_keyevent); + } + debug_key("Sending text received in readSelectionFromPasteboard as key event\n"); + GLFWkeyevent glfw_keyevent = {.text=utf8}; + _glfwInputKeyboard(window, &glfw_keyevent); return YES; } return NO;