]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/diff-mode.el: Better handle empty lines in context diffs
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 25 Mar 2019 17:20:17 +0000 (13:20 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 25 Mar 2019 17:20:17 +0000 (13:20 -0400)
(diff-end-of-hunk): Obey diff-valid-unified-empty-line for context style.
(diff--refine-hunk): Don't look further than the end.

lisp/vc/diff-mode.el

index 40204404e77ab3ccccdac74cd0cbaf3d251bc0f6..b67caab7f5045cc2058bfd4dc1295bc7eec13a8a 100644 (file)
@@ -533,7 +533,8 @@ See https://lists.gnu.org/r/emacs-devel/2007-11/msg01990.html")
                                      "^[^-+# \\\n]\\|" "^[^-+# \\]\\|")
                                  ;; A `unified' header is ambiguous.
                                  diff-file-header-re))
-                        ('context "^[^-+#! \\]")
+                        ('context (if diff-valid-unified-empty-line
+                                      "^[^-+#! \n\\]" "^[^-+#! \\]"))
                         ('normal "^[^<>#\\]")
                         (_ "^[^-+#!<> \\]"))
                       nil t)
@@ -2116,7 +2117,7 @@ Return new point, if it was moved."
              (smerge-refine-regions beg-del beg-add beg-add end-add
                                     nil #'diff-refine-preproc props-r props-a)))))
       ('context
-       (let* ((middle (save-excursion (re-search-forward "^---")))
+       (let* ((middle (save-excursion (re-search-forward "^---" end)))
               (other middle))
          (while (re-search-forward "^\\(?:!.*\n\\)+" middle t)
            (smerge-refine-regions (match-beginning 0) (match-end 0)