[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode e452995 261/486: rust--after-revert-hook should
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode e452995 261/486: rust--after-revert-hook should preserve point position. |
Date: |
Sat, 7 Aug 2021 09:25:32 -0400 (EDT) |
branch: elpa/rust-mode
commit e452995b8ccd388f4be13a11443cffe3cdcd0619
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Wilfred Hughes <me@wilfred.me.uk>
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 ++++++++++++
rust-mode.el | 7 ++++---
2 files changed, 16 insertions(+), 3 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)
diff --git a/rust-mode.el b/rust-mode.el
index 6259b48..1fbc3e8 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1365,9 +1365,10 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
;; to use `font-lock-ensure', which doesn't exist in Emacs 24 and earlier.
;; If it's not available, fall back to calling `font-lock-fontify-region'
;; on the whole buffer.
- (if (fboundp 'font-lock-ensure)
- (font-lock-ensure)
- (font-lock-fontify-region (point-min) (point-max))))
+ (save-excursion
+ (if (fboundp 'font-lock-ensure)
+ (font-lock-ensure)
+ (font-lock-fontify-region (point-min) (point-max)))))
(defun rust--before-save-hook ()
(when rust-format-on-save (rust-format-buffer)))
- [nongnu] elpa/rust-mode ed0b390 246/486: Merge pull request #148 from bmastenbrook/master, (continued)
- [nongnu] elpa/rust-mode ed0b390 246/486: Merge pull request #148 from bmastenbrook/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b971c6d 247/486: Fix #151, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode abadab0 009/486: Update rust-mode.el with new keywords., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6275e8e 010/486: Add trait to emacs keyword table., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9f21b28 024/486: change to 4-space indents everywhere, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f1b6007 174/486: Merge pull request #71 from birkenfeld/doc-comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 07943f0 178/486: Perform syntactic angle bracket matching, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 54e24e6 200/486: Add basic license information, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e3c545e 252/486: imenu: don't add item defs in single-line comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6886300 256/486: [master] Copy buffer only when format changes., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e452995 261/486: rust--after-revert-hook should preserve point position.,
ELPA Syncer <=
- [nongnu] elpa/rust-mode d2e57a9 263/486: fix regex to account for `[E123]`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bec3d0c 267/486: Test #169, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7fb78d4 273/486: Bump version, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f6cf013 275/486: Add instructions for version tag update requests, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4935090 279/486: convert http links into https links, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b8126e4 284/486: Recognize "extern" imenu items, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a436945 294/486: Merge pull request #172 from nokaa/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 954221f 316/486: Define `rust-test-project-located' conditionally instead of using `skip-unless'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1d4a75f 324/486: Make rust-beginning-of-defun ignore comments and strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode dea81aa 334/486: Types get correct font-lock in if-let statements, ELPA Syncer, 2021/08/07