From e452995b8ccd388f4be13a11443cffe3cdcd0619 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Tue, 2 Aug 2016 22:29:40 -0400 Subject: rust--after-revert-hook should preserve point position. Otherwise, rust-format-buffer always moves point to the end of the buffer. --- rust-mode-tests.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'rust-mode-tests.el') diff --git a/rust-mode-tests.el b/rust-mode-tests.el index 1e60768..3c3ba03 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -2561,6 +2561,18 @@ Fontification needs to include this whole string or none of it. ) ) +(ert-deftest rust-test-revert-hook-preserves-point () + (with-temp-buffer + ;; Insert some code, and put point in the middle. + (insert "fn foo() {}\n") + (insert "fn bar() {}\n") + (insert "fn baz() {}\n") + (goto-char (point-min)) + (forward-line 1) + (let ((initial-point (point))) + (rust--after-revert-hook) + (should (equal initial-point (point)))))) + ;; If electric-pair-mode is available, load it and run the tests that use it. If not, ;; no error--the tests will be skipped. (require 'elec-pair nil t) -- cgit v1.2.3