Enhancement: Preserve process selection after exiting search

This commit is contained in:
Berger Eugene 2024-03-23 02:34:56 +02:00
parent 86b48d97a1
commit 7aab5a5187
2 changed files with 22 additions and 11 deletions

View File

@ -249,7 +249,9 @@ func (pv *pcView) matchProcRegex(procName string) bool {
func (pv *pcView) resetProcessSearch() {
pv.setProcRegex(nil)
go pv.appView.QueueUpdateDraw(func() {
name := pv.getSelectedProcName()
pv.fillTableData()
pv.selectTableProcess(name)
})
}
@ -350,3 +352,23 @@ func (pv *pcView) getTableRowValues(state types.ProcessState) tableRowValues {
exitCode: getStrForExitCode(state),
}
}
func (pv *pcView) getSelectedProcName() string {
if pv.procTable == nil {
return ""
}
row, _ := pv.procTable.GetSelection()
if row > 0 {
return pv.procTable.GetCell(row, int(ProcessStateName)).Text
}
return ""
}
func (pv *pcView) selectTableProcess(name string) {
for i := 1; i < pv.procTable.GetRowCount(); i++ {
if pv.procTable.GetCell(i, int(ProcessStateName)).Text == name {
pv.procTable.Select(i, 1)
return
}
}
}

View File

@ -335,17 +335,6 @@ func (pv *pcView) handleConnectivityError() {
}
}
func (pv *pcView) getSelectedProcName() string {
if pv.procTable == nil {
return ""
}
row, _ := pv.procTable.GetSelection()
if row > 0 {
return pv.procTable.GetCell(row, int(ProcessStateName)).Text
}
return ""
}
func (pv *pcView) onProcRowSpanChange() {
if pv.scrSplitState == ProcFull && pv.logFollow {
pv.stopFollowLog()