fix: sougou IME issue on Windows (#1000)
This commit is contained in:
parent
c6909a7a04
commit
4edd0e00e8
2 changed files with 11 additions and 1 deletions
|
|
@ -29,7 +29,9 @@ Diff getDiff(String oldText, String newText, int cursorPosition) {
|
||||||
final delta = newText.length - end;
|
final delta = newText.length - end;
|
||||||
final limit = math.max(0, cursorPosition - delta);
|
final limit = math.max(0, cursorPosition - delta);
|
||||||
|
|
||||||
while (end > limit && oldText[end - 1] == newText[end + delta - 1]) {
|
while (end > limit &&
|
||||||
|
oldText[end - 1] == newText[end + delta - 1] &&
|
||||||
|
!newText.startsWith(oldText)) {
|
||||||
end--;
|
end--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,14 @@ void main() {
|
||||||
expect(diff.toString(), 'Diff[0, "", "W"]');
|
expect(diff.toString(), 'Diff[0, "", "W"]');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getDiff for Chinese', () {
|
||||||
|
const oldText = '一个';
|
||||||
|
const newText = '一个两个';
|
||||||
|
|
||||||
|
final diff = getDiff(oldText, newText, 0);
|
||||||
|
expect(diff.toString(), 'Diff[2, "", "两个"]');
|
||||||
|
});
|
||||||
|
|
||||||
test('getTextEditingDeltas insertion', () {
|
test('getTextEditingDeltas insertion', () {
|
||||||
const oldValue = TextEditingValue(text: 'elcome');
|
const oldValue = TextEditingValue(text: 'elcome');
|
||||||
const newValue = TextEditingValue(text: 'Welcome');
|
const newValue = TextEditingValue(text: 'Welcome');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue