branch: master
commit 9346e9669cb9cd6bf52507428ef9339c28c03718
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Improve the overlay offset
* ivy-overlay.el (ivy-display-function-overlay): Update.
1. When in `org-mode' take into account `org-indent-mode'.
2. When completing a prefix, place it so that it lines up with existing
text. For example, in an Elisp buffer type "org-" and press "C-M-i". The
candidates will all start with "org-" and now will line up with the
"org-" that's already in the buffer. Instead of just being aligned to
the current point.
---
ivy-overlay.el | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ivy-overlay.el b/ivy-overlay.el
index 7a45137..e74e486 100644
--- a/ivy-overlay.el
+++ b/ivy-overlay.el
@@ -69,7 +69,12 @@ Hide the minibuffer contents and cursor."
(buffer-substring (1- (point)) (point))
ivy-text
(buffer-substring (point) (line-end-position))
- (ivy-left-pad str (current-column))))))
+ (ivy-left-pad str
+ (+ (if (eq major-mode 'org-mode)
+ (* org-indent-indentation-per-level
(org-current-level))
+ 0)
+ (- ivy-completion-beg ivy-completion-end)
+ (current-column)))))))
(provide 'ivy-overlay)
;;; ivy-overlay.el ends here