Fix mc/mark-all-in-region leaving fake cursor.

Previously this function left a remain of fake function if there was
only one matching string in selected region.
This commit is contained in:
Seungheon Oh 2022-08-20 23:20:24 -05:00 committed by Magnar Sveen
parent 225fc0e889
commit 1e4842d129

View File

@ -419,16 +419,18 @@ matching the currently active region."
(progn (progn
(mc/remove-fake-cursors) (mc/remove-fake-cursors)
(goto-char beg) (goto-char beg)
(while (search-forward search end t) (let ((lastmatch))
(push-mark (match-beginning 0)) (while (search-forward search end t)
(mc/create-fake-cursor-at-point)) (push-mark (match-beginning 0))
(let ((first (mc/furthest-cursor-before-point))) (mc/create-fake-cursor-at-point)
(if (not first) (setq lastmatch t))
(error "Search failed for %S" search) (unless lastmatch
(mc/pop-state-from-overlay first))) (error "Search failed for %S" search)))
(if (> (mc/num-cursors) 1) (goto-char (match-end 0))
(multiple-cursors-mode 1) (if (< (mc/num-cursors) 3)
(mc/disable-multiple-cursors-mode)))))) (mc/disable-multiple-cursors-mode)
(mc/pop-state-from-overlay (mc/furthest-cursor-before-point))
(multiple-cursors-mode 1))))))
;;;###autoload ;;;###autoload
(defun mc/mark-all-in-region-regexp (beg end) (defun mc/mark-all-in-region-regexp (beg end)