Restore prompt correctly when reconnecting in ERC

* lisp/erc/erc.el (erc--initialize-markers): Commit 0d6c8d41ab "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)
This commit is contained in:
F. Jason Park 2023-11-25 19:23:55 -08:00
parent 01e7178917
commit 2407f81013
3 changed files with 25 additions and 6 deletions

View file

@ -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

View file

@ -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)

View file

@ -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