Use underline suggestions for purely 'additive' replacements
This commit is contained in:
parent
6dfeab5c9e
commit
b480a9214a
110 changed files with 369 additions and 535 deletions
|
@ -230,6 +230,17 @@ impl SubstitutionPart {
|
|||
!self.snippet.is_empty() && self.replaces_meaningful_content(sm)
|
||||
}
|
||||
|
||||
/// Whether this is a replacement that overwrites source with a snippet
|
||||
/// in a way that isn't a superset of the original string. For example,
|
||||
/// replacing "abc" with "abcde" is not destructive, but replacing it
|
||||
/// it with "abx" is, since the "c" character is lost.
|
||||
pub fn is_destructive_replacement(&self, sm: &SourceMap) -> bool {
|
||||
self.is_replacement(sm)
|
||||
&& !sm
|
||||
.span_to_snippet(self.span)
|
||||
.is_ok_and(|snippet| self.snippet.trim_start().starts_with(snippet.trim_start()))
|
||||
}
|
||||
|
||||
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