]> git.neil.brown.name Git - edlib.git/commitdiff
diff: fix occasional slowness.
authorNeilBrown <neil@brown.name>
Sun, 18 Jun 2023 07:54:12 +0000 (17:54 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 07:51:41 +0000 (17:51 +1000)
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 <neil@brown.name>
DOC/TODO.md
python/lib-diff.py

index e682acd4102bda433371d3e968e3fa7927405c8e..ea0c1e898ba3305320e15513499a6c22b5be1bc2 100644 (file)
@@ -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?
index 5ccbd88af1b5ba5161ebf38b1f66327a718baaa9..b0e0bd771a64b40f6a4659eebd30ca7e6c5ab5ac 100644 (file)
@@ -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: