Skip to content

Commit

Permalink
fix #156 - supporting tabs on the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Una865 committed Jul 9, 2023
1 parent 516e49f commit 724e02f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public StringReplacementEvaluator(String old, String replacement) {

@Override
public String evaluate(String oldLibraryCode) {
String shiftedOld = this.old.replaceAll("(?m)^\\s+|(?m) +$", "");
String shiftedOldLibraryCode = oldLibraryCode.replaceAll("(?m)^\\s+|(?m) +$", "");
String shiftedOld = this.old.replaceAll("(?m)^\\s+|(?m)\\s+$", "");
String shiftedOldLibraryCode = oldLibraryCode.replaceAll("(?m)^\\s+|(?m)\\s+$", "");
String replaced = shiftedOldLibraryCode.replace(shiftedOld, this.replacement);

if (replaced.equals(shiftedOldLibraryCode)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static Stream<Arguments> withStringReplacementGenerator() {
"extra line 1\nextra line 2",
"line 1\nextra line 1\nextra line 2\nline 5"),
// different amounts of whitespaces on the end in library and old code
Arguments.of(" line 1 \n \t\t line 2 \nline 3\n\tline 4 \n\tline 5",
Arguments.of(" line 1 \n \t\t line 2\t \nline 3\n\tline 4\t\n\tline 5",
"\t line 2 \n\t\t \tline 3 \nline 4 ",
"extra line 1\nextra line 2",
"line 1\nextra line 1\nextra line 2\nline 5")
Expand Down

0 comments on commit 724e02f

Please sign in to comment.