diff options
| author | Jim Porter | 2024-11-07 10:08:33 -0800 |
|---|---|---|
| committer | Jim Porter | 2024-11-14 09:19:31 -0800 |
| commit | df288d2e4148e6e72f21752a510f98536e7705ac (patch) | |
| tree | 33b272e891ecababf896a7b0da46b640146ded8f /test/lisp/eshell | |
| parent | e30c83e166634e8cdfc9577b982deb7cc2619067 (diff) | |
| download | emacs-df288d2e4148e6e72f21752a510f98536e7705ac.tar.gz emacs-df288d2e4148e6e72f21752a510f98536e7705ac.zip | |
Don't clobber stickiness text properties when printing Eshell prompt
* lisp/eshell/em-prompt.el (eshell--append-text-property): New
function...
(eshell-emit-prompt): ... use it.
* test/lisp/eshell/em-prompt-tests.el
(em-prompt-test/field-properties/merge-stickiness): New test.
(em-prompt-test/field-properties, em-prompt-test/after-failure): Reorder
stickiness values (bug#74230).
Diffstat (limited to 'test/lisp/eshell')
| -rw-r--r-- | test/lisp/eshell/em-prompt-tests.el | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el index fbadade061f..1c6e8e02293 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el | |||
| @@ -57,8 +57,8 @@ | |||
| 57 | 'read-only t | 57 | 'read-only t |
| 58 | 'field 'prompt | 58 | 'field 'prompt |
| 59 | 'font-lock-face 'eshell-prompt | 59 | 'font-lock-face 'eshell-prompt |
| 60 | 'front-sticky '(read-only field font-lock-face) | 60 | 'front-sticky '(read-only font-lock-face field) |
| 61 | 'rear-nonsticky '(read-only field font-lock-face)))) | 61 | 'rear-nonsticky '(read-only font-lock-face field)))) |
| 62 | (should (equal last-input "echo hello\n")) | 62 | (should (equal last-input "echo hello\n")) |
| 63 | (should (equal-including-properties | 63 | (should (equal-including-properties |
| 64 | last-output | 64 | last-output |
| @@ -88,6 +88,33 @@ This tests the case when `eshell-highlight-prompt' is nil." | |||
| 88 | (apply #'propertize "hello\n" | 88 | (apply #'propertize "hello\n" |
| 89 | eshell-command-output-properties))))))) | 89 | eshell-command-output-properties))))))) |
| 90 | 90 | ||
| 91 | (ert-deftest em-prompt-test/field-properties/merge-stickiness () | ||
| 92 | "Check that stickiness properties are properly merged on Eshell prompts." | ||
| 93 | (let ((eshell-prompt-function | ||
| 94 | (lambda () | ||
| 95 | (concat (propertize (eshell/pwd) 'front-sticky '(front)) | ||
| 96 | (propertize "$ " 'rear-nonsticky '(rear)))))) | ||
| 97 | (with-temp-eshell | ||
| 98 | (eshell-insert-command "echo hello") | ||
| 99 | (let ((last-prompt (field-string (1- eshell-last-input-start)))) | ||
| 100 | (should (equal-including-properties | ||
| 101 | last-prompt | ||
| 102 | (concat | ||
| 103 | (propertize | ||
| 104 | (directory-file-name default-directory) | ||
| 105 | 'read-only t | ||
| 106 | 'field 'prompt | ||
| 107 | 'font-lock-face 'eshell-prompt | ||
| 108 | 'front-sticky '(front read-only font-lock-face field) | ||
| 109 | 'rear-nonsticky '(read-only font-lock-face field)) | ||
| 110 | (propertize | ||
| 111 | "$ " | ||
| 112 | 'read-only t | ||
| 113 | 'field 'prompt | ||
| 114 | 'font-lock-face 'eshell-prompt | ||
| 115 | 'front-sticky '(read-only font-lock-face field) | ||
| 116 | 'rear-nonsticky '(rear read-only font-lock-face field))))))))) | ||
| 117 | |||
| 91 | (ert-deftest em-prompt-test/after-failure () | 118 | (ert-deftest em-prompt-test/after-failure () |
| 92 | "Check that current prompt shows the exit code of the last failed command." | 119 | "Check that current prompt shows the exit code of the last failed command." |
| 93 | (with-temp-eshell | 120 | (with-temp-eshell |
| @@ -104,8 +131,8 @@ This tests the case when `eshell-highlight-prompt' is nil." | |||
| 104 | 'read-only t | 131 | 'read-only t |
| 105 | 'field 'prompt | 132 | 'field 'prompt |
| 106 | 'font-lock-face 'eshell-prompt | 133 | 'font-lock-face 'eshell-prompt |
| 107 | 'front-sticky '(read-only field font-lock-face) | 134 | 'front-sticky '(read-only font-lock-face field) |
| 108 | 'rear-nonsticky '(read-only field font-lock-face))))))) | 135 | 'rear-nonsticky '(read-only font-lock-face field))))))) |
| 109 | 136 | ||
| 110 | 137 | ||
| 111 | ;; Prompt navigation | 138 | ;; Prompt navigation |