Skip to content

Fix right-click mouse support for Neovim 0.12+#2

Draft
Copilot wants to merge 2 commits intoneovimfrom
copilot/make-right-click-work
Draft

Fix right-click mouse support for Neovim 0.12+#2
Copilot wants to merge 2 commits intoneovimfrom
copilot/make-right-click-work

Conversation

Copy link

Copilot AI commented Mar 3, 2026

In Neovim 0.12+, mouse events cannot be replayed via normal! — calling exe "normal! \<LeftRelease>" inside s:RightRelease caused an E492 error that aborted function execution, breaking all right-click navigation.

Changes

  • s:MousePress: Replace exe "normal! \<LeftMouse>" with an explicit wincmd w + cursor() call using the getmousepos() data already stored in s:click. Neovim's getmousepos().column is 1-based, matching cursor()'s convention.

  • s:MiddleRelease / s:RightRelease: Guard exe "normal! \<LeftRelease>" with !has('nvim'). In Neovim, cursor position is already correct from the press handler; drag-based visual selection is covered by the existing <RightDrag><LeftDrag> remap.

" s:MousePress — was: exe "normal! \<LeftMouse>"
if has('nvim')
    exe win_id2win(s:click.winid).'wincmd w'
    call cursor(s:click.line, s:click.column)
else
    exe "normal! \<LeftMouse>"
endif

" s:RightRelease / s:MiddleRelease — was: exe "normal! \<LeftRelease>"
if !has('nvim')
    exe "normal! \<LeftRelease>"
endif

Vim behavior is unchanged.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • neovim.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

In Neovim 0.12+, normal! with mouse key events (<LeftMouse>,
<LeftRelease>) is restricted and cannot be used to replay mouse events.
This caused E492 errors in s:RightRelease.

Fixes:
- s:MousePress: use wincmd w + cursor() for Neovim instead of
  normal! \<LeftMouse>
- s:MiddleRelease: skip normal! \<LeftRelease> for Neovim
- s:RightRelease: skip normal! \<LeftRelease> for Neovim (root cause
  of the reported E492 error in issue #1)

Co-authored-by: mcepl <198999+mcepl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix right mouse click jump functionality for Neovim Fix right-click mouse support for Neovim 0.12+ Mar 3, 2026
Copilot finished work on behalf of mcepl March 3, 2026 17:04
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.

2 participants