From 7e1115479b68279295f72c6e504da42368650049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aske=20B=C3=A6kdal=20M=C3=B8ller?= Date: Mon, 24 Apr 2023 12:46:25 +0200 Subject: [PATCH] clients: keyboard: fix delete before cursor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When editing a text field in chromium deleting the surrounding text with backspace fails with `The selection range for surrounding text is invalid` It seems like `(start - keyboard->surrounding_text) - keyboard->surrounding_cursor` evaluates to -1. As far as i can tell `start - keyboard->surrounding_text` evaluates to the index in the surrounding_text char arrays that should be deleted. Signed-off-by: Aske Bækdal Møller (cherry picked from commit 33ec3898d0ae71a640aea9164f61311d6c32c753) --- clients/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/keyboard.c b/clients/keyboard.c index deddd78d9..e5fa3296a 100644 --- a/clients/keyboard.c +++ b/clients/keyboard.c @@ -506,7 +506,7 @@ delete_before_cursor(struct virtual_keyboard *keyboard) end = keyboard->surrounding_text + keyboard->surrounding_cursor; zwp_input_method_context_v1_delete_surrounding_text(keyboard->context, - (start - keyboard->surrounding_text) - keyboard->surrounding_cursor, + start - keyboard->surrounding_text, end - start); zwp_input_method_context_v1_commit_string(keyboard->context, keyboard->serial,