branch: elpa/multiple-cursors commit 1e4842d1297241a5277bfd5c7bfab9e8711da60a Author: Seungheon Oh <seungheon....@gmail.com> Commit: Magnar Sveen <magn...@gmail.com>
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. --- mc-mark-more.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mc-mark-more.el b/mc-mark-more.el index 635e01298e..dc5b975606 100644 --- a/mc-mark-more.el +++ b/mc-mark-more.el @@ -419,16 +419,18 @@ matching the currently active region." (progn (mc/remove-fake-cursors) (goto-char beg) - (while (search-forward search end t) - (push-mark (match-beginning 0)) - (mc/create-fake-cursor-at-point)) - (let ((first (mc/furthest-cursor-before-point))) - (if (not first) - (error "Search failed for %S" search) - (mc/pop-state-from-overlay first))) - (if (> (mc/num-cursors) 1) - (multiple-cursors-mode 1) - (mc/disable-multiple-cursors-mode)))))) + (let ((lastmatch)) + (while (search-forward search end t) + (push-mark (match-beginning 0)) + (mc/create-fake-cursor-at-point) + (setq lastmatch t)) + (unless lastmatch + (error "Search failed for %S" search))) + (goto-char (match-end 0)) + (if (< (mc/num-cursors) 3) + (mc/disable-multiple-cursors-mode) + (mc/pop-state-from-overlay (mc/furthest-cursor-before-point)) + (multiple-cursors-mode 1)))))) ;;;###autoload (defun mc/mark-all-in-region-regexp (beg end)