Answer a question

There're two built-in commands for showing "inline suggestion":

  • editor.action.inlineSuggest.showPrevious
  • editor.action.inlineSuggest.showNext

I've tried both, but nothing happened, in what circumstance could an inline suggestion be triggered?

Answers

For v1.58, see Inline Suggestions:

Inline Suggestions

The inline suggestions API allows extensions to provide inline suggestions that are decoupled from the suggestion widget. An inline suggestion is rendered as if it was already accepted, but with a gray color. Users can cycle through suggestions and accept them with the Tab key.

vscode.languages.registerInlineCompletionItemProvider(
  { pattern: '**' },
  {
    provideInlineCompletionItems: async (document, position) => {
      return [{ text: '< 2) {\n\treturn 1;\n\t}' }]
    },
  },
)

Demo:

enter image description here

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐