Skip to content

Make evil-ghostel-goto-cursor a linewise motion#486

Merged
dakra merged 1 commit into
mainfrom
fix/485-visual-line-goto-cursor
Jun 30, 2026
Merged

Make evil-ghostel-goto-cursor a linewise motion#486
dakra merged 1 commit into
mainfrom
fix/485-visual-line-goto-cursor

Conversation

@dakra

@dakra dakra commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

In an evil-ghostel buffer, G in line-visual state (VG) left point on the
original line instead of extending the selection to the terminal cursor.
Char-visual (vG) worked.

Root cause

evil-ghostel-goto-cursor was a plain defun, so it lacked evil's
:keep-visual property. In line-visual, evil-visual-pre-command therefore
expanded the region to whole lines (moving point to a line boundary) before the
command ran, and evil-visual-post-command contracted it afterward — reverting
the jump. Char-visual's expand/contract is point-neutral, so it was unaffected.

Fix

Define evil-ghostel-goto-cursor with evil-define-motion (:type line,
:jump t), mirroring evil-goto-line. evil-define-motion supplies
:keep-visual t, which suppresses the line-visual expand/contract so the jumped
point sticks. The inactive branch now passes COUNT through to evil-goto-line.

Testing

  • make -j8 all — green (build, lint, all suites; evil-ghostel 112/112).
  • Added regression tests for VG and vG, plus the inactive evil-goto-line
    fallback. They drive G through evil's visual command-loop hooks
    (evil-visual-pre-command / -post-command) because execute-kbd-macro
    does not dispatch commands under --batch. Verified the line-visual test
    fails on the pre-fix code and passes after.
  • Live-verified in a real ghostel + zsh session: VG now moves point to the
    cursor row and selects line 1 → cursor row; vG still works.

Closes #485

In line-visual state (VG) point stayed on the original line instead of
extending the selection to the terminal cursor.  As a plain command,
evil-ghostel-goto-cursor lacked :keep-visual, so evil expanded the
line-visual region to whole lines before the command and contracted it
after, reverting the jump.  Char-visual (vG) was unaffected because its
expand/contract is point-neutral.

Define it with evil-define-motion (:type line, :jump t), mirroring
evil-goto-line: that supplies :keep-visual t and suppresses the
expand/contract.  The inactive branch now passes COUNT through to
evil-goto-line.

Add regression tests for VG/vG driven through evil's visual
command-loop hooks, since execute-kbd-macro does not dispatch commands
under --batch.

Fix #485
@dakra dakra mentioned this pull request Jun 29, 2026
@dakra
dakra merged commit 48d5a21 into main Jun 30, 2026
24 checks passed
@dakra
dakra deleted the fix/485-visual-line-goto-cursor branch June 30, 2026 07:42
@dakra
dakra temporarily deployed to github-pages June 30, 2026 07:43 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

visual-line G binding

1 participant