A SubstitutionPart is not a deletion if it replaces nothing with nothing
This commit is contained in:
parent
52e003a6e9
commit
370c816a71
21 changed files with 130 additions and 198 deletions
|
@ -1704,7 +1704,7 @@ impl EmitterWriter {
|
|||
{
|
||||
notice_capitalization |= only_capitalization;
|
||||
|
||||
let has_deletion = parts.iter().any(|p| p.is_deletion());
|
||||
let has_deletion = parts.iter().any(|p| p.is_deletion(sm));
|
||||
let is_multiline = complete.lines().count() > 1;
|
||||
|
||||
if let Some(span) = span.primary_span() {
|
||||
|
|
|
@ -150,21 +150,20 @@ pub struct SubstitutionHighlight {
|
|||
|
||||
impl SubstitutionPart {
|
||||
pub fn is_addition(&self, sm: &SourceMap) -> bool {
|
||||
!self.snippet.is_empty()
|
||||
&& sm
|
||||
.span_to_snippet(self.span)
|
||||
.map_or(self.span.is_empty(), |snippet| snippet.trim().is_empty())
|
||||
!self.snippet.is_empty() && !self.replaces_meaningful_content(sm)
|
||||
}
|
||||
|
||||
pub fn is_deletion(&self) -> bool {
|
||||
self.snippet.trim().is_empty()
|
||||
pub fn is_deletion(&self, sm: &SourceMap) -> bool {
|
||||
self.snippet.trim().is_empty() && self.replaces_meaningful_content(sm)
|
||||
}
|
||||
|
||||
pub fn is_replacement(&self, sm: &SourceMap) -> bool {
|
||||
!self.snippet.is_empty()
|
||||
&& sm
|
||||
.span_to_snippet(self.span)
|
||||
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty())
|
||||
!self.snippet.is_empty() && self.replaces_meaningful_content(sm)
|
||||
}
|
||||
|
||||
fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool {
|
||||
sm.span_to_snippet(self.span)
|
||||
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue