evil-collection
evil-collection copied to clipboard
evil append does not promote the cursor position appropriately
The following PR seems to have introduced a bug: https://github.com/emacs-evil/evil-collection/pull/638 After appending, the cursor will visually show the correct position, but as soon as you start typing it basically inserts instead of appends.
Effectively reverting the above-mentioned PR, it works as expected (using doom emacs):
(after! evil-collection
(defun evil-collection-vterm-append ()
"Append character after cursor."
(interactive)
(vterm-goto-char (1+ (point)))
(call-interactively #'evil-append)))
@quangIO @mjlbach any idea why it (seems to) behave differently on different setups?
You are right. #638 worked correctly at the time I created the PR. After I upgraded doom today, it behaved incorrectly like the way you describe (not sure about the root cause)
Does your fix have the correct cursor position and work correctly when cursor is under end of line position?
Does your fix have the correct cursor position and work correctly when cursor is under end of line position?
No, it does not have the correct cursor position, the behavior is the inverse: the cursor is visually incorrect (1 position ahead), but as soon as you start typing it appends correctly.
At the end of a line, both the cursor position & the append behavior works correctly with the above-mentioned fix
Does your fix have the correct cursor position and work correctly when cursor is under end of line position?
No, it does not have the correct cursor position, the behavior is the inverse: the cursor is visually incorrect (1 position ahead), but as soon as you start typing it appends correctly.
At the end of a line, both the cursor position & the append behavior works correctly with the above-mentioned fix
I think using evil insert as a workaround will fix the cursor position problem, but that may not work when cursor is at elop.
(defun evil-collection-vterm-append ()
"Append character after cursor."
(interactive)
(vterm-goto-char (1+ (point)))
(call-interactively #'evil-insert)))
It would be nicer if we can chase the root cause.
evil-insert
seems to be working fine, except that the cursor after "appending" should be one position back.
so if you are not at the end of the line, after appending & exiting insert mode, the cursor has moved to the next character.
@bram209 this thread has the workaround https://github.com/akermu/emacs-libvterm/issues/313.
TLDR: add something like to your config.
(defadvice! +vterm-update-cursor (orig-fn &rest args) :before #'vterm-send-key (vterm-goto-char (point)))
(defadvice! +vterm-update-cursor-boon (orig-fn &rest args) :before #'boon-insert (vterm-goto-char (point)))
x
to delete currently doesn't work though.
@bram209 this thread has the workaround akermu/emacs-libvterm#313.
TLDR: add something like to your config.
(defadvice! +vterm-update-cursor (orig-fn &rest args) :before #'vterm-send-key (vterm-goto-char (point))) (defadvice! +vterm-update-cursor-boon (orig-fn &rest args) :before #'boon-insert (vterm-goto-char (point)))
x
to delete currently doesn't work though.
This solved the issue for me
the cursor is visually incorrect (1 position ahead), but as soon as you start typing it appends correctly.
Yeah this seems to be a common annoying problem because apparently the "internal cursor position" is different from what we see visually. Personally I have the following code to workaround this issue:
(add-hook 'evil-insert-state-entry-hook #'vterm-reset-cursor-point nil t)
Is there something actionable on evil-collection's end here? @quangIO @blahgeek