diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2008-03-18 20:49:52 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2008-03-18 20:49:52 +0000 |
commit | aec1ef0729fecde2dc7c322d6bbd52858104d2b7 (patch) | |
tree | f11cf6f933b332b8f4af7bcb41a774029f51844c /lisp/diff-mode.el | |
parent | 117402b86d9199a8ff226075f804d2f8908dac9e (diff) | |
download | emacs-aec1ef0729fecde2dc7c322d6bbd52858104d2b7.tar.gz |
(diff-end-of-hunk): Be careful not to overlook trailing
"+" lines not accounted for by counting "-" and context lines.
Diffstat (limited to 'lisp/diff-mode.el')
-rw-r--r-- | lisp/diff-mode.el | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el index c57613dff51..798f5f2e4ec 100644 --- a/lisp/diff-mode.el +++ b/lisp/diff-mode.el @@ -402,12 +402,23 @@ See http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01990.html") (setq style (cdr (assq (char-after) '((?@ . unified) (?* . context)))))) (goto-char (match-end 0)) (when (and (not donttrustheader) (match-end 2)) + (let* ((nold (string-to-number (match-string 2))) + (nnew (string-to-number (match-string 4))) + (endold (save-excursion (re-search-forward (if diff-valid-unified-empty-line "^[- \n]" "^[- ]") - nil t - (string-to-number (match-string 2))) - (setq end (line-beginning-position 2))))) + nil t nold) + (line-beginning-position 2))) + (endnew + ;; The hunk may end with a bunch of "+" lines, so the `end' is + ;; then further than computed above. + (save-excursion + (re-search-forward (if diff-valid-unified-empty-line + "^[+ \n]" "^[+ ]") + nil t nnew) + (line-beginning-position 2)))) + (setq end (max endold endnew))))) ;; We may have a first evaluation of `end' thanks to the hunk header. (unless end (setq end (and (re-search-forward |