TC704a: Lister regex search does not find empty lines

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
white
Power Member
Power Member
Posts: 5785
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

TC704a: Lister regex search does not find empty lines

Post by *white »

* View a text file using the internal lister
* Search for "^$" with regex checked
* no empty line is found

* View a text file using the internal lister
* Search for "^.*$" with regex checked
* repeat the search many times
* empty lines are skipped

It seems like all empty lines are skipped when searching using regex. Maybe this is done because repeatedly searching for "^.*$" would otherwise not continue?


Also I find the difference between repeatedly searching for ".*" and repeatedly searching for "^.*$" not very obvious. I know why it behaves like that, but I think it is not obvious.

I have a suggestion that would fix all above issues. I suggest to not skip empty lines but instead:
  • in case of a forward search: before performing the search, check whether the start position for the search is at the end of a line. If that's the case change the start position for the search to the beginning of the next line. (If there is no next line, display the "Not found" message)
  • in case of a backward search: before performing the search, check whether the start position for the search is at the beginning of a line. If that's the case change the start position for the search to the end of the previous line. (If there is no previous line, display the "Not found" message)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50475
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Indeed it's currently not possible to search for empty lines, this is a known limitation of the search function which can search only within lines, sorry. TC would explicitly have to search for pairs of line breaks when it encounters ^$ as the search string. Instead, just try to search for \n\n without regex.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5785
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ghisler(Author) wrote:Indeed it's currently not possible to search for empty lines, this is a known limitation of the search function which can search only within lines, sorry. TC would explicitly have to search for pairs of line breaks when it encounters ^$ as the search string. Instead, just try to search for \n\n without regex.
:?: Searching on "^$" or "^.*$" is searching within lines. Actually both these searching will find an empty line if the search starts at an empty line. Scroll a text file so an empty line is at the top of the window. Then start a new search for "^$" or "^.*$".

So matching empty lines isn't the problem. When no match is found in a line and the next line is selected to be searched, you seem to skip empty lines. That's the problem. Empty lines are not searched.

If you do not skip the empty lines, empty lines can be found. However repeated searches would probably find the same line over and over again. Hence my suggestion earlier to fix this.
Post Reply