diff --git a/package.json b/package.json index a6f74c99d..3fb6aa482 100644 --- a/package.json +++ b/package.json @@ -2156,4 +2156,4 @@ } ] } -} +} \ No newline at end of file diff --git a/src/features/completionItemProvider.ts b/src/features/completionItemProvider.ts index 925b8156d..0119c2c38 100644 --- a/src/features/completionItemProvider.ts +++ b/src/features/completionItemProvider.ts @@ -10,7 +10,7 @@ import AbstractSupport from './abstractProvider'; import * as protocol from '../omnisharp/protocol'; import * as serverUtils from '../omnisharp/utils'; import {createRequest} from '../omnisharp/typeConvertion'; -import {CompletionItemProvider, CompletionItem, CompletionItemKind, CancellationToken, TextDocument, Range, Position, CompletionList} from 'vscode'; +import {CompletionItemProvider, CompletionItem, CompletionItemKind, CompletionContext, CompletionTriggerKind, CancellationToken, TextDocument, Range, Position, CompletionList} from 'vscode'; export default class OmniSharpCompletionItemProvider extends AbstractSupport implements CompletionItemProvider { @@ -25,7 +25,7 @@ export default class OmniSharpCompletionItemProvider extends AbstractSupport imp ';', '+', '-', '*', '/', '%', '&', '|', '^', '!', '~', '=', '<', '>', '?', '@', '#', '\'', '\"', '\\']; - public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Promise { + public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken, context: CompletionContext): Promise { let wordToComplete = ''; let range = document.getWordRangeAtPosition(position); @@ -38,6 +38,10 @@ export default class OmniSharpCompletionItemProvider extends AbstractSupport imp req.WantDocumentationForEveryCompletionResult = true; req.WantKind = true; req.WantReturnType = true; + if (context.triggerKind == CompletionTriggerKind.TriggerCharacter) + { + req.TriggerCharacter = context.triggerCharacter; + } return serverUtils.autoComplete(this._server, req).then(responses => { diff --git a/src/omnisharp/extension.ts b/src/omnisharp/extension.ts index f1df05371..012edf2ab 100644 --- a/src/omnisharp/extension.ts +++ b/src/omnisharp/extension.ts @@ -66,7 +66,7 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe localDisposables.push(vscode.languages.registerDocumentRangeFormattingEditProvider(documentSelector, new FormatProvider(server, reporter))); localDisposables.push(vscode.languages.registerOnTypeFormattingEditProvider(documentSelector, new FormatProvider(server, reporter), '}', ';')); } - localDisposables.push(vscode.languages.registerCompletionItemProvider(documentSelector, new CompletionItemProvider(server, reporter), '.')); + localDisposables.push(vscode.languages.registerCompletionItemProvider(documentSelector, new CompletionItemProvider(server, reporter), '.', ' ')); localDisposables.push(vscode.languages.registerWorkspaceSymbolProvider(new WorkspaceSymbolProvider(server, reporter))); localDisposables.push(vscode.languages.registerSignatureHelpProvider(documentSelector, new SignatureHelpProvider(server, reporter), '(', ',')); const codeActionProvider = new CodeActionProvider(server, reporter); diff --git a/src/omnisharp/protocol.ts b/src/omnisharp/protocol.ts index 3c877a288..d46161c8a 100644 --- a/src/omnisharp/protocol.ts +++ b/src/omnisharp/protocol.ts @@ -256,6 +256,7 @@ export interface AutoCompleteRequest extends Request { WantSnippet?: boolean; WantReturnType?: boolean; WantKind?: boolean; + TriggerCharacter?: string; } export interface AutoCompleteResponse {