Function: evil-cleanup-insert-state

evil-cleanup-insert-state is a byte-compiled function defined in evil-states.el.

Signature

(evil-cleanup-insert-state)

Documentation

Called when Insert or Replace state is about to be exited.

Handles the repeat-count of the insertion command.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-states.el
(defun evil-cleanup-insert-state ()
  "Called when Insert or Replace state is about to be exited.
Handles the repeat-count of the insertion command."
  (when evil-insert-count
    (let (pre-command-hook post-command-hook)
      (dotimes (_ (1- evil-insert-count))
        (when evil-insert-lines
          (evil-insert-newline-below)
          (when evil-auto-indent
            (indent-according-to-mode)))
        (evil-execute-repeat-info (cdr evil-insert-repeat-info)))))
  (when evil-insert-vcount
    (let ((buffer-invisibility-spec
           (if (listp buffer-invisibility-spec)
               ;; make all lines hidden by hideshow temporarily visible
               (cl-remove-if (lambda (x) (eq (or (car-safe x) x) 'hs))
                             buffer-invisibility-spec)
             buffer-invisibility-spec)))
      (cl-destructuring-bind (line col vcount) evil-insert-vcount
        (save-excursion
          (combine-change-calls ; For performance
              (progn (goto-char (point-min))
                     (line-beginning-position line))
              (line-end-position (+ line vcount -1))
            (let (pre-command-hook post-command-hook) ; For performance
              (dotimes (v (1- vcount))
                (goto-char (point-min))
                (forward-line (+ line v))
                (when (or (not evil-insert-skip-empty-lines)
                          (not (integerp col))
                          (save-excursion
                            (evil-move-end-of-line)
                            (>= (current-column) col)))
                  (if (integerp col)
                      (move-to-column col t)
                    (funcall col))
                  (dotimes (_ (or evil-insert-count 1))
                    (evil-execute-repeat-info (cdr evil-insert-repeat-info)))))))))))
  (and evil-want-fine-undo (evil-end-undo-step)))