Fix search by process name when processes are filtered by user. Closes #2803481.

This commit is contained in:
Hisham Muhammad 2010-11-20 20:00:31 +00:00
parent d82e31be24
commit 0ff54ebac9
1 changed files with 4 additions and 5 deletions

9
htop.c
View File

@ -436,14 +436,14 @@ int main(int argc, char** argv) {
if (incSearchMode) { if (incSearchMode) {
doRefresh = false; doRefresh = false;
int size = Panel_size(panel);
if (ch == KEY_F(3)) { if (ch == KEY_F(3)) {
int here = Panel_getSelectedIndex(panel); int here = Panel_getSelectedIndex(panel);
int size = ProcessList_size(pl);
int i = here+1; int i = here+1;
while (i != here) { while (i != here) {
if (i == size) if (i == size)
i = 0; i = 0;
Process* p = ProcessList_get(pl, i); Process* p = (Process*) Panel_get(panel, i);
if (String_contains_i(p->comm, incSearchBuffer)) { if (String_contains_i(p->comm, incSearchBuffer)) {
Panel_setSelected(panel, i); Panel_setSelected(panel, i);
break; break;
@ -465,8 +465,8 @@ int main(int argc, char** argv) {
} }
bool found = false; bool found = false;
for (int i = 0; i < ProcessList_size(pl); i++) { for (int i = 0; i < size; i++) {
Process* p = ProcessList_get(pl, i); Process* p = (Process*) Panel_get(panel, i);
if (String_contains_i(p->comm, incSearchBuffer)) { if (String_contains_i(p->comm, incSearchBuffer)) {
Panel_setSelected(panel, i); Panel_setSelected(panel, i);
found = true; found = true;
@ -477,7 +477,6 @@ int main(int argc, char** argv) {
FunctionBar_draw(searchBar, incSearchBuffer); FunctionBar_draw(searchBar, incSearchBuffer);
else else
FunctionBar_drawAttr(searchBar, incSearchBuffer, CRT_colors[FAILED_SEARCH]); FunctionBar_drawAttr(searchBar, incSearchBuffer, CRT_colors[FAILED_SEARCH]);
continue; continue;
} }
if (isdigit((char)ch)) { if (isdigit((char)ch)) {