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
No consistent way to execute a callback function upon acceptance of a Completer item #16294
Comments
Do you want to track acceptance of suggestions from your Provider (I'm assuming that you have one), or from all providers? Currently I think panelHandlers should remain implementation detail, but there could be a high level signal which would proxy Selected from all widgets. |
I only need it for my own provider, I'm fine with any command or signal that I can connect to, there just isn't one at the moment, so I figured surfacing the existing one was the easiest. |
@krassowski If we don't surface |
What do you think? |
I'm not against the idea, but while digging into the idea I did think of a middle ground. An accessor on
This would also give a generic signal, rather than specific to a provider, but I think that's a better implementation. If you don't like this idea I can work on the registerProvider return idea, it felt like a lot of code would need to change to surface the signal to that interface and keep it up to date. I have a general idea of an implementation for the registerProvider return and a pretty detailed one for the signal proxy implementation. I could most likely have a PR for the latter this week, the former would have to wait a bit for my bandwidth to free up to work on it. |
Problem
When accepting a item in the InlineCompleter you can connect a callback function to the
inline-completer:accept
command, but in the case of the Completer, the various equivalent commandscompleter:select-notebook
,completer:select-file
, andcompleter:select-console
are not always executed when accepting an item.The
Completer
class has a private Signal_selected
that is triggered in the code in four places:selectActive()
function which is connected to the various commands listed aboveThis means that there is no way to connect a callback function to cases 2-4 since the command is not executed and the signal triggered is private.
Proposed Solution
The most straight forward solution I see is finding a way to surface the private
_selected
Signal, this is already possible to do where the Completer class is accessible via theselected()
function, but there is no current access of a Completer class to extensions. All calls to Completer instances are done via the private_panelHandlers
Map in theCompletionProviderManager
which is not surfaced.If we create a accessor function to
_panelHandlers
, possibly a lookup method that with a widget id arg, to theCompletionProviderManager
then any extension can get the Completer for a given widget and add a connection to theselected
signal.Additional context
This is important to my use case because our Completer extension wants to track the metrics when users accept completion items.
This could be related to #15026, which would also solve this problem, but with a more complicated solution for this use case, trying the callback into the actual implementation of the insertText
The text was updated successfully, but these errors were encountered: