fix scrolling behavior when number of queried context lines is different from number of visible context lines
MODIFY
lib/project/results-view.js
lib/project/results-view.js
@@ -264,13 +264,22 @@ class ResultsView {
for (let j = 0; j < this.selectedMatchIndex; j++) {
const match = selectedResult.matches[j];
result += this.matchHeight;
- if (match.leadingContextLines) result += this.contextLineHeight * match.leadingContextLines.length;
- if (match.trailingContextLines) result += this.contextLineHeight * match.trailingContextLines.length;
+ if (match.leadingContextLines && this.model.getFindOptions().leadingContextLineCount) {
+ result += this.contextLineHeight * Math.min(
+ match.leadingContextLines.length, this.model.getFindOptions().leadingContextLineCount);
+ }
+ if (match.trailingContextLines && this.model.getFindOptions().trailingContextLineCount) {
+ result += this.contextLineHeight * Math.min(
+ match.trailingContextLines.length, this.model.getFindOptions().trailingContextLineCount);
+ }
}
if (selectedResult) {
const selectedMatch = selectedResult.matches[this.selectedMatchIndex];
- if (selectedMatch.leadingContextLines) result += this.contextLineHeight * selectedMatch.leadingContextLines.length;
+ if (selectedMatch.leadingContextLines && this.model.getFindOptions().leadingContextLineCount) {
+ result += this.contextLineHeight * Math.min(
+ selectedMatch.leadingContextLines.length, this.model.getFindOptions().leadingContextLineCount);
+ }
}
}
@@ -301,8 +310,14 @@ class ResultsView {
for (let j = 0; j < searchResult.matches.length; j++) {
const match = searchResult.matches[j];
bottom = top + this.matchHeight;
- if (match.leadingContextLines) bottom += this.contextLineHeight * match.leadingContextLines.length;
- if (match.trailingContextLines) bottom += this.contextLineHeight * match.trailingContextLines.length;
+ if (match.leadingContextLines && this.model.getFindOptions().leadingContextLineCount) {
+ bottom += this.contextLineHeight * Math.min(
+ match.leadingContextLines.length, this.model.getFindOptions().leadingContextLineCount);
+ }
+ if (match.trailingContextLines && this.model.getFindOptions().trailingContextLineCount) {
+ bottom += this.contextLineHeight * Math.min(
+ match.trailingContextLines.length, this.model.getFindOptions().trailingContextLineCount);
+ }
if (bottom > position) {
this.selectedResultIndex = i;

fix scrolling behavior when number of queried context lines is different from number of visible context lines