Fix bug that occured when navigating results with context lines on
MODIFY
lib/project/result-row.js
lib/project/result-row.js
@@ -3,6 +3,8 @@ const {Range} = require('atom');
class LeadingContextRow {
constructor(rowGroup, line, separator, matchLineNumber, rowOffset) {
this.group = rowGroup
+ this.rowOffset = rowOffset
+ // props
this.data = {
separator,
line,
@@ -15,6 +17,8 @@ class LeadingContextRow {
class TrailingContextRow {
constructor(rowGroup, line, separator, matchLineNumber, rowOffset) {
this.group = rowGroup
+ this.rowOffset = rowOffset
+ // props
this.data = {
separator,
line,
@@ -27,6 +31,7 @@ class TrailingContextRow {
class ResultPathRow {
constructor(rowGroup) {
this.group = rowGroup
+ // props
this.data = {
separator: false,
}
@@ -36,6 +41,7 @@ class ResultPathRow {
class MatchRow {
constructor(rowGroup, separator, lineNumber, matches) {
this.group = rowGroup
+ // props
this.data = {
separator,
lineNumber,

MODIFY
lib/project/results-view.js
lib/project/results-view.js
@@ -333,9 +333,9 @@ class ResultsView {
const resultRow = this.resultRows[this.selectedRowIndex]
if (resultRow instanceof LeadingContextRow) {
- this.selectedRowIndex += resultRow.dy
+ this.selectedRowIndex += resultRow.rowOffset
} else if (resultRow instanceof TrailingContextRow) {
- this.selectedRowIndex -= resultRow.dy
+ this.selectedRowIndex -= resultRow.rowOffset
}
if (i >= this.resultRows.length) {
@@ -443,6 +443,13 @@ class ResultsView {
const groupIndex = this.resultRowGroups.indexOf(rowGroup)
const rowIndex = this.getRowCountBefore(groupIndex)
+ if (!rowGroup.data.isCollapsed) {
+ if (this.selectedRowIndex === rowIndex) {
+ this.selectRow(rowIndex + 1)
+ }
+ return
+ }
+
rowGroup.data.isCollapsed = false
this.invalidateRowGroup(rowIndex, groupIndex)
this.selectRow(rowIndex + 1)
@@ -455,6 +462,11 @@ class ResultsView {
}
const rowGroup = this.selectedRow().group
+
+ if (rowGroup.data.isCollapsed) {
+ return
+ }
+
const groupIndex = this.resultRowGroups.indexOf(rowGroup)
const rowIndex = this.getRowCountBefore(groupIndex)

Fix bug that occured when navigating results with context lines on