Skip to content

fix: make ghost-text extmark with pcall #287

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 2 commits into from
Nov 12, 2024

Conversation

eero-lehtinen
Copy link
Contributor

Fixes #257

This issue also happens to me in a large Rust project where the LSP is slow. It tries to show a slightly outdated text edit and errors, but shows the correct text edit instantly after. So maybe this could also be fixed with better scheduling.

Now I just make the extmark with pcall to not render outdated ghost-texts and cause errors. Nvim-cmp also does this.

@idelice
Copy link

idelice commented Nov 11, 2024

This introduces another error that I've experienced by using your changes:

   Error  10:14:28 msg_show.lua_error Error executing vim.schedule lua callback: ...e/projects/blink.cmp/lua/blink/cmp/accept/text-edits.lua:89: index out of range
stack traceback:
	[C]: in function 'get_line_byte_from_position'
	...e/projects/blink.cmp/lua/blink/cmp/accept/text-edits.lua:89: in function 'get_from_item'
	.../projects/blink.cmp/lua/blink/cmp/windows/ghost-text.lua:68: in function 'draw_preview'
	.../projects/blink.cmp/lua/blink/cmp/windows/ghost-text.lua:53: in function 'show_preview'
	.../projects/blink.cmp/lua/blink/cmp/windows/ghost-text.lua:34: in function 'callback'
	...rojects/blink.cmp/lua/blink/cmp/windows/autocomplete.lua:283: in function 'emit_on_select'
	...rojects/blink.cmp/lua/blink/cmp/windows/autocomplete.lua:129: in function 'open_with_items'
	.../ibrahimdelice/projects/blink.cmp/lua/blink/cmp/init.lua:57: in function <.../ibrahimdelice/projects/blink.cmp/lua/blink/cmp/init.lua:51>

@eero-lehtinen
Copy link
Contributor Author

Ok. I have zero issues at least with rust-analyzer, but another solution is probably necessary.

@Saghen Saghen merged commit a2f6cfb into Saghen:main Nov 12, 2024
@Saghen
Copy link
Owner

Saghen commented Nov 12, 2024

Thanks! I believe I found the root cause to be from the offset applied to text edits. I'd like to avoid the pcall if possible so I'll leave it out for now, but if you're still running into errors, I'll take a second look

@eero-lehtinen
Copy link
Contributor Author

Seems to work 👍

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.

ghost text: invalid 'col' out of range
3 participants