From af6a699db43fc0eb1fafd1a364b917cc4ba9d5e1 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 28 Dec 2020 18:29:01 +0000 Subject: [PATCH] up down better ux --- src/static/js/ace2_inner.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index deb792c8c..291c59757 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -3082,26 +3082,28 @@ function Ace2Inner() { rep.selEnd[0] = rep.selEnd[0] + (visibleLineRange[1] - visibleLineRange[0]); } top.console.log(rep.selStart[0]); - if (rep.selStart[0] === -1) rep.selStart[0] = 0; - if (rep.selEnd[0] === -1) rep.selEnd[0] = 0; + if (rep.selStart[0] === -1) { + return rep.selStart[0] = 0; + } + if (rep.selEnd[0] === -1) { + return rep.selEnd[0] = 0; + } // if the new rep is beyond the viewport // put the caret on the last line at the end of the line + top.console.log(rep.selStart[0]); if (rep.selStart[0] >= (linesLength - 1)) { - top.console.log('wait wut?'); + top.console.log('wait wut?', rep.selStart[0], linesLength - 1); let line; // need current character length of line try { line = rep.lines.atIndex(rep.selEnd[0]); } catch (e) { // silently fail, no big deal.. + line = rep.lines.atIndex(visibleLineRange[1]); } - let lineLength; - if (line) { // need to test if this is needed or not. - lineLength = line.width; - } else { - lineLength = 0; - } + const lineLength = line.width; + rep.selStart = [linesLength - 1, lineLength]; rep.selEnd = [linesLength - 1, lineLength]; }