<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>250208</bug_id>
          
          <creation_ts>2023-01-06 07:49:36 -0800</creation_ts>
          <short_desc>[GTK] delete surrounding text doesn&apos;t seem to work</short_desc>
          <delta_ts>2026-11-02 00:18:07 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=325166</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=327412</see_also>
          <bug_file_loc>https://github.com/keymanapp/keyman/issues/7971</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="ermshiperete">eb1</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>eric.schikschneit</cc>
    
    <cc>fujii</cc>
    
    <cc>marc</cc>
    
    <cc>spena</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1923500</commentid>
    <comment_count>0</comment_count>
    <who name="ermshiperete">eb1</who>
    <bug_when>2023-01-06 07:49:36 -0800</bug_when>
    <thetext>It seems that deleting surrounding text doesn&apos;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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2271940</commentid>
    <comment_count>1</comment_count>
    <who name="">eric.schikschneit</who>
    <bug_when>2026-10-30 07:53:29 -0700</bug_when>
    <thetext>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(&quot;&quot;) 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2271946</commentid>
    <comment_count>2</comment_count>
    <who name="">eric.schikschneit</who>
    <bug_when>2026-10-30 08:18:34 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/79052</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2272816</commentid>
    <comment_count>3</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2026-11-02 00:18:07 -0800</bug_when>
    <thetext>Another PR: https://github.com/WebKit/WebKit/pull/79275</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>