File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -2427,6 +2427,29 @@ Fontification needs to include this whole string or none of it.
2427
2427
(should (<= font-lock-beg 1 ))
2428
2428
(should (>= font-lock-end 12 )))))
2429
2429
2430
+ (ert-deftest redo-syntax-after-change-far-from-point ()
2431
+ (let*
2432
+ ((tmp-file-name (make-temp-file " rust-mdoe-test-issue104" ))
2433
+ (base-contents (apply 'concat (append '(" fn foo() {\n\n }\n " ) (make-list 500 " // More stuff...\n " ) '(" fn bar() {\n\n }\n " )))))
2434
+ ; ; Create the temp file...
2435
+ (with-temp-file tmp-file-name
2436
+ (insert base-contents))
2437
+ (with-temp-buffer
2438
+ (insert-file-contents tmp-file-name 'VISIT nil nil 'REPLACE )
2439
+ (rust-mode )
2440
+ (goto-char (point-max ))
2441
+ (should (= 0 (rust-paren-level)))
2442
+ (with-temp-file tmp-file-name
2443
+ (insert base-contents)
2444
+ (goto-char 12 ) ; ; On the blank line in the middle of fn foo
2445
+ (insert " let z = 1 < 3;" )
2446
+ )
2447
+ (revert-buffer 'IGNORE-AUTO 'NOCONFIRM 'PRESERVE-MODES )
2448
+ (should (= 0 (rust-paren-level)))
2449
+ )
2450
+ )
2451
+ )
2452
+
2430
2453
; ; If electric-pair-mode is available, load it and run the tests that use it. If not,
2431
2454
; ; no error--the tests will be skipped.
2432
2455
(require 'elec-pair nil t )
Original file line number Diff line number Diff line change @@ -1229,7 +1229,9 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
1229
1229
(setq-local beginning-of-defun-function 'rust-beginning-of-defun )
1230
1230
(setq-local end-of-defun-function 'rust-end-of-defun )
1231
1231
(setq-local parse-sexp-lookup-properties t )
1232
- (setq-local electric-pair-inhibit-predicate 'rust-electric-pair-inhibit-predicate-wrap ))
1232
+ (setq-local electric-pair-inhibit-predicate 'rust-electric-pair-inhibit-predicate-wrap )
1233
+ (add-hook 'after-revert-hook 'rust--after-revert-hook 'LOCAL )
1234
+ )
1233
1235
1234
1236
;;;### autoload
1235
1237
(add-to-list 'auto-mode-alist '(" \\ .rs\\ '" . rust-mode))
@@ -1240,6 +1242,17 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
1240
1242
(require 'rust-mode )
1241
1243
(rust-mode ))
1242
1244
1245
+ ; ; Issue #104: When reverting the buffer, make sure all fontification is redone
1246
+ ; ; so that we don't end up missing a non-angle-bracket '<' or '>' character.
1247
+ (defun rust--after-revert-hook ()
1248
+ (let
1249
+ ; ; Newer emacs versions (25 and later) make `font-lock-fontify-buffer'
1250
+ ; ; interactive-only, and want lisp code to call `font-lock-flush' or
1251
+ ; ; `font-lock-ensure' . But those don't exist in emacs 24 and earlier.
1252
+ ((font-lock-ensure-fn (if (fboundp 'font-lock-ensure ) 'font-lock-ensure 'font-lock-fontify-buffer )))
1253
+ (funcall font-lock-ensure-fn))
1254
+ )
1255
+
1243
1256
; ; Issue #6887: Rather than inheriting the 'gnu compilation error
1244
1257
; ; regexp (which is broken on a few edge cases), add our own 'rust
1245
1258
; ; compilation error regexp and use it instead.
You can’t perform that action at this time.
0 commit comments