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

Add optional command to onAutoInsert response #7073

Merged
merged 1 commit into from
May 8, 2024

Conversation

mgoertz-msft
Copy link
Collaborator

The response item for this message is currently defined like this:

export interface OnAutoInsertResponseItem {
    _vs_textEditFormat: lsp.InsertTextFormat;
    _vs_textEdit: lsp.TextEdit;
}

The purpose of this message is similar to inserting completions. However, it's lacking one thing that completion items provide - the ability to provide an optional command to retrigger completions for example.

This is especially useful for markup languages like XAML where you would use = as a trigger character to automatically insert the attribute quotes and place the caret in between, so that you would end up with this ="|". The expectation though is to offer completions for attribute values at this point, but there is currently no way to automatically trigger completions. This is made even more painful in VS Code where the default editor setting does not even trigger completions within strings.

I propose the following addition to the response item in the same way it exists for CompletionItem, which should be ignorable by any client that does not support the optional parameter:

export interface OnAutoInsertResponseItem {
    _vs_textEditFormat: lsp.InsertTextFormat;
    _vs_textEdit: lsp.TextEdit;
    /**
     * An optional command that is executed *after* inserting.
     */
    command?: Command;
}

I have a local prototype for the vscode-csharp extension that works just beautifully like this.

@mgoertz-msft mgoertz-msft requested a review from a team as a code owner April 26, 2024 17:33
@dibarbet dibarbet merged commit cc599a7 into dotnet:main May 8, 2024
13 checks passed
dibarbet added a commit to dibarbet/vscode-csharp that referenced this pull request May 8, 2024
…rtcommand

Add optional command to onAutoInsert response
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