Open ajaygera opened 7 months ago
I encountered the same problem.
In earlier versions:
always show toolbar
is false
, clicking accept word will trigger provideInlineCompletionItems
, context.triggerKind
is Automatic
, then I return undefined
and the suggestion code will still exist;always show toolbar
is specified as true
, clicking accept word
will trigger provideInlineCompletionItems
, and context.triggerKind
is Invoke
. In this case, undefined
will be returned and the suggestion code will not exist. So in this case I returned the rest of the code;In the current version:
always show toolbar
is specified as true
, context.triggerKind
is Automatic
, the returned undefined
suggestion code will not existType: Bug
VS Code version: Code 1.88.0 (5c3e652f63e798a5ac2f31ffd0d863669328dc4c, 2024-04-03T13:26:18.741Z) OS version: Windows_NT x64 10.0.22631 Modes:
This issue exists on latest vscode version 1.88. Can anyone help in resolving this issue?
Does this issue occur when all extensions are disabled?: Yes/No
Steps to Reproduce: 1) In vscode editor (for our extension), we need to show some text on user action (lets say on clicking some context menu). After displaying the text, User can insert entire text or insert the text word by word or line by line. The text which needs to be displayed and inserted would be fetched on clicking context menu and can be passed to vscode provider. 2) We need to show the text in new line after the end of the statement rather than at current cursor position In order to achieve both requirements we have used vscode.InlineCompletionItemProvider. i have found vscode.InlineCompletionItemProvider does not fulfill both requirements completely and we are facing below issues 1)Accept word and Accept Line does not work on Windows for vscode version later than 1.86.2. On vscode version later than 1.86.2, On clicking Accept word only first word gets inserted and after that inline suggest toolbar gets disappears. 2)Accept word and Accept Line does not work on mac for any vscode version. On clicking Accept word only first word gets inserted and after that inline suggest toolbar gets disappears. 3)Text is shown at current cursor position rather than at the end of statement.
I have also raised above issues on threads https://github.com/microsoft/vscode/issues/207414 and https://github.com/microsoft/vscode/issues/207753 but did not get resolution yet
I was wondering do we need to implement any other provider or i am using the provider in wrong way(particularly related to range) or is their any bug with vscode?
Below is the code snippet. ( please note, inlineCompletionitemProvider.pos is the current position of cursor which does not change after we trigger command - editor.action.inlineSuggest.trigger
class inlineCompletionitemProvider implements vscode.InlineCompletionItemProvider { public static hint:string = ""; public static pos:vscode.Position; public static range:vscode.Range; provideInlineCompletionItems(document: vscode.TextDocument, position: vscode.Position, context: vscode.InlineCompletionContext, token: vscode.CancellationToken): vscode.ProviderResult<vscode.InlineCompletionItem[] | vscode.InlineCompletionList> { if (context.triggerKind == vscode.InlineCompletionTriggerKind.Invoke) { let vscodeRange:vscode.Range = new vscode.Range(inlineCompletionitemProvider.pos,position); let item: vscode.InlineCompletionItem = new vscode.InlineCompletionItem(
${inlineCompletionitemProvider.hint}
,vscodeRange); return [item]; } else{ return []; } } }//code snippet to explicit trigger inline hint provider and display them private onResult = async () => { oracleInlineCompletionitemProvider.hint = "testing accept word"; oracleInlineCompletionitemProvider.pos = activeTextEditor.selection.active; // this is cuurent cursor position. hints would be displayed at this position await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger');
}