emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rust-mode cc2435b 359/486: Merge pull request #264 from jj


From: ELPA Syncer
Subject: [nongnu] elpa/rust-mode cc2435b 359/486: Merge pull request #264 from jjwest/master
Date: Sat, 7 Aug 2021 09:25:52 -0400 (EDT)

branch: elpa/rust-mode
commit cc2435b9e5899c0787929a62dc6e6dcdb982febc
Merge: 0d408d5 b861aa9
Author: Niko Matsakis <niko@alum.mit.edu>
Commit: GitHub <noreply@github.com>

    Merge pull request #264 from jjwest/master
    
    Fixed indent when ? operator is used in chained method calls
---
 rust-mode-tests.el | 24 ++++++++++++++++++++++++
 rust-mode.el       |  4 ++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index fd29d5d..3e6c67a 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1668,6 +1668,18 @@ fn main() {
 "
    )))
 
+(ert-deftest indent-method-chains-no-align-with-question-mark-operator ()
+  (let ((rust-indent-method-chain nil)) (test-indent
+   "
+fn main() {
+    let x = thing.do_it()
+        .aligned()
+        .more_alignment()?
+        .more_alignment();
+}
+"
+   )))
+
 (ert-deftest indent-method-chains-with-align ()
   (let ((rust-indent-method-chain t)) (test-indent
    "
@@ -1679,6 +1691,18 @@ fn main() {
 "
    )))
 
+(ert-deftest indent-method-chains-with-align-with-question-mark-operator ()
+  (let ((rust-indent-method-chain t)) (test-indent
+   "
+fn main() {
+    let x = thing.do_it()
+                 .aligned()
+                 .more_alignment()?
+                 .more_alignment();
+}
+"
+   )))
+
 (ert-deftest indent-method-chains-with-align-and-second-stmt ()
   (let ((rust-indent-method-chain t)) (test-indent
    "
diff --git a/rust-mode.el b/rust-mode.el
index 0c31b6c..908b892 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -320,7 +320,7 @@ buffer."
                 (- (current-column) rust-indent-offset)))))
         (cond
          ;; foo.bar(...)
-         ((rust-looking-back-str ")")
+         ((looking-back "[)?]" (1- (point)))
           (backward-list 1)
           (funcall skip-dot-identifier))
 
@@ -501,7 +501,7 @@ buffer."
                           ;; ..or if the previous line ends with any of these:
                           ;;     { ? : ( , ; [ }
                           ;; then we are at the beginning of an expression, so 
stay on the baseline...
-                          (looking-back "[(,:;?[{}]\\|[^|]|" (- (point) 2))
+                          (looking-back "[(,:;[{}]\\|[^|]|" (- (point) 2))
                           ;; or if the previous line is the end of an 
attribute, stay at the baseline...
                           (progn 
(rust-rewind-to-beginning-of-current-level-expr) (looking-at "#")))))
                       baseline



reply via email to

[Prev in Thread] Current Thread [Next in Thread]