Skip to content

fix: Unhandled terminal mode in set_cursor implementation #1672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

friedow
Copy link
Contributor

@friedow friedow commented Apr 24, 2025

Summary of the change
The set_cursor function on the blink.cmp.Context did not handle terminal mode gracefully. Since terminal buffers support using the vim.api.nvim_win_set_cursor function we can just extend the default behavior of set_cursor for terminal buffers.

How I noticed the problem:
Every time I've tried to switch to the third (or more) completion entry by hitting my select_next keybind in a terminal buffer I ran into this error:

Error executing vim.schedule lua callback: ...t/blink.cmp/lua/blink/cmp/completion/trigger/context.lua:106: Unsupported mode for setting cursor: term
stack traceback:
	[C]: in function 'assert'
	...t/blink.cmp/lua/blink/cmp/completion/trigger/context.lua:106: in function 'set_cursor'
	...ckages/start/blink.cmp/lua/blink/cmp/completion/list.lua:241: in function 'undo_preview'
	...ckages/start/blink.cmp/lua/blink/cmp/completion/list.lua:167: in function 'cb'
	...ckages/start/blink.cmp/lua/blink/cmp/lib/term_events.lua:81: in function 'suppress_events_for_callback'
	...tart/blink.cmp/lua/blink/cmp/completion/trigger/init.lua:201: in function 'suppress_events_for_callback'
	...ckages/start/blink.cmp/lua/blink/cmp/completion/list.lua:166: in function 'select'
	...ckages/start/blink.cmp/lua/blink/cmp/completion/list.lua:196: in function 'select_next'
	.../myNeovimPackages/start/blink.cmp/lua/blink/cmp/init.lua:189: in function <.../myNeovimPackages/start/blink.cmp/lua/blink/cmp/init.lua:189>

Why I noticed the problem
I'm currently building zsh completions for blink.cmp. More on that in other PRs in a couple of days :).

@Saghen Saghen merged commit 07a09ac into Saghen:main Apr 24, 2025
4 checks passed
@Saghen
Copy link
Owner

Saghen commented Apr 24, 2025

Thanks!

I'm currently building zsh completions for blink.cmp. More on that in other PRs in a couple of days :)

If you've got any questions, please don't hesitate to comment on that issue!

@friedow friedow deleted the fix/term-set-cursor branch April 25, 2025 04:57
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