New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep whole lines for code highlighting in search #1871
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just small remarks
int c = index; | ||
while (c > 0) { | ||
c--; | ||
if (content.charAt(c) == '\n') { | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use public int lastIndexOf(int ch, int fromIndex)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is not possible here to use lastIndexOf, because we need not the next line ending from the position. We need the previous (c--
vs c++
).
scm-webapp/src/main/java/sonia/scm/search/LuceneHighlighter.java
Outdated
Show resolved
Hide resolved
scm-webapp/src/main/java/sonia/scm/search/LuceneHighlighter.java
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
Proposed changes
We now use SimpleSpanFragmenter with a fragment size of 200 for each highlighted field. For code fields we ensure that each line is complete.
Your checklist for this pull request
Contributor:
gradle/changelog
or CHANGELOG.md is updated for pluginsReviewer:
Checklist for branch merge request (not required for forks)