Skip to content

Commit

Permalink
Compare common prefix/suffix len sum to both old and new tokens' len
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jan 14, 2025
1 parent 282045b commit c1edcfb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dylint/src/package_options/auto_correct/rewrite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dylint_internal::{
env,
git2::{Commit, Diff, DiffHunk, Oid, Patch, Repository},
};
use std::{collections::HashMap, ops::Range, time::Instant};
use std::{cmp::min, collections::HashMap, ops::Range, time::Instant};

mod diff;
use diff::{collect_commits, diff_from_commit, patches_from_diff};
Expand Down Expand Up @@ -88,7 +88,7 @@ impl Rewrite {
.zip(new_tokens.iter().rev())
.take_while(|(x, y)| x == y)
.count();
if common_prefix_len + common_suffix_len >= old_tokens.len() {
if common_prefix_len + common_suffix_len >= min(old_tokens.len(), new_tokens.len()) {
Ok(None)
} else {
Ok(Some(Self {
Expand Down

0 comments on commit c1edcfb

Please sign in to comment.