emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2407f810136 2/2: Restore prompt correctly when reconnecting in ER


From: F. Jason Park
Subject: master 2407f810136 2/2: Restore prompt correctly when reconnecting in ERC
Date: Sun, 26 Nov 2023 17:30:05 -0500 (EST)

branch: master
commit 2407f810136739da376ff0929b247a49dc196299
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>

    Restore prompt correctly when reconnecting in ERC
    
    * lisp/erc/erc.el (erc--initialize-markers): Commit 0d6c8d41ab7 "Use
    overlay instead of text prop to hide ERC's prompt" introduced a bug
    that caused the prompt to remain hidden upon reconnecting because the
    stashed overlay would get clobbered by ERC's major-mode setup.
    Binding its old value while unhiding fixes the issue.
    * test/lisp/erc/erc-tests.el (erc-hide-prompt): Don't permanently set
    the default value of `erc-hide-prompt'.
    * test/lisp/erc/resources/erc-scenarios-common.el
    (erc-scenarios-common--join-network-id): Add assertions for prompt
    hiding and unhiding on reconnect.  (Bug#51082)
---
 lisp/erc/erc.el                                 |  4 +++-
 test/lisp/erc/erc-tests.el                      |  4 +++-
 test/lisp/erc/resources/erc-scenarios-common.el | 23 +++++++++++++++++++----
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index a2f4562d333..616129bf780 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2394,7 +2394,9 @@ nil."
         (set-marker-insertion-type erc-insert-marker t)
         (cl-assert (= (field-end erc-insert-marker) erc-input-marker))
         (goto-char old-point)
-        (erc--unhide-prompt))
+        (let ((erc--hidden-prompt-overlay
+               (alist-get 'erc--hidden-prompt-overlay continued-session)))
+          (erc--unhide-prompt)))
     (cl-assert (not (get-text-property (point) 'erc-prompt)))
     ;; In the original version from `erc-open', the snippet that
     ;; handled these newline insertions appeared twice close in
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 0d6ddf12380..912a85ad5e0 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -155,7 +155,9 @@
   (set-process-query-on-exit-flag erc-server-process nil))
 
 (ert-deftest erc-hide-prompt ()
-  (let (erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook)
+  (let ((erc-hide-prompt erc-hide-prompt)
+        ;;
+        erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook)
 
     (with-current-buffer (get-buffer-create "ServNet")
       (erc-tests--send-prep)
diff --git a/test/lisp/erc/resources/erc-scenarios-common.el 
b/test/lisp/erc/resources/erc-scenarios-common.el
index 802ccaeedaa..311d8a82d72 100644
--- a/test/lisp/erc/resources/erc-scenarios-common.el
+++ b/test/lisp/erc/resources/erc-scenarios-common.el
@@ -654,10 +654,17 @@ Bug#48598: 28.0.50; buffer-naming collisions involving 
bouncers in ERC."
       (with-current-buffer erc-server-buffer-foo (erc-cmd-JOIN "#chan"))
       (with-current-buffer (erc-d-t-wait-for 5 (get-buffer "#chan"))
         (funcall expect 5 "vile thing")
-        (erc-cmd-QUIT "")))
+        (erc-cmd-QUIT "")
 
-    (erc-d-t-wait-for 2 "Foonet connection deceased"
-      (not (erc-server-process-alive erc-server-buffer-foo)))
+        (ert-info ("Prompt hidden in channel buffer upon quitting")
+          (erc-d-t-wait-for 10 (erc--prompt-hidden-p))
+          (should (overlays-in erc-insert-marker erc-input-marker)))))
+
+    (with-current-buffer erc-server-buffer-foo
+      (ert-info ("Prompt hidden after process dies in server buffer")
+        (erc-d-t-wait-for 2 (not (erc-server-process-alive)))
+        (erc-d-t-wait-for 10 (erc--prompt-hidden-p))
+        (should (overlays-in erc-insert-marker erc-input-marker))))
 
     (should (equal erc-autojoin-channels-alist
                    (if foo-id '((oofnet "#chan")) '((foonet "#chan")))))
@@ -706,6 +713,10 @@ Bug#48598: 28.0.50; buffer-naming collisions involving 
bouncers in ERC."
         (setq erc-server-process-foo erc-server-process)
         (erc-d-t-wait-for 2 (eq erc-network 'foonet))
         (should (string= (buffer-name) (if foo-id "oofnet" "foonet")))
+
+        (ert-info ("Prompt unhidden")
+          (should-not (erc--prompt-hidden-p))
+          (should-not (overlays-in erc-insert-marker erc-input-marker)))
         (funcall expect 5 "foonet")))
 
     (ert-info ("#chan@foonet is clean, no cross-contamination")
@@ -713,7 +724,11 @@ Bug#48598: 28.0.50; buffer-naming collisions involving 
bouncers in ERC."
         (erc-d-t-wait-for 3 (eq erc-server-process erc-server-process-foo))
         (funcall expect 3 "<bob>")
         (erc-d-t-absent-for 0.1 "<joe>")
-        (funcall expect 20 "not given me")))
+        (funcall expect 30 "not given me")
+
+        (ert-info ("Prompt unhidden")
+          (should-not (erc--prompt-hidden-p))
+          (should-not (overlays-in erc-insert-marker erc-input-marker)))))
 
     (ert-info ("All #chan@barnet output received")
       (with-current-buffer chan-buf-bar



reply via email to

[Prev in Thread] Current Thread [Next in Thread]