https://bugs.kde.org/show_bug.cgi?id=384459

--- Comment #3 from Mykola Krachkovsky <[email protected]> ---
More thoughts about more complex and nice solution as I see it.

It could be done at moment of recalculation of fold positions or later. If we
do check later we have something like two lists (or trees?) of pairs.

First list "markers": correct folds starts and endings.
Second list "folds": current (folded) folds starts and endings.

At update time (open/activate file or external update) we are checking "folds":
for each element in "folds" find matching in "markers" by start. I expect they
both are sorted by start so we can search with binary search dividing not by
half but proportionally starting from first acceptable (no point to check
previous folds with lines less than current) — just keep some current start
index. If there is no match in "markers" remove this item from "folds". If
there is match by start but ending doesn't match either remove from "folds" or
change it endings with new valid ending (can't see any problems ATM). If both
start and endings match, check next item in "folds".

After that all incorrect items would be fixed or removed from "folds" (at worst
it would be empty) and it could be used to show folds in file.

If "markers" and "folds" are trees instead of lists algorithm of search should
be slightly more complex to check inside of node whose start is less than
investigated and end is bigger (< and > or <= and >= not sure ATM).

I'm ready to spend my time to implement this (starting from this weekend) and
it would be nice to have some hint where to start.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to