Replace !isFalsyOrEmpty with isNonEmptyArray

This new call works as a type guard and can help avoid writing double negations

Avoid either call in cases where we were iterating over the possibly undefined value. Use `|| []` for these
This commit is contained in:
Matt Bierner
2018-11-14 16:06:13 -08:00
parent 8392c36a49
commit 30b2a5fd94
16 changed files with 41 additions and 51 deletions

View File

@@ -19,7 +19,7 @@ import { MainContext, MainThreadLanguageFeaturesShape, ExtHostLanguageFeaturesSh
import { regExpLeadsToEndlessLoop } from 'vs/base/common/strings';
import { IPosition } from 'vs/editor/common/core/position';
import { IRange, Range as EditorRange } from 'vs/editor/common/core/range';
import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import { isFalsyOrEmpty, isNonEmptyArray } from 'vs/base/common/arrays';
import { isObject } from 'vs/base/common/types';
import { ISelection, Selection } from 'vs/editor/common/core/selection';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
@@ -433,7 +433,7 @@ class NavigateTypeAdapter {
provideWorkspaceSymbols(search: string, token: CancellationToken): Thenable<WorkspaceSymbolsDto> {
const result: WorkspaceSymbolsDto = IdObject.mixin({ symbols: [] });
return asThenable(() => this._provider.provideWorkspaceSymbols(search, token)).then(value => {
if (!isFalsyOrEmpty(value)) {
if (isNonEmptyArray(value)) {
for (const item of value) {
if (!item) {
// drop