branch: externals/phpinspect
commit 9d6ce5726d921e7d9265bbdbe78a1a05e6958e69
Author: Hugo Thunnissen <[email protected]>
Commit: Hugo Thunnissen <[email protected]>
Use `phpinspect-edtrack-original-position-at-point' for edit end
determination
---
phpinspect-edtrack.el | 4 +++-
phpinspect-parser.el | 6 +++---
test/test-edtrack.el | 23 ++++++++++++++++++-----
3 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/phpinspect-edtrack.el b/phpinspect-edtrack.el
index 01857d5fa6..ae28dfc546 100644
--- a/phpinspect-edtrack.el
+++ b/phpinspect-edtrack.el
@@ -120,7 +120,9 @@
;; points in the buffer subtratted. This corresponds with
;; the original position of the region end before the
;; buffer was ever edited.
- (- (+ start pre-change-length) (or
(phpinspect-edit-delta edit-before) 0))
+ (phpinspect-edtrack-original-position-at-point
+ track (+ start pre-change-length))
+
;; The delta of this edit.
(- (- end start) pre-change-length))))
diff --git a/phpinspect-parser.el b/phpinspect-parser.el
index e5fa194e80..9aab4d32c9 100644
--- a/phpinspect-parser.el
+++ b/phpinspect-parser.el
@@ -563,6 +563,9 @@ token is \";\", which marks the end of a statement in PHP."
(not (if delimiter-predicate
(funcall delimiter-predicate (car (last
tokens)))
nil)))
+ (when check-interrupt
+ (phpinspect-pctx-check-interrupt context))
+
(setq start-position (point))
(cond ((and previous-bmap edtrack
(setq existing-meta
@@ -583,9 +586,6 @@ token is \";\", which marks the end of a statement in PHP."
(goto-char current-end-position)
- (when check-interrupt
- (phpinspect-pctx-check-interrupt context))
-
;; Skip over whitespace after so that we don't do a full
;; run down all of the handlers during the next iteration
(when (looking-at (phpinspect-handler-regexp 'whitespace))
diff --git a/test/test-edtrack.el b/test/test-edtrack.el
index 68e9ee4bcb..4391598f33 100644
--- a/test/test-edtrack.el
+++ b/test/test-edtrack.el
@@ -6,13 +6,26 @@
(should (= 13 (phpinspect-edit-end edit)))))
(ert-deftest phpinspect-edtrack-register-edit ()
- (let* ((edtrack (phpinspect-make-edtrack))
- (edit1 (phpinspect-edtrack-register-edit edtrack 5 10 10))
- (edit3 (phpinspect-edtrack-register-edit edtrack 100 200 150))
- (edit2 (phpinspect-edtrack-register-edit edtrack 15 22 7)))
+ (let* ((edtrack (phpinspect-make-edtrack)))
+ (phpinspect-edtrack-register-edit edtrack 5 10 10)
+ (phpinspect-edtrack-register-edit edtrack 100 200 150)
+ (phpinspect-edtrack-register-edit edtrack 15 22 7)
(should (equal `((255 . -50) (27 . 0) (15 . -5)) (phpinspect-edtrack-edits
edtrack)))))
+(ert-deftest phpinspect-edtrack-register-encroaching-edit ()
+ (let* ((edtrack (phpinspect-make-edtrack)))
+ (phpinspect-edtrack-register-edit edtrack 5 10 0)
+ (phpinspect-edtrack-register-edit edtrack 100 150 25)
+
+ ;; Encroaches on delta of edit before by 15 points ((125 + 25) - 135 = 15),
+ ;; so the original end position should be calculated as 135 - (25 - 15) -
5 = 120
+ ;; (see also `phpinspect-edtrack-original-position-at-point')
+ (phpinspect-edtrack-register-edit edtrack 135 170 0)
+
+ (should (equal `((120 . 35) (120 . 25) (5 . 5)) (phpinspect-edtrack-edits
edtrack)))))
+
+
(ert-deftest phpinspect-edtrack-orginal-position-at-point ()
(let ((track (phpinspect-make-edtrack)))
(phpinspect-edtrack-register-edit track 10 20 0)
@@ -74,4 +87,4 @@
iterator (phpinspect-make-meta nil 65 73 nil nil)))
(should (phpinspect-taint-iterator-token-is-tainted-p
- iterator (phpinspect-make-meta nil 100 130 nil nil)))))
+ iterator (phpinspect-make-meta nil 100 130 nil nil)))))