Merge pull request #3453 from scampi/issue-3423

remove trailing whitespaces in missing spans
This commit is contained in:
Seiichi Uchida 2019-03-17 14:01:49 +09:00 committed by GitHub
commit ad6d89842a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -252,7 +252,12 @@ impl<'a> FmtVisitor<'a> {
// - if there isn't one already // - if there isn't one already
// - otherwise, only if the last line is a line comment // - otherwise, only if the last line is a line comment
if status.line_start <= snippet.len() { 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') => { Some('\n') | Some('\r') => {
if !subslice.trim_end().ends_with("*/") { if !subslice.trim_end().ends_with("*/") {
self.push_str("\n"); self.push_str("\n");

View File

@ -0,0 +1,5 @@
/* a nice comment with a trailing whitespace */
fn foo() {}
/* a nice comment with a trailing tab */
fn bar() {}

View File

@ -0,0 +1,5 @@
/* a nice comment with a trailing whitespace */
fn foo() {}
/* a nice comment with a trailing tab */
fn bar() {}