Properly handle removal suggestion rendering
Do not leave a `+ ` line with only whitespace. In reality, the user will want to remove the entire line.
This commit is contained in:
@@ -2273,9 +2273,26 @@ impl HumanEmitter {
|
|||||||
&normalize_whitespace(last_line),
|
&normalize_whitespace(last_line),
|
||||||
Style::NoStyle,
|
Style::NoStyle,
|
||||||
);
|
);
|
||||||
|
if !line_to_add.trim().is_empty() {
|
||||||
|
// Check if after the removal, the line is left with only whitespace. If so, we
|
||||||
|
// will not show an "addition" line, as removing the whole line is what the user
|
||||||
|
// would really want.
|
||||||
|
// For example, for the following:
|
||||||
|
// |
|
||||||
|
// 2 - .await
|
||||||
|
// 2 + (note the left over whitepsace)
|
||||||
|
// |
|
||||||
|
// We really want
|
||||||
|
// |
|
||||||
|
// 2 - .await
|
||||||
|
// |
|
||||||
|
// *row_num -= 1;
|
||||||
buffer.puts(*row_num, 0, &self.maybe_anonymized(line_num), Style::LineNumber);
|
buffer.puts(*row_num, 0, &self.maybe_anonymized(line_num), Style::LineNumber);
|
||||||
buffer.puts(*row_num, max_line_num_len + 1, "+ ", Style::Addition);
|
buffer.puts(*row_num, max_line_num_len + 1, "+ ", Style::Addition);
|
||||||
buffer.append(*row_num, &normalize_whitespace(line_to_add), Style::NoStyle);
|
buffer.append(*row_num, &normalize_whitespace(line_to_add), Style::NoStyle);
|
||||||
|
} else {
|
||||||
|
*row_num -= 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
*row_num -= 2;
|
*row_num -= 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ LL | dbg!();
|
|||||||
help: remove the invocation before committing it to a version control system
|
help: remove the invocation before committing it to a version control system
|
||||||
|
|
|
|
||||||
LL - dbg!();
|
LL - dbg!();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `dbg!` macro is intended as a debugging tool
|
error: the `dbg!` macro is intended as a debugging tool
|
||||||
@@ -146,7 +145,6 @@ LL | expand_to_dbg!();
|
|||||||
help: remove the invocation before committing it to a version control system
|
help: remove the invocation before committing it to a version control system
|
||||||
|
|
|
|
||||||
LL - dbg!();
|
LL - dbg!();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `dbg!` macro is intended as a debugging tool
|
error: the `dbg!` macro is intended as a debugging tool
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ LL | dbg!();
|
|||||||
help: remove the invocation before committing it to a version control system
|
help: remove the invocation before committing it to a version control system
|
||||||
|
|
|
|
||||||
LL - dbg!();
|
LL - dbg!();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `dbg!` macro is intended as a debugging tool
|
error: the `dbg!` macro is intended as a debugging tool
|
||||||
|
|||||||
@@ -96,12 +96,10 @@ LL | let (l, r) = "a.b.c".split_once('.').unwrap();
|
|||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let l = iter.next().unwrap();
|
LL - let l = iter.next().unwrap();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let r = iter.next().unwrap();
|
LL - let r = iter.next().unwrap();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: manual implementation of `split_once`
|
error: manual implementation of `split_once`
|
||||||
@@ -121,12 +119,10 @@ LL | let (l, r) = "a.b.c".split_once('.')?;
|
|||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let l = iter.next()?;
|
LL - let l = iter.next()?;
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let r = iter.next()?;
|
LL - let r = iter.next()?;
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: manual implementation of `rsplit_once`
|
error: manual implementation of `rsplit_once`
|
||||||
@@ -146,12 +142,10 @@ LL | let (l, r) = "a.b.c".rsplit_once('.').unwrap();
|
|||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let r = iter.next().unwrap();
|
LL - let r = iter.next().unwrap();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let l = iter.next().unwrap();
|
LL - let l = iter.next().unwrap();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: manual implementation of `rsplit_once`
|
error: manual implementation of `rsplit_once`
|
||||||
@@ -171,12 +165,10 @@ LL | let (l, r) = "a.b.c".rsplit_once('.')?;
|
|||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let r = iter.next()?;
|
LL - let r = iter.next()?;
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let l = iter.next()?;
|
LL - let l = iter.next()?;
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: manual implementation of `split_once`
|
error: manual implementation of `split_once`
|
||||||
@@ -202,12 +194,10 @@ LL | let (a, b) = "a.b.c".split_once('.').unwrap();
|
|||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let a = iter.next().unwrap();
|
LL - let a = iter.next().unwrap();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
help: remove the `iter` usages
|
help: remove the `iter` usages
|
||||||
|
|
|
|
||||||
LL - let b = iter.next().unwrap();
|
LL - let b = iter.next().unwrap();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: aborting due to 19 previous errors
|
error: aborting due to 19 previous errors
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ LL + let rslt0 = mutex.lock().unwrap().abs();
|
|||||||
help: remove separated single usage
|
help: remove separated single usage
|
||||||
|
|
|
|
||||||
LL - let rslt0 = lock.abs();
|
LL - let rslt0 = lock.abs();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: temporary with significant `Drop` can be early dropped
|
error: temporary with significant `Drop` can be early dropped
|
||||||
@@ -88,7 +87,6 @@ LL + mutex.lock().unwrap().clear();
|
|||||||
help: remove separated single usage
|
help: remove separated single usage
|
||||||
|
|
|
|
||||||
LL - lock.clear();
|
LL - lock.clear();
|
||||||
LL +
|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|||||||
Reference in New Issue
Block a user