summaryrefslogtreecommitdiff
path: root/rust-mode-tests.el
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2016-08-02 22:29:40 -0400
committerWilfred Hughes <me@wilfred.me.uk>2016-08-02 22:29:40 -0400
commite452995b8ccd388f4be13a11443cffe3cdcd0619 (patch)
tree0ce35c985d9fcd6b64d9271e76b893a1fe55f934 /rust-mode-tests.el
parentba5ff9058546df593ff7d8737fb52b5e92ad1913 (diff)
downloadrust-mode-e452995b8ccd388f4be13a11443cffe3cdcd0619.tar.gz
rust--after-revert-hook should preserve point position.
Otherwise, rust-format-buffer always moves point to the end of the buffer.
Diffstat (limited to 'rust-mode-tests.el')
-rw-r--r--rust-mode-tests.el12
1 files changed, 12 insertions, 0 deletions
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)