[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 110d672 12/57: Cleanup diff parsing function
From: |
Justin Burkett |
Subject: |
[elpa] master 110d672 12/57: Cleanup diff parsing function |
Date: |
Tue, 3 Nov 2020 14:32:19 -0500 (EST) |
branch: master
commit 110d6726bc2f0c6a7c589fb59de8001ad9477950
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>
Cleanup diff parsing function
---
vdiff.el | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/vdiff.el b/vdiff.el
index 01610f6..69bde38 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -603,6 +603,12 @@ an addition when compared to other vdiff buffers."
(let* ((start-line-a (string-to-number (match-string 1)))
(start-line-b (string-to-number (match-string 2)))
(lines (cons start-line-a start-line-b)))
+ ;; Adjust starting line in case it's not actually a line of one of
the
+ ;; files
+ (when (looking-at-p "+")
+ (setcar lines (1- (car lines))))
+ (when (looking-at-p "-")
+ (setcdr lines (1- (cdr lines))))
(while (and (not (looking-at-p "@"))
(not (eobp)))
(cond ((looking-at-p "+")
@@ -614,8 +620,7 @@ an addition when compared to other vdiff buffers."
(when vdiff-debug
(cl-assert (or (looking-at-p " ") (eobp))))
(push
- ;; there's no context lines at the beginning of the file
- (list (cons (if (= beg-a 1) 1 (1+ beg-a)) nil)
+ (list (cons (car lines) nil)
(cons beg-b (1- (cdr lines))))
res)))
((looking-at-p "-")
@@ -627,8 +632,8 @@ an addition when compared to other vdiff buffers."
(if (or (looking-at-p " ") (eobp))
;; subtraction
(push
- (list (cons beg-a (if (= (car lines) 1) 1 (1- (car
lines))))
- (cons (1+ beg-b) nil))
+ (list (cons beg-a (1- (car lines)))
+ (cons (cdr lines) nil))
res)
(when vdiff-debug
(cl-assert (or (looking-at-p "+") (eobp))))
@@ -640,8 +645,9 @@ an addition when compared to other vdiff buffers."
(push
(list (cons beg-a (1- (car lines)))
(cons beg-b (1- (cdr lines))))
- res))))))
- (setq lines (vdiff--inc-lines lines))))))
+ res)))))
+ (t
+ (setq lines (vdiff--inc-lines lines))))))))
(nreverse res)))
(defun vdiff--parse-diff3 (buf)
- [elpa] master fd6ec8e 25/57: Test that both buffers are correct by default, (continued)
- [elpa] master fd6ec8e 25/57: Test that both buffers are correct by default, Justin Burkett, 2020/11/03
- [elpa] master 45666cc 30/57: README: evil-collection adds vimdiff-like bindings, Justin Burkett, 2020/11/03
- [elpa] master 6878093 33/57: Add vdiff-toggle-fold and vdiff-toggle-all-folds, Justin Burkett, 2020/11/03
- [elpa] master ccc773b 39/57: Add optional to-buffer arg to vdiff--translate line, Justin Burkett, 2020/11/03
- [elpa] master 58d530b 53/57: Add vdiff-temp-files, Justin Burkett, 2020/11/03
- [elpa] master c732247 45/57: Reset truncate-lines on cleanup, Justin Burkett, 2020/11/03
- [elpa] master 61d29bb 54/57: Travis -> github workflow, Justin Burkett, 2020/11/03
- [elpa] master eb553fa 09/57: Add support for different diff algorithms, Justin Burkett, 2020/11/03
- [elpa] master 8f3fa10 15/57: Fix Makefile typo, Justin Burkett, 2020/11/03
- [elpa] master 5667bc6 16/57: Ensure input files to diff end in newline, Justin Burkett, 2020/11/03
- [elpa] master 110d672 12/57: Cleanup diff parsing function,
Justin Burkett <=
- [elpa] master bd8976e 26/57: Add movement and setup tests, Justin Burkett, 2020/11/03
- [elpa] master 40ffc92 29/57: Warn on bad initialization of vdiff session., Justin Burkett, 2020/11/03
- [elpa] master 0e10521 31/57: Merge pull request #20 from edkolev/patch-1, Justin Burkett, 2020/11/03
- [elpa] master f2a622f 34/57: Improve vdiff-toggle-fold, Justin Burkett, 2020/11/03
- [elpa] master 45f7019 19/57: Add basic send and receive tests, Justin Burkett, 2020/11/03
- [elpa] master 773e3eb 28/57: Fix compiler warnings, Justin Burkett, 2020/11/03
- [elpa] master 3bfb5de 32/57: Truncate long lines by default, Justin Burkett, 2020/11/03
- [elpa] master c806fe2 36/57: Allow selective sending in change hunks, Justin Burkett, 2020/11/03
- [elpa] master 007e44b 56/57: Version 0.2.4, Justin Burkett, 2020/11/03
- [elpa] master 69eacfe 18/57: Fix and simplify final newline detection, Justin Burkett, 2020/11/03