Skip to content

Commit 995f394

Browse files
committed
When direction=rtl, fix home/end and arrow motion across line boundaries
Closes #6117
1 parent f41c636 commit 995f394

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/edit/methods.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,9 @@ function findPosH(doc, pos, dir, unit, visually) {
469469
let oldPos = pos
470470
let origDir = dir
471471
let lineObj = getLine(doc, pos.line)
472+
let lineDir = visually && doc.cm && doc.cm.getOption("direction") == "rtl" ? -dir : dir
472473
function findNextLine() {
473-
let l = pos.line + dir
474+
let l = pos.line + lineDir
474475
if (l < doc.first || l >= doc.first + doc.size) return false
475476
pos = new Pos(l, pos.ch, pos.sticky)
476477
return lineObj = getLine(doc, l)
@@ -484,7 +485,7 @@ function findPosH(doc, pos, dir, unit, visually) {
484485
}
485486
if (next == null) {
486487
if (!boundToLine && findNextLine())
487-
pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir)
488+
pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir)
488489
else
489490
return false
490491
} else {

src/input/movement.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function moveLogically(line, start, dir) {
1515

1616
export function endOfLine(visually, cm, lineObj, lineNo, dir) {
1717
if (visually) {
18+
if (cm.getOption("direction") == "rtl") dir = -dir
1819
let order = getOrder(lineObj, cm.doc.direction)
1920
if (order) {
2021
let part = dir < 0 ? lst(order) : order[0]

0 commit comments

Comments
 (0)