mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Avoid errors when a restricted-sexp widget is empty
* lisp/wid-edit.el (restricted-sexp): Don't try to read an empty string when converting the current value to the external format. (Bug#63838) * test/lisp/wid-edit-tests.el (widget-test-restricted-sexp-empty-val): New test.
This commit is contained in:
parent
68976b00f1
commit
2ea98ea35c
2 changed files with 14 additions and 1 deletions
|
|
@ -3681,7 +3681,9 @@ match-alternatives: %S"
|
|||
:warning)
|
||||
;; Make sure we will `read' a string.
|
||||
(setq value (prin1-to-string value)))
|
||||
(read value)))
|
||||
(if (string-empty-p value)
|
||||
value
|
||||
(read value))))
|
||||
|
||||
(defun widget-restricted-sexp-match (widget value)
|
||||
(let ((alternatives (widget-get widget :match-alternatives))
|
||||
|
|
|
|||
|
|
@ -380,4 +380,15 @@ return nil, even with a non-nil bubblep argument."
|
|||
:value (("1" . 1) ("2" . 2))))))
|
||||
(should (equal '(("1" . 1) ("2" . 2)) (widget-default-get w))))))
|
||||
|
||||
(ert-deftest widget-test-restricted-sexp-empty-val ()
|
||||
"Test that we handle an empty restricted-sexp widget just fine."
|
||||
(with-temp-buffer
|
||||
(let ((w (widget-create '(restricted-sexp
|
||||
:value 3
|
||||
:match-alternatives (integerp)))))
|
||||
(widget-setup)
|
||||
(widget-backward 1)
|
||||
(delete-char 1)
|
||||
(should (string= (widget-value w) "")))))
|
||||
|
||||
;;; wid-edit-tests.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue