From: NeilBrown Date: Sun, 18 Jun 2023 07:54:12 +0000 (+1000) Subject: diff: fix occasional slowness. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=299be919c532d8f715c7a40d67d25d9b39a0df63;p=edlib.git diff: fix occasional slowness. If a diff region was marked before it was completely generated, an attempt to mark the word-diff regions could create over-lapping vmark ranges, which causes confusion. So always remove old vmark ranges before adding new ones. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index e682acd4..ea0c1e89 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -32,7 +32,7 @@ the file. ### Medium - [X] lib-mergeview improvements -- [ ] lib-diff slowness with large diff +- [X] lib-diff slowness with large diff - [ ] linecount :when used in 'view' mode, stack the counting pane with all the others so it can easily catch view-changed. - [X] C config module that reads an ini-style file to set attributes @@ -215,9 +215,9 @@ Module features ### lib-diff -- [ ] When viewing diff or merge can get into infinite loop. Possibly due +- [X] When viewing diff or merge can get into infinite loop. Possibly due to edit at end-of-file -- [ ] slowness with large diff - particularly lots of "+" lines at end +- [X] slowness with large diff - particularly lots of "+" lines at end - [ ] highlight white-space errors. - [ ] command to apply a hunk to a given document - or to reverse it. How much of a hunk? Selection? How to record which hunks are done? diff --git a/python/lib-diff.py b/python/lib-diff.py index 5ccbd88a..b0e0bd77 100644 --- a/python/lib-diff.py +++ b/python/lib-diff.py @@ -159,11 +159,17 @@ class DiffPane(edlib.Pane): break ch = focus.following(mark) + # delete any old marks in this range. + m = focus.vmark_at_or_before(self.viewnum, mark, self) + while m and m >= starta: + m.release() + m = focus.vmark_at_or_before(self.viewnum, mark, self) + alen = measure(focus, starta, startb) blen = measure(focus, startb, mark) if alen == 0 or blen == 0 or not is_hunk: - msg = "Nothing to compare here!" - ret = 4 + msg = "Nothing to compare here!" + ret = 4 else: cmd = focus.call("MakeWiggle", ret='comm') if not cmd: