summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPip Cet <pipcet@protonmail.com>2026-05-24 12:05:50 +0000
committerPip Cet <pipcet@protonmail.com>2026-05-24 12:32:28 +0000
commitb72dcebdabfc3b7b28c9542633bd48b43bcc6365 (patch)
treec690a27d99ea966a1b3f1721caeea37919f74c5e /test
parent7f8ac8bf6f04045a676543862098c47bbf732f9e (diff)
Avoid crash in self-insert-command with non-ASCII auto-fill
* src/cmds.c (internal_self_insert): If the autofill function changed the newline character we inserted, don't attempt to restore point. * test/src/cmds-tests.el (self-insert-nonascii-autofill): New.
Diffstat (limited to 'test')
-rw-r--r--test/src/cmds-tests.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/src/cmds-tests.el b/test/src/cmds-tests.el
index 8c0e4706e3c..2038c01942f 100644
--- a/test/src/cmds-tests.el
+++ b/test/src/cmds-tests.el
@@ -48,5 +48,22 @@
(self-insert-command 0 10)
(should-not (equal pt 0)))))
+(ert-deftest self-insert-nonascii-autofill ()
+ "Test `self-insert-command' with a non-ASCII autofill function."
+ (with-temp-buffer
+ (let ((auto-fill-function
+ (lambda ()
+ (delete-char 1)
+ (insert #x2000)
+ (forward-char -1))))
+ (dotimes (_ 10)
+ (self-insert-command 1 10)
+ (goto-char 2)
+ (should (equal (point) 2))
+ (should (equal (length (buffer-string)) 1))
+ (should (equal (format "%S" (buffer-string))
+ "\"\x2000\""))
+ (delete-char -1)))))
+
(provide 'cmds-tests)
;;; cmds-tests.el ends here