branch: externals/capf-autosuggest
commit 54e9d1f559fe08f3f7004e4d0f961847c4b4d579
Author: jakanakaevangeli <[email protected]>
Commit: jakanakaevangeli <[email protected]>
Fix cursor display issues if overlay text ends with a newline
---
capf-autosuggest.el | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/capf-autosuggest.el b/capf-autosuggest.el
index 2074808..9512181 100644
--- a/capf-autosuggest.el
+++ b/capf-autosuggest.el
@@ -196,8 +196,12 @@ Otherwise, return nil."
capf-autosuggest--str (copy-sequence str)
capf-autosuggest--tick (buffer-modified-tick))
(move-overlay capf-autosuggest--overlay end end)
+ ;; Make sure the overlay after-string doesn't start or end with a
+ ;; newline, otherwise it can behave badly with cursor placement
(when (eq ?\n (aref str 0))
(setq str (concat " " str)))
+ (when (eq ?\n (aref str (1- (length str))))
+ (setq str (concat str (propertize " " 'display ""))))
(add-text-properties 0 1 (list 'cursor (length str)) str)
(put-text-property 0 (length str) 'face 'capf-autosuggest-face str)
(overlay-put capf-autosuggest--overlay 'after-string str)