mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Fix ibus first keystroke goes two (#1886)
Calling `moveCaretToEnd()` when `richText` is empty will cause the first keystroke of ibus-based input methods with candidates to goes double. For example, if you type "a" it becomes "aa". This problem exists in many linux distributions. When `richText` is empty, there is no need to place the caret, just return as a workaround.
This commit is contained in:
parent
e50d40cedf
commit
5e1b67bcbc
2 changed files with 9 additions and 0 deletions
|
@ -100,6 +100,7 @@ Bruce Harris <github.com/bruceharris>
|
||||||
Patric Cunha <patricc@agap2.pt>
|
Patric Cunha <patricc@agap2.pt>
|
||||||
Brayan Oliveira <github.com/BrayanDSO>
|
Brayan Oliveira <github.com/BrayanDSO>
|
||||||
Luka Warren <github.com/lukawarren>
|
Luka Warren <github.com/lukawarren>
|
||||||
|
wisherhxl <wisherhxl@gmail.com>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
async function moveCaretToEnd(): Promise<void> {
|
async function moveCaretToEnd(): Promise<void> {
|
||||||
const richText = await richTextPromise;
|
const richText = await richTextPromise;
|
||||||
|
if (richText.textContent?.length === 0) {
|
||||||
|
// Calling this method when richText is empty will cause the first keystroke of
|
||||||
|
// ibus-based input methods with candidates to go double. For example, if you
|
||||||
|
// type "a" it becomes "aa". This problem exists in many linux distributions.
|
||||||
|
// When richText is empty, there is no need to place the caret, just return.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
placeCaretAfterContent(richText);
|
placeCaretAfterContent(richText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue