pesos / grofer

A system and resource monitoring tool written in Golang!
Apache License 2.0
352 stars 52 forks source link

[BUG] Selectoed process out of bounds in `grofer proc` #122

Open anihm136 opened 3 years ago

anihm136 commented 3 years ago

Describe the bug When the process list changes for any reason and is refreshed, if the number of processes in the refreshed list is less than the index of the currently selected process, the selection goes out of bounds and no process is selected

To Reproduce Steps to reproduce the behavior:

  1. grofer proc
  2. Scroll down to the last process
  3. Wait for a while (or kill a process if you're impatient)
  4. No process is selected

Expected behavior If the selection goes out of bounds, cursor should reset to the last element in the new list

Screenshots image Before termination of last process image After termination of last process

Desktop (please complete the following information):

Additional context Seems generally harmless for now, does not cause any crashes. Using any of the navigation keys from this state resets the selection to a valid position. However, this caused some issues on #112 for which a temporary fix has been made. Updating the selection using calcPos after every process refresh seems to fix the problem, but has not been tested for adverse behaviors or side effects