https://bugs.documentfoundation.org/show_bug.cgi?id=135538

--- Comment #21 from Justin L <[email protected]> ---
The problems with zero-length matches in Writer are:
-cannot replace (only ReplaceAll): SwEditShell::Replace needs
    rPaM.HasMark() && *rPaM.GetMark() != *rPaM.GetPoint()
-there is nothing to select and no cursor is seen, so no user feedback...
-cannot move ahead: each 'Find Next' finds the same match

And (except for very explicit cases), we cannot know ahead of time whether a
zero-length match is expected, and after the fact is too late!

I suppose we could track the starting position - and if the search results in a
zero-length match at the same starting position we could reject the result,
move ahead in the content, and run the search again. The likely place to do
that is SwCursor::FindAll (used for all kinds of finds, not just 'Find All').
lcl_FindSelection already does this position tracking for FindRanges::InSelAll.

So with a lot of effort the 'cannot move ahead' problem should be solvable. But
given the other two (more unsolvable) problems, it doesn't seem worthwhile
putting the effort into this.


I have a simple patch that mostly solves this for Calc. I'm a bit reluctant to
merge it because I'm not a Calc guy.
https://gerrit.libreoffice.org/c/core/+/209080

I also have a hacky patch for searching Writer for '^' that seems to work
pretty good. https://gerrit.libreoffice.org/c/core/+/209094

And then finally a quick patch to at least accept zero-length matches, despite
all their problems. https://gerrit.libreoffice.org/c/core/+/209115

Not sure if I will every try to merge any of these...

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to