1
Fork 0

Consider add-prefix replacements too

This commit is contained in:
Michael Goulet 2025-02-13 03:07:18 +00:00 committed by Jubilee Young
parent b480a9214a
commit f6406dfd4e
44 changed files with 222 additions and 330 deletions

View file

@ -236,9 +236,10 @@ impl SubstitutionPart {
/// 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()))
&& !sm.span_to_snippet(self.span).is_ok_and(|snippet| {
self.snippet.trim_start().starts_with(snippet.trim_start())
|| self.snippet.trim_end().ends_with(snippet.trim_end())
})
}
fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool {