resolving vscode thenable



vscode Thenable is a promise, we just need to return a promised of a type, as illustrated in code below :-



class CodeCompletionItemProvider implements CompletionItemProvider {
public provideCompletionItems(
document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Thenable<vscode.CompletionItem[]> {

             let linePrefix = document.lineAt(position).text.substr(0, position.character);
             if (linePrefix.endsWith('std.')) {
                console.log('great stuff!!!!');

                // returning thenable //
                return new Promise<vscode.CompletionItem[]>((resolve, reject) => {
                const dockerRunTask = new vscode.CompletionItem('crapRun');
                dockerRunTask.insertText = new vscode.SnippetString('\n{\n\t"task": "dockerRunTask", \n\t"desc": "${1}"\n}');
                    resolve([dockerRunTask]);
                });
             }
             return undefined
}
}

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm