Skip to content
Permalink
Browse files

Improve up/down cursor movement

  • Loading branch information...
antonmedv committed Apr 4, 2019
1 parent 0889b96 commit acf0255e1d8e18971c4253520ebd5be0afdbe63d
Showing with 14 additions and 14 deletions.
  1. +14 −14 fx.js
28 fx.js
@@ -284,16 +284,16 @@ module.exports = function start(filename, source) {
box.key(['up', 'k'], function () {
hideStatusBar()
program.showCursor()
let rest = [...index.keys()]

const [n] = getLine(program.y)
if (typeof n !== 'undefined') {
rest = rest.filter(i => i < n)
}

if (rest.length > 0) {
const next = Math.max(...rest)
let next
for (let [i,] of index) {
if (i < n && (typeof next === 'undefined' || i > next)) {
next = i
}
}

if (typeof next !== 'undefined') {
let y = box.getScreenNumber(next) - box.childBase
if (y <= 0) {
box.scroll(-1)
@@ -309,16 +309,16 @@ module.exports = function start(filename, source) {
box.key(['down', 'j'], function () {
hideStatusBar()
program.showCursor()
let rest = [...index.keys()]

const [n] = getLine(program.y)
if (typeof n !== 'undefined') {
rest = rest.filter(i => i > n)
}

if (rest.length > 0) {
const next = Math.min(...rest)
let next
for (let [i,] of index) {
if (i > n && (typeof next === 'undefined' || i < next)) {
next = i
}
}

if (typeof next !== 'undefined') {
let y = box.getScreenNumber(next) - box.childBase
if (y >= box.height) {
box.scroll(1)

0 comments on commit acf0255

Please sign in to comment.
You can’t perform that action at this time.