Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Nov 20, 2022
1 parent bcf76bd commit bdb60ee
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ public static SuggestedFix deleteWithTrailingWhitespace(Tree tree, VisitorState
return SuggestedFix.delete(tree);
}

int actualEnd = NON_WHITESPACE_MATCHER.indexIn(sourceCode, endPos);
return actualEnd == -1
? SuggestedFix.delete(tree)
: SuggestedFix.replace(((DiagnosticPosition) tree).getStartPosition(), actualEnd, "");
int whitespaceEndPos = NON_WHITESPACE_MATCHER.indexIn(sourceCode, endPos);
return SuggestedFix.replace(
((DiagnosticPosition) tree).getStartPosition(),
whitespaceEndPos == -1 ? sourceCode.length() : whitespaceEndPos,
"");
}
}

0 comments on commit bdb60ee

Please sign in to comment.