branch: externals/diff-hl commit ca35cfaf725f5b34f164f37de7637f17681fe2a4 Author: Dmitry Gutov <dmi...@gutov.dev> Commit: Dmitry Gutov <dmi...@gutov.dev>
Unify behavior between diff-hl-show-hunk-function's * Move posframe one line up, so its popup starts right after the hunk. * Add the same exception for `deletion` that inline-popup has. * Use `before-string` and `cursor` in inline popup, for correct positioning of it with `deletion` hunks as well. And of cursor, which it overlaps. --- diff-hl-inline-popup.el | 3 ++- diff-hl-show-hunk-posframe.el | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/diff-hl-inline-popup.el b/diff-hl-inline-popup.el index 48a6f991d4..0f202aff5a 100644 --- a/diff-hl-inline-popup.el +++ b/diff-hl-inline-popup.el @@ -154,7 +154,8 @@ FOOTER are showed at start and end." diff-hl-inline-popup--current-footer))) ;; https://debbugs.gnu.org/38563, `company--replacement-string'. (add-face-text-property 0 (length str) 'default t str) - (overlay-put diff-hl-inline-popup--current-popup 'after-string str)))) + (put-text-property 0 1 'cursor 0 str) + (overlay-put diff-hl-inline-popup--current-popup 'before-string str)))) (defun diff-hl-inline-popup--popup-down() "Scrolls one line down." diff --git a/diff-hl-show-hunk-posframe.el b/diff-hl-show-hunk-posframe.el index 331c4bb3fe..014d3f263e 100644 --- a/diff-hl-show-hunk-posframe.el +++ b/diff-hl-show-hunk-posframe.el @@ -194,8 +194,12 @@ The button calls an ACTION." (setq posframe-mouse-banish nil) (setq diff-hl-show-hunk--original-frame (selected-frame)) - (let* ((hunk-overlay diff-hl-show-hunk--original-overlay) - (position (overlay-end hunk-overlay))) + (let* ((overlay diff-hl-show-hunk--original-overlay) + (type (overlay-get overlay 'diff-hl-hunk-type)) + (position (save-excursion + (goto-char (overlay-end overlay)) + (forward-line -1) + (point)))) (setq diff-hl-show-hunk--frame (posframe-show buffer @@ -213,6 +217,7 @@ The button calls an ACTION." :respect-header-line diff-hl-show-hunk-posframe-show-header-line :respect-tab-line nil :respect-mode-line nil + :y-pixel-offset (if (eq type 'delete) (- (default-line-height))) :override-parameters diff-hl-show-hunk-posframe-parameters))) (set-frame-parameter diff-hl-show-hunk--frame 'drag-internal-border t)