From a416e1d6c111527205f3583c8d201bf95af6fa20 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 12 Dec 2016 18:03:40 +0200 Subject: Fix point motion in cloned buffers * src/thread.c (post_acquire_global_lock): Call set_buffer_internal_2 instead of tricking set_buffer_internal_1 into resetting the current buffer even if it didn't change. This avoids bug#25165, caused by failing to record the modified values of point and mark, because current_buffer was set to NULL. Also, don't bother re-setting the buffer if there was no thread switch, as that just wastes cycles. * src/buffer.c (set_buffer_internal_2): New function, with most of the body of set_buffer_internal_1, but without the test for B being identical to the current buffer. (set_buffer_internal_1): Call set_buffer_internal_2 if B is not identical to the current buffer. * src/buffer.h (set_buffer_internal_2): Add prototype. * test/src/thread-tests.el (thread-sticky-point): New test. --- test/src/thread-tests.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el index 4e7b052cba0..7261cda9fbb 100644 --- a/test/src/thread-tests.el +++ b/test/src/thread-tests.el @@ -221,8 +221,18 @@ :group 'widget-faces)) (ert-deftest thread-errors () - "Test what happens when a thread signals an error." + "Test what happens when a thread signals an error." (should (threadp (make-thread #'call-error "call-error"))) (should (threadp (make-thread #'thread-custom "thread-custom")))) +(ert-deftest thread-sticky-point () + "Test bug #25165 with point movement in cloned buffer." + (with-temp-buffer + (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") + (goto-char (point-min)) + (clone-indirect-buffer nil nil) + (forward-char 20) + (sit-for 1) + (should (= (point) 21)))) + ;;; threads.el ends here -- cgit v1.2.1