Skip to content

fix: use async for moving cursor with dot repeat #1904

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

Saghen
Copy link
Owner

@Saghen Saghen commented Jun 12, 2025

I don't love this solution in general, so please feel free to suggest other ideas!

We use <C-g>U<Left> to move the cursor backwards after accepting with auto-brackets (move_cursor_in_dot_repeat). However, because we use feedkeys, the input is queued for processing, but doesn't get processed until after vim.schedule. This means we don't have an easy way to wait for it to finish processing and the downstream show_if_on_trigger_character() will see the cursor at test()| instead of at test(|).

I've setup an autocmd that listens for a CursorMoved/CursorMovedI event (need CursorMovedC too, but that's nvim 0.11+. need to test terminal too) and resolves the move_cursor_in_dot_repeat task when the autocmd fires. Notably, this makes the default_implementation passed to source:execute Task rather than void, so sources would need to be updated to support this.

Closes #1685

@canova
Copy link

canova commented Jun 14, 2025

Thanks for the PR!

Notably, this makes the default_implementation passed to source:execute Task rather than void, so sources would need to be updated to support this.

This makes sense, but we don't need to do anything for LSP sources since this PR updates it already, right?

I tried this PR locally with my STR in #1685, and I still can't get the signature show up on the JS (with ts_ls) files. But I'm not entirely sure if there is something else needed.

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.

Signature doesn't show up on a JS file right after the autocompletion is accepted
2 participants