From 78487f1c24becbdee05b046128b5fdae14662cc0 Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Fri, 18 Jul 2025 20:47:18 +0200 Subject: [PATCH] Optimize editor newline command This may be the wrong place for this optimization, but I don't have the luxury of having time to do things right. Hell, the editor is all in one big file, does it look like I have time to spare for quality? --- wip-duuqnd/editor/editor.lisp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/wip-duuqnd/editor/editor.lisp b/wip-duuqnd/editor/editor.lisp index c818f63..cf56cf1 100644 --- a/wip-duuqnd/editor/editor.lisp +++ b/wip-duuqnd/editor/editor.lisp @@ -592,11 +592,22 @@ Additionally ensures correct line numbers on the way, as a bonus." (defun com-newline () (with-editor-accessors *editor* (:current-column column :current-line line) - (ensure-correct-line-number (new-line-at line column)) - (redisplay-view-from-line (current-view *editor*) line) - (com-next-line) - (com-beginning-of-line) - (redisplay-line line))) + (let* ((old-line line) + (new-line (new-line-at line column)) + (in-view-p (line-in-view new-line (current-view *editor*)))) + (ensure-correct-line-number new-line) + (com-next-line) + (com-beginning-of-line) + (when in-view-p + (set-scrolling-region (view-line-number (current-view *editor*) + new-line) + (1- *status-line-position*)) + (scroll-screen-down) + (set-scrolling-region)) + (when (line-in-view old-line (current-view *editor*)) + (redisplay-line old-line :start column)) + (when in-view-p + (redisplay-line new-line))))) (defun com-beginning-of-line () (with-editor-accessors *editor* (:current-column column