app: always preserve IME snippet replacement text

When a text range in the IME snippet is replaced, the replacement
is discarded if the range don't overlap with the snippet range. However,
the replacement is more relevant than whatever snippet is current.
This change discards the snippet in case of no overlap.

As a bonus, IMEs that leaves the snippet range at [0:0] will have the
snippet track the composing region now.

The FuzzIME test is adjusted to always generate replacements that overlap
Editor content; otherwise the IME snippet and editor state can't be expected
to match.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-02-12 12:01:10 +01:00
parent 9e23412a01
commit 216f2c3295
2 changed files with 10 additions and 8 deletions
+3 -2
View File
@@ -47,9 +47,10 @@ func FuzzIME(f *testing.F) {
)
const cmdLen = 5
for len(cmds) >= cmdLen {
n := e.Len()
rng := key.Range{
Start: int(cmds[1]),
End: int(cmds[2]),
Start: int(cmds[1]) % (n + 1),
End: int(cmds[2]) % (n + 1),
}
switch cmds[0] % cmdLen {
case cmdReplace: