diff --git a/qt/ts/src/editor.ts b/qt/ts/src/editor.ts index addb2f7a6..0dca144d0 100644 --- a/qt/ts/src/editor.ts +++ b/qt/ts/src/editor.ts @@ -59,6 +59,29 @@ function onKey(evt: KeyboardEvent) { focusPrevious(); return; } + + // fix Ctrl+right/left handling in RTL fields + if (currentField.dir === "rtl") { + const selection = window.getSelection(); + let granularity = "character"; + let alter = "move"; + if (evt.ctrlKey) { + granularity = "word"; + } + if (evt.shiftKey) { + alter = "extend"; + } + if (evt.which === 39) { + selection.modify(alter, "right", granularity); + evt.preventDefault(); + return; + } else if (evt.which === 37) { + selection.modify(alter, "left", granularity); + evt.preventDefault(); + return; + } + } + triggerKeyTimer(); }