Skip to content

Commit

Permalink
fix: Handle when self-insert is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Dec 24, 2023
1 parent 06fb307 commit d2c5d8c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vs-comment-return.el
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,15 @@
"Execution after command's execution."
;; De-register ourselves!
(remove-hook 'post-command-hook #'vs-comment-return--post-command t)
(when (memq #'vs-comment-return--post-self-insert post-self-insert-hook)
(run-hooks 'post-self-insert-hook))
;; Cancel action!
(remove-hook 'post-self-insert-hook #'vs-comment-return--post-self-insert t))

(defun vs-comment-return--post-self-insert (&rest _)
"Execution after self insertion."
(when (and vs-comment-return-cancel-after
(eq last-command-event ?\n)
(memq last-command-event '(?\n ?\r))
(vs-comment-return--line-empty-p))
;; At this point, it means we have enter the return twice in a row. The
;; previous line above must be a empty comment line, which is safe to
Expand Down

0 comments on commit d2c5d8c

Please sign in to comment.