cs icon indicating copy to clipboard operation
cs copied to clipboard

Only first occurrence within file is displayed

Open m-kru opened this issue 2 years ago • 5 comments

I have realized that only first occurrence within file is displayed. Is this intentional behavior?

m-kru avatar Jun 08 '23 13:06 m-kru

Ok, I see I have to provide -s N argument. The default value is 1. To be honest I do not think this is desired default behavior. Shouldn't it default to "all"?

m-kru avatar Jun 08 '23 13:06 m-kru

Another observation -s does not work in interactive TUI mode.

m-kru avatar Jun 08 '23 13:06 m-kru

Its not the first occurrence, but what is considered the most relevant one. Which of course depends on the terms entered, their relative frequency in the corpus being searched, how close they are together etc...

From the README

It works by passing the document content to extract the snippet from and all the match locations for each term. It then looks through each location for each word, and checks on either side looking for terms close to it. It then ranks on the term frequency for the term we are checking around and rewards rarer terms. It also rewards more matches, closer matches, exact case matches and matches that are whole words.

This is the intended default behavior. If you are looking for all the matches something like rg TERM | fzf is an existing option to achieve this.

As for them not working in TUI mode... that I am aware of. It is something I want to include. Ill leave this open to track that particular issue.

boyter avatar Jun 08 '23 22:06 boyter

Is there any option in TUI to select given file and jump over occurrences? It also would be nice to display how many occurrence have been found.

m-kru avatar Jun 09 '23 06:06 m-kru

Not currently. I think that could be a decent addition to have though.

boyter avatar Jun 14 '23 04:06 boyter