From 97d9e6b37395625a19051a4d9c0c3d47f9437ded Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Tue, 5 Sep 2017 16:51:54 +0900 Subject: [PATCH] Use the last line's width for indent width in rewriting missed span to fix unindented comments --- src/missed_spans.rs | 5 +++-- tests/source/comment.rs | 1 - tests/source/comment4.rs | 1 - tests/target/comment.rs | 5 ++--- tests/target/comment4.rs | 5 ++--- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/missed_spans.rs b/src/missed_spans.rs index 301e1583029..5e350cf41b4 100644 --- a/src/missed_spans.rs +++ b/src/missed_spans.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use Shape; +use {Indent, Shape}; use comment::{rewrite_comment, CodeCharKind, CommentCodeSlices}; use config::WriteMode; use syntax::codemap::{BytePos, Pos, Span}; @@ -169,11 +169,12 @@ fn replace_chars(string: &str) -> String { self.config.comment_width(), self.config.max_width() - self.block_indent.width(), ); + let comment_indent = Indent::from_width(self.config, self.buffer.cur_offset()); self.buffer.push_str(&rewrite_comment( subslice, false, - Shape::legacy(comment_width, self.block_indent), + Shape::legacy(comment_width, comment_indent), self.config, ).unwrap()); diff --git a/tests/source/comment.rs b/tests/source/comment.rs index 61d7fc454aa..e8ddaf959a6 100644 --- a/tests/source/comment.rs +++ b/tests/source/comment.rs @@ -9,7 +9,6 @@ fn test() { // comment // comment2 - // FIXME(1275) code(); /* leave this comment alone! * ok? */ diff --git a/tests/source/comment4.rs b/tests/source/comment4.rs index 0ae5cf4c3f6..ff1445378d7 100644 --- a/tests/source/comment4.rs +++ b/tests/source/comment4.rs @@ -5,7 +5,6 @@ fn test() { // comment // comment2 - // FIXME(1275) code(); /* leave this comment alone! * ok? */ diff --git a/tests/target/comment.rs b/tests/target/comment.rs index 168fb28edb9..f6de70a16ad 100644 --- a/tests/target/comment.rs +++ b/tests/target/comment.rs @@ -9,9 +9,8 @@ fn test() { // comment // comment2 - // FIXME(1275) code(); // leave this comment alone! - // ok? + // ok? // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a // diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam @@ -33,7 +32,7 @@ fn test() { // .unwrap()); funk(); // dontchangeme - // or me + // or me // #1388 const EXCEPTION_PATHS: &'static [&'static str] = &[ diff --git a/tests/target/comment4.rs b/tests/target/comment4.rs index 2916f083ca0..e07abf74a81 100644 --- a/tests/target/comment4.rs +++ b/tests/target/comment4.rs @@ -5,9 +5,8 @@ fn test() { // comment // comment2 - // FIXME(1275) code(); /* leave this comment alone! - * ok? */ + * ok? */ /* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a * diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam @@ -28,7 +27,7 @@ fn test() { // .unwrap()); funk(); //dontchangeme - // or me + // or me } /// test123 -- 2.44.0