diff options
| author | Stefan Monnier | 2020-10-31 09:07:53 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2020-10-31 09:07:53 -0400 |
| commit | 7103192cd2b0434c7acf712d0b7cf5a2f7b19e75 (patch) | |
| tree | 14333414af14ff4035a27ec26f67ab177394ae01 /test/src | |
| parent | c3a20804a81826ec091a4a096c1987a61e412580 (diff) | |
| download | emacs-7103192cd2b0434c7acf712d0b7cf5a2f7b19e75.tar.gz emacs-7103192cd2b0434c7acf712d0b7cf5a2f7b19e75.zip | |
* src/xdisp.c (syms_of_xdisp) <"scroll-minibuffer-conservatively">: New var
Fix bug#44070, which causes the minibuffer display to jump upon minor edit
(redisplay_window): Obey it.
* lisp/simple.el (end-of-buffer): Obey it.
* test/src/xdisp-tests.el (xdisp-tests--in-minibuffer): New macro,
extracted from `xdisp-tests--minibuffer-resizing`.
(xdisp-tests--minibuffer-resizing): Use it.
(xdisp-tests--minibuffer-scroll): New test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/xdisp-tests.el | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el index 95c39dacc3e..fad90fad531 100644 --- a/test/src/xdisp-tests.el +++ b/test/src/xdisp-tests.el | |||
| @@ -21,34 +21,55 @@ | |||
| 21 | 21 | ||
| 22 | (require 'ert) | 22 | (require 'ert) |
| 23 | 23 | ||
| 24 | (defmacro xdisp-tests--in-minibuffer (&rest body) | ||
| 25 | (declare (debug t) (indent 0)) | ||
| 26 | `(catch 'result | ||
| 27 | (minibuffer-with-setup-hook | ||
| 28 | (lambda () | ||
| 29 | (let ((redisplay-skip-initial-frame nil) | ||
| 30 | (executing-kbd-macro nil)) ;Don't skip redisplay | ||
| 31 | (throw 'result (progn . ,body)))) | ||
| 32 | (let ((executing-kbd-macro t)) ;Force real minibuffer in `read-string'. | ||
| 33 | (read-string "toto: "))))) | ||
| 34 | |||
| 24 | (ert-deftest xdisp-tests--minibuffer-resizing () ;; bug#43519 | 35 | (ert-deftest xdisp-tests--minibuffer-resizing () ;; bug#43519 |
| 25 | ;; FIXME: This test returns success when run in batch but | ||
| 26 | ;; it's only a lucky accident: it also returned success | ||
| 27 | ;; when bug#43519 was not fixed. | ||
| 28 | (should | 36 | (should |
| 29 | (equal | 37 | (equal |
| 30 | t | 38 | t |
| 31 | (catch 'result | 39 | (xdisp-tests--in-minibuffer |
| 32 | (minibuffer-with-setup-hook | 40 | (insert "hello") |
| 33 | (lambda () | 41 | (let ((ol (make-overlay (point) (point))) |
| 34 | (insert "hello") | 42 | (max-mini-window-height 1) |
| 35 | (let ((ol (make-overlay (point) (point))) | 43 | (text "askdjfhaklsjdfhlkasjdfhklasdhflkasdhflkajsdhflkashdfkljahsdlfkjahsdlfkjhasldkfhalskdjfhalskdfhlaksdhfklasdhflkasdhflkasdhflkajsdhklajsdgh")) |
| 36 | (redisplay-skip-initial-frame nil) | 44 | ;; (save-excursion (insert text)) |
| 37 | (max-mini-window-height 1) | 45 | ;; (sit-for 2) |
| 38 | (text "askdjfhaklsjdfhlkasjdfhklasdhflkasdhflkajsdhflkashdfkljahsdlfkjahsdlfkjhasldkfhalskdjfhalskdfhlaksdhfklasdhflkasdhflkasdhflkajsdhklajsdgh")) | 46 | ;; (delete-region (point) (point-max)) |
| 39 | ;; (save-excursion (insert text)) | 47 | (put-text-property 0 1 'cursor t text) |
| 40 | ;; (sit-for 2) | 48 | (overlay-put ol 'after-string text) |
| 41 | ;; (delete-region (point) (point-max)) | 49 | (redisplay 'force) |
| 42 | (put-text-property 0 1 'cursor t text) | 50 | ;; Make sure we do the see "hello" text. |
| 43 | (overlay-put ol 'after-string text) | 51 | (prog1 (equal (window-start) (point-min)) |
| 44 | (let ((executing-kbd-macro nil)) ;Don't skip redisplay | 52 | ;; (list (window-start) (window-end) (window-width)) |
| 45 | (redisplay 'force)) | 53 | (delete-overlay ol))))))) |
| 46 | (throw 'result | 54 | |
| 47 | ;; Make sure we do the see "hello" text. | 55 | (ert-deftest xdisp-tests--minibuffer-scroll () ;; bug#44070 |
| 48 | (prog1 (equal (window-start) (point-min)) | 56 | (let ((posns |
| 49 | ;; (list (window-start) (window-end) (window-width)) | 57 | (xdisp-tests--in-minibuffer |
| 50 | (delete-overlay ol))))) | 58 | (let ((max-mini-window-height 4)) |
| 51 | (let ((executing-kbd-macro t)) ;Force real minibuffer in `read-string'. | 59 | (dotimes (_ 80) (insert "\nhello")) |
| 52 | (read-string "toto: "))))))) | 60 | (beginning-of-buffer) |
| 61 | (redisplay 'force) | ||
| 62 | (end-of-buffer) | ||
| 63 | ;; A simple edit like removing the last `o' shouldn't cause | ||
| 64 | ;; the rest of the minibuffer's text to move. | ||
| 65 | (list | ||
| 66 | (progn (redisplay 'force) (window-start)) | ||
| 67 | (progn (delete-char -1) | ||
| 68 | (redisplay 'force) (window-start)) | ||
| 69 | (progn (goto-char (point-min)) (redisplay 'force) | ||
| 70 | (goto-char (point-max)) (redisplay 'force) | ||
| 71 | (window-start))))))) | ||
| 72 | (should (equal (nth 0 posns) (nth 1 posns))) | ||
| 73 | (should (equal (nth 1 posns) (nth 2 posns))))) | ||
| 53 | 74 | ||
| 54 | ;;; xdisp-tests.el ends here | 75 | ;;; xdisp-tests.el ends here |