emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/idris-mode f52818775f 1/4: Ensure that Idris repl buffer w


From: ELPA Syncer
Subject: [nongnu] elpa/idris-mode f52818775f 1/4: Ensure that Idris repl buffer window point is moved to end
Date: Tue, 17 Jan 2023 06:59:21 -0500 (EST)

branch: elpa/idris-mode
commit f52818775f6cb1281ac157946a52101d27bc2e9c
Author: Marek L <nospam.keram@gmail.com>
Commit: Marek L <nospam.keram@gmail.com>

    Ensure that Idris repl buffer window point is moved to end
    
    together with the buffer point when repl prompt is inserted.
    
    Resolves:
    https://github.com/idris-hackers/idris-mode/issues/443
---
 idris-repl.el           |  5 +++--
 test/idris-repl-test.el | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
 test/idris-tests.el     |  1 +
 3 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/idris-repl.el b/idris-repl.el
index d2ab2600c3..a5511c5e34 100644
--- a/idris-repl.el
+++ b/idris-repl.el
@@ -127,8 +127,9 @@ If ALWAYS-INSERT is non-nil, always insert a prompt at the 
end of the buffer."
       (let ((inhibit-read-only t))
         (insert prompt)))
     (set-marker idris-input-start (point-max))
-    (goto-char idris-input-start)))
-
+    (goto-char idris-input-start)
+    (and (get-buffer-window)
+         (set-window-point (get-buffer-window) idris-input-start))))
 
 (defun idris-repl-update-prompt (new-prompt)
   "Update prompt string to NEW-PROMPT."
diff --git a/test/idris-repl-test.el b/test/idris-repl-test.el
new file mode 100644
index 0000000000..116f88f9a9
--- /dev/null
+++ b/test/idris-repl-test.el
@@ -0,0 +1,52 @@
+;;; idris-repl-test.el --- Tests for idris-repl
+
+(require 'ert)
+(require 'idris-repl)
+
+(ert-deftest idris-repl-buffer ()
+  ;; Useful while debugging
+  ;; (and (get-buffer idris-repl-buffer-name) (kill-buffer 
idris-repl-buffer-name))
+  (let ((idris-repl-prompt-style 'short))
+    (cl-flet ((idris-get-idris-version-stub () '((1 3 3))))
+      (advice-add 'idris-get-idris-version :override 
#'idris-get-idris-version-stub)
+
+      (unwind-protect
+          (let* ((buffer (idris-repl-buffer)))
+            (with-current-buffer buffer
+              (display-buffer buffer)
+
+              ;; Assert the short default prompt is present
+              (should (string-match-p "λΠ> "
+                                      (buffer-substring-no-properties 
(point-min) (point-max))))
+
+              (with-selected-window (get-buffer-window)
+                (should (eq (point) (point-max))))
+
+              (idris-repl-update-prompt "TTT")
+              (with-selected-window (get-buffer-window)
+                (should (eq (point) (point-max))))
+
+              ;; Assert the prompt did not change after update
+              (should (string-match-p "λΠ> "
+                                      (buffer-substring-no-properties 
(point-min) (point-max))))
+
+              ;; when Idris repl prompt style is not 'short
+              (let ((idris-repl-prompt-style 'long))
+                (idris-repl-update-prompt "FooBar")
+
+                (with-selected-window (get-buffer-window)
+                  (should (eq (point) (point-max))))
+
+                ;; Assert the prompt does change after update
+                (should (string-match-p "FooBar> "
+                                        (buffer-substring-no-properties 
(point-min) (point-max)))))
+
+              ;; Cleanup
+              (kill-buffer))
+            (advice-remove 'idris-get-idris-version 
#'idris-get-idris-version-stub)
+            (setq idris-prompt-string nil))))))
+
+;; https://github.com/idris-hackers/idris-mode/issues/443
+(provide 'idris-repl-test)
+
+;;; idris-repl-test.el ends here
diff --git a/test/idris-tests.el b/test/idris-tests.el
index ce243e8c13..f431e9a6d0 100644
--- a/test/idris-tests.el
+++ b/test/idris-tests.el
@@ -136,6 +136,7 @@
 
 (load "idris-commands-test")
 (load "idris-navigate-test")
+(load "idris-repl-test")
 (load "idris-xref-test")
 
 (provide 'idris-tests)



reply via email to

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