[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode ec3855f 188/486: Recognize runaway raw strings
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode ec3855f 188/486: Recognize runaway raw strings |
Date: |
Sat, 7 Aug 2021 09:25:16 -0400 (EDT) |
branch: elpa/rust-mode
commit ec3855f1c6895eb12f140a84f9dd98392c4566a8
Author: Micah Chalmer <micah@micahchalmer.net>
Commit: Micah Chalmer <micah@micahchalmer.net>
Recognize runaway raw strings
Recognize raw strings all the way to the end of the buffer if they are
not closed. This is not valid rust code, but the highlighting should
show the mistake.
This also eliminates glitchy behavior that can occur in this situation.
Emacs assumes that edits can't change syntax at positions before the
edit, and raw strings without this change violated this.
---
rust-mode-tests.el | 35 +++++++++++++++++++++++++++++++++++
rust-mode.el | 5 ++++-
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 5312f38..8f25f06 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1110,6 +1110,41 @@ this_is_not_a_string();)"
(should (equal nil (get-text-property 28 'face))) ;; Semicolon--should not
be part of the string
))
+(ert-deftest font-lock-runaway-raw-string ()
+ (rust-test-font-lock
+ "const Z = r#\"my raw string\";\n// oops this is still in the string"
+ '("const" font-lock-keyword-face
+ "Z" font-lock-type-face
+ "r#\"my raw string\";\n// oops this is still in the string"
font-lock-string-face))
+ )
+
+(ert-deftest font-lock-recognize-closing-raw-string ()
+ (with-temp-buffer
+ (rust-mode)
+ (insert "const foo = r##\"
+1...............................................50
+1...............................................50
+1...............................................50
+1...............195-->\"; let ...................50
+1...............................................50
+1...............................................50
+1...............................................50
+1...............................................50
+1...............................................50
+1......................500......................50
+\"#;
+")
+ (font-lock-fontify-buffer)
+ (goto-char 530)
+ (insert "#")
+ ;; We have now closed the raw string. Check that the whole string is
+ ;; recognized after the change
+ (font-lock-after-change-function (1- (point)) (point) 0)
+ (should (equal 'font-lock-string-face (get-text-property 195 'face))) ;;
The "let"
+ (should (equal 'font-lock-string-face (get-text-property 500 'face))) ;;
The "500"
+ (should (equal nil (get-text-property 531 'face))) ;; The second ";"
+ ))
+
;;; Documentation comments
(ert-deftest font-lock-doc-line-comment-parent ()
diff --git a/rust-mode.el b/rust-mode.el
index 9e20aa2..9899ad1 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -531,7 +531,10 @@
;; No "#"s - capture the ending quote (using a backref to group 3,
;; so that we can't match a quote if we had "#"s) as group 6
- (group (backref 3))))
+ (group (backref 3))
+
+ ;; If the raw string wasn't actually closed, go all the way to the end
+ string-end))
;; Character literal: match the beginning ' of a character literal
;; as group 7, and the ending one as group 8
- [nongnu] elpa/rust-mode 6d5b02e 153/486: Merge pull request #56 from pnkfelix/pr=fix-word-syntax, (continued)
- [nongnu] elpa/rust-mode 6d5b02e 153/486: Merge pull request #56 from pnkfelix/pr=fix-word-syntax, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 96f7f79 156/486: Fix free-variable warnings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8eb6029 165/486: handle case where blink-matching-paren-distance is nil, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3798c7e 167/486: fix quoting in two doc strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 78e8b08 163/486: Merge pull request #62 from MicahChalmer/a-couple-of-readme-fixes, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6e72f64 176/486: Fix bugs in raw strings and character literals, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5937589 169/486: set :safe on two defcustoms, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 102ad5f 181/486: Merge pull request #67 from tromey/fix-two-docstrings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 88ff62a 182/486: Remove unnecessary code with call to undefined function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c49bb12 184/486: Cache (regexp-opt rust-special-types 'symbols) in rust-is-lt-char-operator, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ec3855f 188/486: Recognize runaway raw strings,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 99c5571 190/486: Merge pull request #68 from tromey/fix-issue-53, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5f5a428 192/486: Merge pull request #88 from kw-udon/nested-comment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1ff1d75 193/486: Merge pull request #90 from Wilfred/fix_type_word_boundaries, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 30d1dac 198/486: Recognize compiler help and notes as "info" messages, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 61a35f6 202/486: Merge pull request #97 from syohex/update-url, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0cf2bc3 255/486: Merge pull request #157 from fmdkdd/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c2a0c13 269/486: Add info to enable rustfmt, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode cd09a54 280/486: Merge pull request #189 from froydnj/minor-cleanups, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 19e6f60 291/486: Merge pull request #199 from tromey/open-paren-in-column-0, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7f7b2ac 293/486: mention keybinding for rustfmt, ELPA Syncer, 2021/08/07