Bug 250208

Summary: [GTK] delete surrounding text doesn't seem to work
Product: WebKit Reporter: ermshiperete <eb1>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: bugs-noreply, eric.schikschneit, fujii, marc, spena
Priority: P2    
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
URL: https://github.com/keymanapp/keyman/issues/7971
See Also: https://bugs.webkit.org/show_bug.cgi?id=325166
https://bugs.webkit.org/show_bug.cgi?id=327412

ermshiperete
Reported 2023-01-06 07:49:36 PST
It seems that deleting surrounding text doesn't work when typing with an IME that makes use of surrounding text, e.g. ibus-engine-keyman (https://keyman.com). Ubuntu 22.04 with Gnome Shell and X11, but also in other Ubuntu versions. To reproduce: - install Keyman 16.x together with the patched version of ibus from https://launchpad.net/~keymanapp/+archive/ubuntu/keyman-beta - start km-config and download Vietnamese Telex keyboard - in km-config in the Download dialog, switch to Vietnamese Telex keyboard and type `boo` - alternatively, start WebKit minibrowser, load a webpage with a textfield (e.g. https://www.editpad.org/) and type `boo` (with Vietnamese Telex keyboard active) Expected result: `bô` Actual result: `boô` Note that in the minibrowser things work correctly in the address bar, but not on a webpage. When typing the second `o` Keyman sends the delete-surrounding signal to delete the first `o` (one character to the left of the IP) and then adds the `ô`. Maybe relevant: https://bugs.webkit.org/show_bug.cgi?id=205716 https://bugs.webkit.org/show_bug.cgi?id=206352 See also: https://github.com/keymanapp/keyman/issues/7971
Attachments
eric.schikschneit
Comment 1 2026-10-30 07:53:29 PDT
I believe I’ve found the cause. WebKitInputMethodContextImplGtk connects the GtkIMContext preedit-start, preedit-changed, preedit-end, commit and retrieve-surrounding signals, but not delete-surrounding. InputMethodFilter already handles delete-surrounding on the WebKitInputMethodContext, but GTK’s signal never reaches it, so deletions requested by an input method are dropped. That matches the original report: GTK entries such as the MiniBrowser address bar handle delete-surrounding themselves, so deleting works there, but not in web content. It also isn’t specific to IBus. I hit the same problem on Wayland with text-input-v3. In a WAYLAND_DEBUG trace, GTK receives delete_surrounding_text(1, 0), commit_string("") and done, and the field is unchanged. Since bug 327412, WebKitInputMethodContext::delete-surrounding counts UTF-16 code units from the start of the selection, while GtkIMContext counts characters from the cursor. So the fix converts the range before re-emitting it, using the surrounding text the context already keeps. I’ll upload a pull request with the fix and unit tests for the conversion. I saw that Simon Pena and Fujii Hironori worked on similar issues in 325166, 327412, 327694.
eric.schikschneit
Comment 2 2026-10-30 08:18:34 PDT
Fujii Hironori
Comment 3 2026-11-02 00:18:07 PST
Note You need to log in before you can comment on or make changes to this bug.