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?
This commit is contained in:
John Lorentzson 2025-07-18 20:47:18 +02:00
parent 2157589190
commit 78487f1c24

View file

@ -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