diff --git a/lib/adapters/autocomplete-adapter.ts b/lib/adapters/autocomplete-adapter.ts index bd9f024..fe0efc2 100644 --- a/lib/adapters/autocomplete-adapter.ts +++ b/lib/adapters/autocomplete-adapter.ts @@ -278,11 +278,11 @@ export default class AutocompleteAdapter { // // Returns a {Map} of AutoComplete+ suggestions ordered by the CompletionItems sortText. public completionItemsToSuggestions( - completionItems: CompletionItem[] | CompletionList, + completionItems: CompletionItem[] | CompletionList | null, request: ac.SuggestionsRequestedEvent, onDidConvertCompletionItem?: CompletionItemAdjuster, ): Map { - return new Map((Array.isArray(completionItems) ? completionItems : completionItems.items || []) + return new Map((Array.isArray(completionItems) ? completionItems : (completionItems && completionItems.items || [])) .sort((a, b) => (a.sortText || a.label).localeCompare(b.sortText || b.label)) .map<[ac.AnySuggestion, PossiblyResolvedCompletionItem]>( (s) => [ diff --git a/lib/languageclient.ts b/lib/languageclient.ts index 796596b..07a8d54 100644 --- a/lib/languageclient.ts +++ b/lib/languageclient.ts @@ -241,7 +241,7 @@ export class LanguageClientConnection extends EventEmitter { // Returns a {Promise} containing either a {CompletionList} or an {Array} of {CompletionItem}s. public completion( params: lsp.TextDocumentPositionParams | CompletionParams, - cancellationToken?: jsonrpc.CancellationToken): Promise { + cancellationToken?: jsonrpc.CancellationToken): Promise { // Cancel prior request if necessary return this._sendRequest('textDocument/completion', params, cancellationToken); }