Fix scrolling to selected match
MODIFY
lib/project/results-view.js
lib/project/results-view.js
@@ -404,20 +404,21 @@ class ResultsView {
const resultElement = this.element.children[this.selectedResultIndex];
if (!resultElement) return;
- let top = resultElement.offsetTop;
- let bottom = top + resultElement.offsetHeight;
-
- if (this.selectedMatchIndex !== -1) {
- const matchElement = resultElement.querySelectorAll('.search-result');
- top += matchElement.offsetTop;
- bottom = top + matchElement.offsetHeight;
+ let element;
+ if (this.selectedMatchIndex === -1) {
+ element = resultElement.querySelector('.path-details');
+ } else {
+ element = resultElement.querySelectorAll('.search-result')[this.selectedMatchIndex];
}
- if (bottom > this.element.scrollTop + this.element.scrollHeight) {
- this.element.scrollTop = bottom - this.element.scrollHeight;
+ const top = element.offsetTop;
+ const bottom = top + element.offsetHeight;
+
+ if (bottom > this.element.scrollTop + this.element.offsetHeight) {
+ this.element.scrollTop = bottom - this.element.offsetHeight;
}
- if (top < this.scrollTop) {
+ if (top < this.element.scrollTop) {
this.element.scrollTop = top;
}
}

Fix scrolling to selected match