diff --git a/mistty.el b/mistty.el index 0fef436..85aa92c 100644 --- a/mistty.el +++ b/mistty.el @@ -2384,7 +2384,9 @@ This function fails if there is no current or previous output." (message "MisTTY: Canceling replay") (mistty--cancel-queue mistty--queue)) (mistty--ignore-foreign-overlays) - (mistty--inhibit-clear 'noschedule))) + (mistty--inhibit-clear 'noschedule) + (when mistty--forbid-edit + (mistty-send-key 1 "\C-g")))) (let ((point-moved (and mistty--old-point (/= (point) mistty--old-point)))) ;; Show cursor again if the command moved the point. diff --git a/test/mistty-test.el b/test/mistty-test.el index e840802..ed194da 100644 --- a/test/mistty-test.el +++ b/test/mistty-test.el @@ -2988,6 +2988,27 @@ (should (not mistty--forbid-edit)) (should (equal ":run" mode-line-process))))) +(ert-deftest mistty-test-exit-forbid-edit () + (let ((mistty-forbid-edit-regexps + '("^search: .*\n\\(►\\|(no matches)\\)"))) + (mistty-with-test-buffer (:shell fish) + (mistty-send-key 1 (kbd "C-r")) + (mistty-wait-for-output :str "search:" :start (point-min)) + (should mistty--forbid-edit) + + ;; C-g + (let ((this-command 'keyboard-quit)) + (mistty--pre-command) + (mistty--post-command)) + + (mistty-wait-for-output + :test (lambda () + (save-excursion + (goto-char (point-min)) + (not (search-forward "search:" nil t))))) + + (should (not mistty--forbid-edit))))) + (ert-deftest mistty-test-forbid-edit-map () (let ((mistty-forbid-edit-regexps '("^search: .*\n\\(►\\|(no matches)\\)")))