Skip to content

Commit

Permalink
When direction=rtl, fix home/end and arrow motion across line boundaries
Browse files Browse the repository at this point in the history
Closes #6117
  • Loading branch information
marijnh committed Jan 20, 2020
1 parent f41c636 commit 995f394
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/edit/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,9 @@ function findPosH(doc, pos, dir, unit, visually) {
let oldPos = pos
let origDir = dir
let lineObj = getLine(doc, pos.line)
let lineDir = visually && doc.cm && doc.cm.getOption("direction") == "rtl" ? -dir : dir
function findNextLine() {
let l = pos.line + dir
let l = pos.line + lineDir
if (l < doc.first || l >= doc.first + doc.size) return false
pos = new Pos(l, pos.ch, pos.sticky)
return lineObj = getLine(doc, l)
Expand All @@ -484,7 +485,7 @@ function findPosH(doc, pos, dir, unit, visually) {
}
if (next == null) {
if (!boundToLine && findNextLine())
pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir)
pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir)
else
return false
} else {
Expand Down
1 change: 1 addition & 0 deletions src/input/movement.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function moveLogically(line, start, dir) {

export function endOfLine(visually, cm, lineObj, lineNo, dir) {
if (visually) {
if (cm.getOption("direction") == "rtl") dir = -dir
let order = getOrder(lineObj, cm.doc.direction)
if (order) {
let part = dir < 0 ? lst(order) : order[0]
Expand Down

0 comments on commit 995f394

Please sign in to comment.