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

[VSCode] When a code completion is selected, automatically invoke import fix code action if possible #2965

Closed
Tracked by #2967
wsxiaoys opened this issue Aug 23, 2024 · 3 comments · Fixed by #3389
Closed
Tracked by #2967
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@wsxiaoys
Copy link
Member

wsxiaoys commented Aug 23, 2024

References: https://code.visualstudio.com/api/references/commands
image

Example:

const codeActions = await vscode.commands.executeCommand<vscode.CodeAction[]>(
    'vscode.executeCodeActionProvider',
    document.uri,
    range,
    vscode.CodeActionKind.QuickFix.value,
    7
  );
@wsxiaoys wsxiaoys added good first issue Good for newcomers enhancement New feature or request labels Aug 23, 2024
@shankarg87
Copy link
Contributor

can take a look if no-one is working on this

@shankarg87
Copy link
Contributor

Went through the code and a bit lost. Some follow up questions:

When a code completion is selected - Can you clarify you mean by this? Are you referring to the inlineCompletionTriggerMode, whenever the user triggers it ? Or do you mean once the user accepts the suggestion of the inline code completion. Trying to understand what the trigger for the code action is expected to be.

automatically invoke import fix code action - I see that the existing CodeProvider registers the CodeAction.RefactorRewrite CodeAction. This can be extended to CodeActionKind.QuickFix. Any thoughts on what the user workflow would look like for QuickFix? Would it also be inline editing (tabby.chat.edit.start) or are we looking for a new workflow.

Appreciate any pointers!

@wsxiaoys
Copy link
Member Author

When a code completion is selected - Can you clarify you mean by this? Are you referring to the inlineCompletionTriggerMode, whenever the user triggers it ? Or do you mean once the user accepts the suggestion of the inline code completion.

When I mentioned "When a code completion is selected," I specifically meant when the user accepts the suggestion of the inline code completion. This is the point at which the code completion is integrated into the user's code.

automatically invoke import fix code action - I see that the existing CodeProvider registers the CodeAction.RefactorRewrite CodeAction. This can be extended to CodeActionKind.QuickFix. Any thoughts on what the user workflow would look like for QuickFix?

The work need to be done here is:

  1. Verify if the generated code contains any quick fix action.

  2. If the action can be classified as import libraries, trigger the action (such actions is usually provided by an LSP implementation for that languages)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants