I’m writing some UI that has third party components and I would like to be able to accept a completion at a specfic index (ie. accept completion n# 7).
but this doesn’t seem to work very well, since the acceptCompletion call is working on the old version of view. (it does work some of the time which is weird).
I would like to call insertCompletionText but I don’t have enough information about the completions (like the from and to parameters) to pass to that command.
I’m using currentCompletions and selectedCompletionIndex to render the completions in a completely different part of the document. Users can click them or use keyboard shortcuts to select them.
I could switch to selectedCompletion but that won’t resolve my issue since I still can’t access the autocomplete internal state to get the active completion source associated with the completion.
I see. I tried out your code, and it seems to work for me. view is a mutable object that is updated synchronously by the call to dispatch, so there’s not really a way to call anything on an old version of it. Though if you have transaction filters active that mess with that kind of transaction I guess you could have a situation where that doesn’t work, but that seems unlikely to be the case.