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

Better handling of text-edits at completion #858

Merged
merged 1 commit into from
Aug 6, 2019
Merged

Better handling of text-edits at completion #858

merged 1 commit into from
Aug 6, 2019

Conversation

dimbleby
Copy link
Contributor

@dimbleby dimbleby commented Aug 1, 2019

The current implementation calls undo, but unless you happened to break the undo sequence before starting the completion - unlikely in regular typing - this will go very wrong:

  • it'll undo more than just the insertion of the unwanted word (potentially a lot more)
  • and having done that, it'll perform the text edit in the wrong place in the document

The approach here is borrowed from https://github.com/prabirshrestha/vim-lsp/blob/master/autoload/lsp/omni.vim#L321

  • assume that the text edit is taking place at the completion point
  • tweak that text edit so that it removes the now-unwanted completion

cf #662, #857 (comment)

//
// Check that we're not doing anything stupid before going ahead with this.
let mut edit = edit.clone();
edit.range.end.character =
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is smart!

I will test a bit more before merging this in.

@autozimu autozimu merged commit d5e28db into autozimu:next Aug 6, 2019
@autozimu
Copy link
Owner

autozimu commented Aug 6, 2019

Thanks!

@dimbleby dimbleby deleted the better-text-edit-completion branch August 6, 2019 15:29
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