V command and diff-file-next clash

epich avatarepich created an issue

Open up any multi file unified diff file. Highlight the current line with V evil-visual-line command. M-x diff-file-next. Wait about one second and witness the advancement of point is undone. Behaves fine with v evil-visual-char command.

Comments (3)

  1. Frank Fischer
    • changed status to open

    This should fix the problem if diff-file-next is called with a keybinding, e.g. M-}. However, if it is called using M-x it still does not work.

    The reason is that M-x calls execute-extended-command, and, AFAIK, there is no way to execute some code after the command to be executed has been entered but before it is actually run. But this would be necessary to detect whether that command is actually a motion or an editing command (e.g. diff-file-next vs. delete-region) -- if the command is a motion, then the visual region is not changed before the command is run because only the position of point is important, however if the command is an editing command then the region (i.e. mark and point) must be moved so that the (Emacs) region matches the visual selection.

    The problem you encountered was caused because diff-file-next has not been marked as a motion, so the adapt-the-region action took place and Evil modified the region causing point to jump.

    Though, I would be glad to hear a solution to the executed-extended-command problem ;)

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.