Skip to content

Commit

Permalink
remove trailing whitespaces in missing spans
Browse files Browse the repository at this point in the history
  • Loading branch information
scampi committed Mar 16, 2019
1 parent 5f3dfe6 commit 2d5bc69
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/missed_spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ impl<'a> FmtVisitor<'a> {
// - if there isn't one already
// - otherwise, only if the last line is a line comment
if status.line_start <= snippet.len() {
match snippet[status.line_start..].chars().next() {
match snippet[status.line_start..]
.chars()
// skip trailing whitespaces
.skip_while(|c| *c == ' ' || *c == '\t')
.next()
{
Some('\n') | Some('\r') => {
if !subslice.trim_end().ends_with("*/") {
self.push_str("\n");
Expand Down
5 changes: 5 additions & 0 deletions tests/source/issue-3423.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* a nice comment with a trailing whitespace */
fn foo() {}

/* a nice comment with a trailing tab */
fn bar() {}
5 changes: 5 additions & 0 deletions tests/target/issue-3423.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* a nice comment with a trailing whitespace */
fn foo() {}

/* a nice comment with a trailing tab */
fn bar() {}

0 comments on commit 2d5bc69

Please sign in to comment.