microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.5k stars 28.65k forks source link

Extensions can provide hover UI for inline completion #169336

Closed justinmk3 closed 1 year ago

justinmk3 commented 1 year ago

From https://github.com/microsoft/vscode/issues/165988#issuecomment-1349679114 :

Problem

Currently (afaik) there is no way for mutliple inline-suggestions extensions to behave in a cooperative manner. So for example, plugins like GitHub Copilot shows a Open GitHub Copilot label in the inline-suggestions hover affordance, even with other plugins (such as AWS Toolkit) are actively providing suggestions:

image

AWS Toolkit provides suggestions from CodeWhisperer. To do so,

  1. we implement vscode.InlineCompletionItemProvider.
  2. we also override "editor.action.inlinesuggest.shownext" and related commands when CodeWhisperer is providing suggestions so that the inline suggestion popup Next and Previous buttons provide CodeWhisperer suggestions.

@alexdima @hediet is there a better way for vscode extensions to provide inline suggestions without conflicting with other inline suggestions extensions?

As a workaround, old versions of AWS Toolkit temporarily disabled the editor.hover.enabled setting. But that is a fragile workaround (which reduces functionality) and causes issues like https://github.com/microsoft/vscode/issues/165988 .

We've since removed that workaround. But now on mouse-hover, users that have installed GitHub Copilot will see a popup with a Open GitHub Copilot button (while CodeWhisperer is providing suggestions), which is very confusing.

Expected behavior

Extensions that provide inline suggestions should be able to co-exist and not conflict with each other. If extension A is providing suggestions, it should be able to provide the inline-suggestions UI without conflict from other extensions.

Alternatively, similar to LSP, inline-suggestions could be "merged", and then multiple extensions would provide buttons on the inline-suggestions hover UI.

Related

hediet commented 1 year ago

Why did you need to disable next/previous? They should cycle through the merged list of all provided inline completions.

justinmk3 commented 1 year ago

Why did you need to disable next/previous? They should cycle through the merged list of all provided inline completions.

That was only a workaround to avoid the confusing experience of the Open Github Copilot label being presented during CodeWhisperer-provided suggestions.

hediet commented 1 year ago

@jrieken do you have ideas here?

jrieken commented 1 year ago

How about only showing InlineCompletionList#commands items when showing an item from that list, but not for other lists?

hediet commented 1 year ago

Verification steps:

Playground link

Depending on which item you select, you either get "Foo" or "Bar". Notice that the context menu is currently broken in the monaco editor (but not in VS Code).

Oym7w2trL2