-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Add a callback function for the Accept button of inline suggestion toolbar #198721
Comments
You can set a command which is then called. |
@hediet Thank you for replying! I am not sure if I understood your answer correctly. handleDidPartiallyAcceptCompletionItem(completionItem: vscode.InlineCompletionItem, acceptedLength: number): void {
console.log('handleDidPartiallyAcceptCompletionItem');
}, Then, how can I add a command for "full" accept event? (i.e., event for the Accept button was clicked) |
there is a command propert yon the inline completion item itself |
@hediet I see. Thank you for the answer. For those who need explanation, here is the main part of the code for handling the accept event using the property on the inline completion item. export function activate(context: vscode.ExtensionContext) {
function handleAccept() {
console.log("Accepted");
}
vscode.commands.registerCommand('accept.command1', handleAccept);
const provider: vscode.InlineCompletionItemProvider = {
async provideInlineCompletionItems(document, position, context, token) {
const result: vscode.InlineCompletionList = {
items: [],
commands: [],
};
// TODO: make suggestion text, position_range, and completeBracketPairs
result.items.push({
insertText: text,
range: position_range,
completeBracketPairs,
command: {command: 'accept.command1', title: 'my title'},
});
return result
}
}; |
dont forget to unregister your temporary commands! |
Inline Suggestion Toolbar
Current Feature
vscode/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts
Lines 42 to 56 in 620340c
When we click "Accept Word" of the inline suggestion toolbar,
the function
handleDidPartiallyAcceptCompletionItem
is calledso that we can handle the event for partially accepted suggestion.
For the "Accept" button, however, we don't have a corresponding function.
New Feature
Can we add a function that is called when an inline completion item was fully accepted by the "Accept" button of the inline suggestion toolbar?
The function would look like as follows:
The text was updated successfully, but these errors were encountered: