Skip to content

Commit

Permalink
feat: better cursor positioning on accept
Browse files Browse the repository at this point in the history
  • Loading branch information
kassick committed Nov 25, 2024
1 parent b4f0c7c commit f5b572b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lsp-inline-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@
((start . end) (when range?
(-let (((&RangeToPoint :start :end) range?)) (cons start end))))
(text-insert-start (or start lsp-inline-completion--start-point))
text-insert-end)
text-insert-end
(completion-is-substr (string-equal
(buffer-substring text-insert-start lsp-inline-completion--start-point)
(substring text 0 (- lsp-inline-completion--start-point text-insert-start)))))

(when text-insert-start
(goto-char text-insert-start))
Expand All @@ -275,7 +278,9 @@
(when command?
(lsp--execute-command command?))

(goto-char text-insert-start)
(if completion-is-substr
(goto-char lsp-inline-completion--start-point)
(goto-char text-insert-start))

;; hooks
(run-hook-with-args-until-failure 'lsp-inline-completion-accepted-hook text text-insert-start text-insert-end)))
Expand Down

0 comments on commit f5b572b

Please sign in to comment.