lnav icon indicating copy to clipboard operation
lnav copied to clipboard

n/N to move between search results and not clusters

Open bagonyi opened this issue 2 years ago • 4 comments

I would like to re-request a feature I created a ticket for several years ago (https://github.com/tstack/lnav/issues/394).

Please make the n/N keys configurable in lnav, so that when pressing the keys to navigate between the next/previous search result it always take me to the next search hit, and not to the next cluster.

In the recording below, every time I press n it takes me to the next search cluster, instead of the next search hit.

lnav-cluster-search

I understand the use-case for skipping results close to each other; if one wants to quickly scan through a file where they are not interested in the results line-by-line, only cluster-by-cluster, not having to press n thousands of times to go through the entire log file is a big convenience.

However, my use case for analysing log files is different. I heavily rely on being able move between the search results line by line, as every single line contains information I need to look at. Currently, the only workaround I have, is to continuously monitor the hit counter, and whenever I press n the hit counter increases by more than 1, I have to press N to go back to the cluster and use the arrow keys to navigate through the cluster line-by-line.

Please consider making the cluster search functionality toggleable.

bagonyi avatar Oct 05 '23 12:10 bagonyi

Try turning on cursor-mode by pressing CTRL + X. You can permanently enable cursor mode by running the following :config command:

:config /ui/movement/mode cursor

tstack avatar Oct 05 '23 16:10 tstack

Thank you for pointing out cursor-mode, it is indeed a good workaround.

The only issue I have noticed, is that when moving between the error messages in cursor-mode using the e key, the line under focus will cause the text to be hidden, due to the background and foreground colours being the same.

Cursor not on the error line:

Screenshot 2023-10-06 at 10 54 51

Cursor on the error line:

Screenshot 2023-10-06 at 10 55 08

bagonyi avatar Oct 06 '23 10:10 bagonyi

Another issue I am seeing is that in cursor mode the chronological navigation using the r/R keys appears to be somewhat broken.

If in cursor mode I go to the first line in the log file, type :goto 1 seconds later, and press the r key a few times, the cursor advances second by second, as expected. When I press the R key, the cursor goes back to a second earlier. However, when I press the R key a 2nd time, nothing happens, it just stays on the same line. If I exit cursor mode, the R key starts to function as expected.

bagonyi avatar Oct 06 '23 10:10 bagonyi

The only issue I have noticed, is that when moving between the error messages in cursor-mode using the e key, the line under focus will cause the text to be hidden, due to the background and foreground colours being the same.

Ah, sorry, this is a bug in the default theme. Maybe try a different one for now, I usually use the monocai theme. You can change the theme with the :config command. For example, to set it to monocai, you would do:

:config /ui/theme monocai

If in cursor mode I go to the first line in the log file, type :goto 1 seconds later, and press the r key a few times, the cursor advances second by second, as expected. When I press the R key, the cursor goes back to a second earlier. However, when I press the R key a 2nd time, nothing happens, it just stays on the same line. If I exit cursor mode, the R key starts to function as expected.

I can replicate this, thanks! I'll get it fixed right away.

tstack avatar Oct 06 '23 15:10 tstack