syl20bnr / evil-escape

Customizable key sequence to escape from insert state and everything else in Emacs.
GNU General Public License v3.0
226 stars 41 forks source link

[UPSTREAM] evil-mode with overwrite mode error on pressing key f #82

Open XiaoGeMa opened 6 years ago

XiaoGeMa commented 6 years ago

Description :octocat:

overwrite mode error on pressing f

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: the two charactors under and after the cursor will be replace by f. if I press any key otherwise, only one charactor under the cursor will be replaced. I'm not sure it's a bug or something meaningful I don't understand.

Expected behaviour: :heart: :smile: like press other keys.

System Info :computer:

Backtrace :paw_prints:

<<BACKTRACE IF RELEVANT>>
duianto commented 4 years ago

The first evil escape sequence character seems to be inserted here: https://github.com/syl20bnr/evil-escape/blob/f4e9116bfbaac8c9d210c17ad488e0982291245f/evil-escape.el#L184

               (inserted (evil-escape--insert))

excluding the insertion in overwrite-mode seems to stop the issue:

               (inserted (unless overwrite-mode (evil-escape--insert)))

This can be tested by evaluating the function with the change:

(defun evil-escape-pre-command-hook ()
  "evil-escape pre-command hook."
  (with-demoted-errors "evil-escape: Error %S"
      (when (evil-escape-p)
        (let* ((modified (buffer-modified-p))
               (inserted (unless overwrite-mode (evil-escape--insert)))
               (fkey (elt evil-escape-key-sequence 0))
               (skey (elt evil-escape-key-sequence 1))
               (evt (read-event nil nil evil-escape-delay)))
          (when inserted (evil-escape--delete))
          (set-buffer-modified-p modified)
          (cond
           ((and (characterp evt)
                 (or (and (equal (this-command-keys) (evil-escape--first-key))
                          (char-equal evt skey))
                     (and evil-escape-unordered-key-sequence
                          (equal (this-command-keys) (evil-escape--second-key))
                          (char-equal evt fkey))))
            (evil-repeat-stop)
            (let ((esc-fun (evil-escape-func)))
              (when esc-fun
                (setq this-command esc-fun)
                (setq this-original-command esc-fun))))
           ((null evt))
           (t (setq unread-command-events
                    (append unread-command-events (list evt)))))))))