registered a focus listener
MODIFY
lib/project/results-view.js
lib/project/results-view.js
@@ -62,6 +62,7 @@ class ResultsView {
const resizeObserver = new ResizeObserver(this.invalidateItemHeights.bind(this));
resizeObserver.observe(this.element);
this.element.addEventListener('mousedown', this.handleClick.bind(this));
+ this.element.addEventListener('focus', this.maintainPreviousScrollPosition.bind(this));
this.subscriptions = new CompositeDisposable(
atom.config.observe('editor.fontFamily', this.fontFamilyChanged.bind(this)),
@@ -477,6 +478,7 @@ class ResultsView {
const selectedRow = this.selectedRow()
if (selectedRow instanceof MatchRow) {
+ this.currentScrollTop = this.getScrollTop();
const match = selectedRow.data.matches[0]
const editor = await atom.workspace.open(selectedRow.group.result.filePath, {
pending,
@@ -658,6 +660,15 @@ class ResultsView {
return this.refs.listView ? this.refs.listView.element.scrollHeight : 0;
}
+ maintainPreviousScrollPosition() {
+ if(this.selectedRowIndex === -1) {
+ return;
+ }
+ setTimeout(() => {
+ this.setScrollTop(this.currentScrollTop);
+ },100)
+ }
+
fontFamilyChanged(fontFamily) {
this.previewStyle = {fontFamily};
etch.update(this);

registered a focus listener