Skip to content

Commit

Permalink
Reuse contextStartIndex variable
Browse files Browse the repository at this point in the history
Signed-off-by: Simeon Widdis <[email protected]>
  • Loading branch information
Swiddis committed Jan 29, 2025
1 parent 9000314 commit 6642475
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ private String getOffendingText(Token offendingToken) {
}

private String truncateQueryAtOffendingToken(String query, Token offendingToken) {
int contextStart = offendingToken.getStartIndex() - CONTEXT_TRUNCATION_THRESHOLD;
if (offendingToken.getStartIndex() - CONTEXT_TRUNCATION_THRESHOLD <= 3) {
int contextStartIndex = offendingToken.getStartIndex() - CONTEXT_TRUNCATION_THRESHOLD;
if (contextStartIndex < 3) { // The ellipses won't save us anything below the first 4 characters
return query.substring(0, offendingToken.getStopIndex() + 1);
}
return "..." + query.substring(contextStart, offendingToken.getStopIndex() + 1);
return "..." + query.substring(contextStartIndex, offendingToken.getStopIndex() + 1);
}

private String getDetails(Recognizer<?, ?> recognizer, String msg, RecognitionException e) {
Expand Down

0 comments on commit 6642475

Please sign in to comment.