Skip to content
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

fix(auto-insert): restore content of context instead of undo #953

Closed
wants to merge 1 commit into from

Conversation

xzbdmw
Copy link
Contributor

@xzbdmw xzbdmw commented Jan 8, 2025

fix #942
fix #810

Described in #942 (comment), this pr removes the preview_undo field and make the auto_insert stateless.

@xzbdmw xzbdmw force-pushed the auto-insert branch 2 times, most recently from 091b3ce to f9d4b20 Compare January 8, 2025 18:34
@xzbdmw xzbdmw marked this pull request as draft January 8, 2025 18:38
@xzbdmw xzbdmw marked this pull request as ready for review January 8, 2025 18:41
@xzbdmw
Copy link
Contributor Author

xzbdmw commented Jan 8, 2025

Blink has the same issue with nvim-cmp when used with mini.snippets, but should not related to this pr, I'd open a new one.

@xzbdmw xzbdmw marked this pull request as draft January 8, 2025 18:45
@xzbdmw
Copy link
Contributor Author

xzbdmw commented Jan 8, 2025

I feel this function is unnecessary (keep it a blank body also fix these two issues), we already handles text_edits smartly, it says TODO: doesnt work when the item contains characters not included in the context regex, but I have not find a condition this guess fails.

This pr sort of emulate the restore functionality by deleting chars until list.context.bounds.start_col

@xzbdmw xzbdmw marked this pull request as ready for review January 8, 2025 20:10
@Saghen
Copy link
Owner

Saghen commented Jan 9, 2025

This is a cool idea, I'd love for this to be stateless! Unfortunately though, it's not enough to use the start_col of the bounds since the edit range of the text edit may not equal those bounds. I believe the most correct solution is still to undo the text edit explicitly, there's a few bugs remaining in this approach though

@Saghen Saghen closed this Jan 9, 2025
@xzbdmw
Copy link
Contributor Author

xzbdmw commented Jan 9, 2025

Yeah you are right, they are not always match, nvim-cmp has a function to compute the offset when cycling completion list with auto-insert based on TextEdit and the offset when request was sent (source_offset). So what it does is to delete from cursor col until this offset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants