diff --git a/fcore/cursor.sml b/fcore/cursor.sml index 4162301..f066475 100644 --- a/fcore/cursor.sml +++ b/fcore/cursor.sml @@ -1044,7 +1044,7 @@ struct * increment by 1 as we want to go to first char after line break *) bufferIdx + lineIdx else - bufferIdx + lineIdx + 1 + bufferIdx + lineIdx end end | (_, _) => diff --git a/fcore/normal-mode/normal-move.sml b/fcore/normal-mode/normal-move.sml index 7feacd8..db76d2c 100644 --- a/fcore/normal-mode/normal-move.sml +++ b/fcore/normal-mode/normal-move.sml @@ -129,8 +129,17 @@ struct (* get idx of first chr after linebreak *) val cursorIdx = Cursor.getLineStartIdx (buffer, reqLine) - val buffer = LineGap.goToIdx (cursorIdx, buffer) + + (* we got the line start idx, but we want to move to the index + * after it, where the first character of the line is. + * Unless the next character is a line break, + * in which case we want to stay at the current idx. *) + val cursorIdx = + if Cursor.isNextChrEndOfLine (buffer, cursorIdx) then cursorIdx + else cursorIdx + 1 + val buffer = LineGap.goToIdx (cursorIdx, buffer) + val visualScrollColumn = TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth, prevScrollColumn)