Skip to content

Commit 06f1c68

Browse files
authored
Merge pull request #300 from mmilenko/rust-looking-back-macro--backward-char--fix
Avoid signaling "Beginning of buffer" in rust-looking-back-macro
2 parents 8cd18cc + 497d476 commit 06f1c68

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

rust-mode-tests.el

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,6 +2414,14 @@ fn main() {
24142414
"/* " font-lock-comment-delimiter-face
24152415
"no-op */" font-lock-comment-face)))
24162416

2417+
(ert-deftest font-lock-fontify-angle-brackets ()
2418+
"Test that angle bracket fontify"
2419+
(should (equal (rust-test-fontify-string "<>") "<>"))
2420+
(should (equal (rust-test-fontify-string "<foo>") "<foo>"))
2421+
(should (equal (rust-test-fontify-string "<<>>") "<<>>"))
2422+
(should (equal (rust-test-fontify-string "<>>") "<>>"))
2423+
(should (equal (rust-test-fontify-string "<<>") "<<>")))
2424+
24172425
(ert-deftest rust-test-basic-paren-matching ()
24182426
(rust-test-matching-parens
24192427
"

rust-mode.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ Like `looking-back' but for fixed strings rather than regexps (so that it's not
8080

8181
(defun rust-looking-back-macro ()
8282
"Non-nil if looking back at an ident followed by a !"
83-
(save-excursion (backward-char) (and (= ?! (char-after)) (rust-looking-back-ident))))
83+
(if (> (- (point) (point-min)) 1)
84+
(save-excursion (backward-char) (and (= ?! (char-after)) (rust-looking-back-ident)))))
8485

8586
;; Syntax definitions and helpers
8687
(defvar rust-mode-syntax-table
@@ -1604,7 +1605,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
16041605
(when rust-format-on-save
16051606
(unless (executable-find rust-rustfmt-bin)
16061607
(error "Could not locate executable \"%s\"" rust-rustfmt-bin))))
1607-
1608+
16081609
(defvar rustc-compilation-regexps
16091610
(let ((file "\\([^\n]+\\)")
16101611
(start-line "\\([0-9]+\\)")

0 commit comments

Comments
 (0)