diff options
| author | Tony Zorman | 2023-06-03 14:23:19 +0200 |
|---|---|---|
| committer | Jim Porter | 2023-06-15 09:40:12 -0700 |
| commit | f2aae8b879baa4986b69af7ee54fe4eb987b99d6 (patch) | |
| tree | 86a96b1f93059937fa570485f09395ed2da57d88 /test | |
| parent | 1acce3b5c7fdf0b2a7301db25dfc2a616df36744 (diff) | |
| download | emacs-f2aae8b879baa4986b69af7ee54fe4eb987b99d6.tar.gz emacs-f2aae8b879baa4986b69af7ee54fe4eb987b99d6.zip | |
eshell-next-prompt: More precisely navigate to the prompt (bug#63748)
* lisp/eshell/em-prompt.el (eshell-next-prompt): Navigate to the
current prompt more accurately by using text properties instead of
going to the beginning of the line. This is important for multiline
prompts, as they don't necessarily start at the beginning of the
current line.
* test/lisp/eshell/em-prompt-tests.el
(em-prompt-test--with-multiline):
Execute a given body with a multiline prompt.
(em-prompt-test/next-previous-prompt-with):
(em-prompt-test/forward-backward-matching-input-with):
Helper functions for code reuse.
(em-prompt-test/forward-backward-matching-input):
(em-prompt-test/next-previous-prompt):
Rewrite in terms of the appropriate helper functions.
(em-prompt-test/next-previous-prompt-multiline):
(em-prompt-test/forward-backward-matching-input-multiline):
Add multiline variants of existing tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/eshell/em-prompt-tests.el | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el index 257549e40fb..93bf9d84ab3 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el | |||
| @@ -80,8 +80,13 @@ This tests the case when `eshell-highlight-prompt' is nil." | |||
| 80 | (apply #'propertize "hello\n" | 80 | (apply #'propertize "hello\n" |
| 81 | eshell-command-output-properties))))))) | 81 | eshell-command-output-properties))))))) |
| 82 | 82 | ||
| 83 | (ert-deftest em-prompt-test/next-previous-prompt () | 83 | (defmacro em-prompt-test--with-multiline (&rest body) |
| 84 | "Check that navigating forward/backward through old prompts works correctly." | 84 | "Execute BODY with a multiline Eshell prompt." |
| 85 | `(let ((eshell-prompt-function (lambda () "multiline prompt\n$ "))) | ||
| 86 | ,@body)) | ||
| 87 | |||
| 88 | (defun em-prompt-test/next-previous-prompt-with () | ||
| 89 | "Helper for checking forward/backward navigation of old prompts." | ||
| 85 | (with-temp-eshell | 90 | (with-temp-eshell |
| 86 | (eshell-insert-command "echo one") | 91 | (eshell-insert-command "echo one") |
| 87 | (eshell-insert-command "echo two") | 92 | (eshell-insert-command "echo two") |
| @@ -98,8 +103,17 @@ This tests the case when `eshell-highlight-prompt' is nil." | |||
| 98 | (eshell-next-prompt 3) | 103 | (eshell-next-prompt 3) |
| 99 | (should (equal (eshell-get-old-input) "echo fou")))) | 104 | (should (equal (eshell-get-old-input) "echo fou")))) |
| 100 | 105 | ||
| 101 | (ert-deftest em-prompt-test/forward-backward-matching-input () | 106 | (ert-deftest em-prompt-test/next-previous-prompt () |
| 102 | "Check that navigating forward/backward via regexps works correctly." | 107 | "Check that navigating forward/backward through old prompts works correctly." |
| 108 | (em-prompt-test/next-previous-prompt-with)) | ||
| 109 | |||
| 110 | (ert-deftest em-prompt-test/next-previous-prompt-multiline () | ||
| 111 | "Check old prompt forward/backward navigation for multiline prompts." | ||
| 112 | (em-prompt-test--with-multiline | ||
| 113 | (em-prompt-test/next-previous-prompt-with))) | ||
| 114 | |||
| 115 | (defun em-prompt-test/forward-backward-matching-input-with () | ||
| 116 | "Helper for checking forward/backward navigation via regexps." | ||
| 103 | (with-temp-eshell | 117 | (with-temp-eshell |
| 104 | (eshell-insert-command "echo one") | 118 | (eshell-insert-command "echo one") |
| 105 | (eshell-insert-command "printnl something else") | 119 | (eshell-insert-command "printnl something else") |
| @@ -117,4 +131,13 @@ This tests the case when `eshell-highlight-prompt' is nil." | |||
| 117 | (eshell-forward-matching-input "echo" 3) | 131 | (eshell-forward-matching-input "echo" 3) |
| 118 | (should (equal (eshell-get-old-input) "echo fou")))) | 132 | (should (equal (eshell-get-old-input) "echo fou")))) |
| 119 | 133 | ||
| 134 | (ert-deftest em-prompt-test/forward-backward-matching-input () | ||
| 135 | "Check that navigating forward/backward via regexps works correctly." | ||
| 136 | (em-prompt-test/forward-backward-matching-input-with)) | ||
| 137 | |||
| 138 | (ert-deftest em-prompt-test/forward-backward-matching-input-multiline () | ||
| 139 | "Check forward/backward regexp navigation for multiline prompts." | ||
| 140 | (em-prompt-test--with-multiline | ||
| 141 | (em-prompt-test/forward-backward-matching-input-with))) | ||
| 142 | |||
| 120 | ;;; em-prompt-tests.el ends here | 143 | ;;; em-prompt-tests.el ends here |