[gtk/gtk-4-2: 61/91] imcontext: Fix cursor positions




commit d35e069436b5d79a93fc61540f2d0147d57a43c3
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Apr 21 06:27:26 2021 -0400

    imcontext: Fix cursor positions
    
    gtk_im_context_get_preedit_string is documented to
    return the cursor position as a character offset,
    not a byte count. So return that.
    
    Fixed: #3885

 gtk/gtkimcontextsimple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index a3a2c54c8f..074ffdd01f 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -1152,7 +1152,7 @@ gtk_im_context_simple_get_preedit_string (GtkIMContext   *context,
     }
 
   if (cursor_pos)
-    *cursor_pos = s->len;
+    *cursor_pos = g_utf8_strlen (s->str, s->len);
 
   if (attrs)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]