inputMethod: Reset preedit cursor when preedit text is cleared
Without this MR, client can get wrong cursor position which index is larger than preedit string. This could leads into bugs if client handles it wrongly.
For example, with GTK_IM_MODULE= WAYLAND_DEBUG=1 gnome-text-editor 2>&1 | rg 'text_input'
, it gets following events when you delete the last char of preedit text:
[3464542.715] zwp_text_input_v3@51.preedit_string("n", 1, 1)
[3464542.748] zwp_text_input_v3@51.done(10)
[3467121.052] zwp_text_input_v3@51.preedit_string(nil, 0, 1)
[3467121.085] zwp_text_input_v3@51.done(10)
Which is obviously wrong, it should be zwp_text_input_v3@51.preedit_string(nil, 0, 0)
, this MR fixes it.
Below is the original commit message:
The preedit cursor position should be 0 when there is no preedit text, currently it will pass 1, which is the wrong previous value.