Stricter refinement threshold and logic
This commit is contained in:
parent
c042ae2e33
commit
15c71d1189
|
@ -52,8 +52,11 @@ If nil, the additions will be displayed via empty overlays."
|
||||||
"Whether to refine diffs with finer changes."
|
"Whether to refine diffs with finer changes."
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
(defcustom inline-diff-refine-similarity 0.5
|
(defcustom inline-diff-refine-similarity 0.7
|
||||||
"The similarity threshold for refining diffs."
|
"The similarity threshold for refining diffs, between 0.0 and 1.0.
|
||||||
|
|
||||||
|
This is the proportion of characters that must remain in common between
|
||||||
|
the old and new versions in order for refinement highlighting to be shown."
|
||||||
:type 'number)
|
:type 'number)
|
||||||
|
|
||||||
;;;; Faces
|
;;;; Faces
|
||||||
|
@ -509,8 +512,9 @@ SO-FAR is a list of overlays already seen."
|
||||||
(mapconcat #'cdr (cdar last-op-ov) nil))))
|
(mapconcat #'cdr (cdar last-op-ov) nil))))
|
||||||
(new-chars (vconcat (inline-diff--char-positions
|
(new-chars (vconcat (inline-diff--char-positions
|
||||||
(mapconcat #'cdr (cdar op-ov) nil))))
|
(mapconcat #'cdr (cdar op-ov) nil))))
|
||||||
|
(max-length (max (length old-chars) (length new-chars)))
|
||||||
(char-diff (inline-diff--myers-diff old-chars new-chars :test #'eql :key #'cdr))
|
(char-diff (inline-diff--myers-diff old-chars new-chars :test #'eql :key #'cdr))
|
||||||
deletions insertions del-ins-unique-points)
|
deletions insertions)
|
||||||
(dolist (op char-diff)
|
(dolist (op char-diff)
|
||||||
(pcase (car op)
|
(pcase (car op)
|
||||||
('delete
|
('delete
|
||||||
|
@ -518,13 +522,15 @@ SO-FAR is a list of overlays already seen."
|
||||||
('insert
|
('insert
|
||||||
(setq insertions (nconc insertions (cdr op))))))
|
(setq insertions (nconc insertions (cdr op))))))
|
||||||
(when (and deletions
|
(when (and deletions
|
||||||
(<= (length deletions) (* inline-diff-refine-similarity (length old-chars))))
|
(<= (length deletions) (* (- 1 inline-diff-refine-similarity) (length old-chars)))
|
||||||
|
(<= (* inline-diff-refine-similarity max-length) (length old-chars)))
|
||||||
(inline-diff--show-refinement
|
(inline-diff--show-refinement
|
||||||
(cdr last-op-ov)
|
(cdr last-op-ov)
|
||||||
(inline-diff--seq-ranges deletions #'car)
|
(inline-diff--seq-ranges deletions #'car)
|
||||||
'inline-diff-refine-removed))
|
'inline-diff-refine-removed))
|
||||||
(when (and insertions
|
(when (and insertions
|
||||||
(<= (length insertions) (* inline-diff-refine-similarity (length new-chars))))
|
(<= (length insertions) (* (- 1 inline-diff-refine-similarity) (length new-chars)))
|
||||||
|
(<= (* inline-diff-refine-similarity max-length) (length new-chars)))
|
||||||
(inline-diff--show-refinement
|
(inline-diff--show-refinement
|
||||||
(cdr op-ov)
|
(cdr op-ov)
|
||||||
(inline-diff--seq-ranges insertions #'car)
|
(inline-diff--seq-ranges insertions #'car)
|
||||||
|
|
Loading…
Reference in a new issue