From fba77143c009b7b11839c77259f3b1f7a9c88bb8 Mon Sep 17 00:00:00 2001 From: mrBliss Date: Sat, 22 Oct 2016 12:39:17 +0200 Subject: Handle comments when indenting method chains Previously, indentation went wrong when the comment on the line above looked like a method call/member access: fn main() { // Lorem ipsum lorem ipsum lorem ipsum lorem.ipsum foo.bar() } With this patch: fn main() { // Lorem ipsum lorem ipsum lorem ipsum lorem.ipsum foo.bar() } Also, a blank line or a comment broke method-chain indentation: fn main() { something.a.do_it // A comment .aligned .more_alignment(); } With this patch: fn main() { something.a.do_it // A comment .aligned .more_alignment(); } Note that comments interleaving a method chain are not aligned with the '.' of the method chain. --- rust-mode-tests.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'rust-mode-tests.el') diff --git a/rust-mode-tests.el b/rust-mode-tests.el index 35a1cbd..2585237 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -1599,6 +1599,19 @@ fn main() { " ))) +(ert-deftest indent-method-chains-look-over-comment () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + thing.a.do_it + // A comment + .aligned + // Another comment + .more_alignment(); +} +" + ))) + (ert-deftest indent-method-chains-comment () (let ((rust-indent-method-chain t)) (test-indent " @@ -1627,6 +1640,17 @@ fn main() { // comment here should not push next line out " ))) +(ert-deftest indent-method-chains-after-comment2 () + (let ((rust-indent-method-chain t)) (test-indent + " +fn main() { + // Lorem ipsum lorem ipsum lorem ipsum lorem.ipsum + foo.bar() +} +" + ))) + + (ert-deftest test-for-issue-36-syntax-corrupted-state () "This is a test for a issue #36, which involved emacs's internal state getting corrupted when actions were done in a -- cgit v1.2.3