mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-18 18:03:19 +01:00
reduce usage of arrays#flatten util, use native flat instead
This commit is contained in:
@@ -7,7 +7,6 @@ import { isSafari } from 'vs/base/browser/browser';
|
||||
import { $, append, hide, show } from 'vs/base/browser/dom';
|
||||
import { IconLabel, IIconLabelValueOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
|
||||
import { IListRenderer } from 'vs/base/browser/ui/list/list';
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
import { Codicon, CSSIcon } from 'vs/base/common/codicons';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { createMatches } from 'vs/base/common/filters';
|
||||
@@ -190,10 +189,10 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
|
||||
// special logic for 'folder' completion items
|
||||
data.icon.className = 'icon hide';
|
||||
data.iconContainer.className = 'icon hide';
|
||||
labelOptions.extraClasses = flatten([
|
||||
labelOptions.extraClasses = [
|
||||
getIconClasses(this._modelService, this._languageService, URI.from({ scheme: 'fake', path: element.textLabel }), FileKind.FOLDER),
|
||||
getIconClasses(this._modelService, this._languageService, URI.from({ scheme: 'fake', path: completion.detail }), FileKind.FOLDER)
|
||||
]);
|
||||
].flat();
|
||||
} else {
|
||||
// normal icon
|
||||
data.icon.className = 'icon hide';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { flatten, isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { combinedDisposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -43,7 +43,7 @@ abstract class MainThreadKernel implements INotebookKernel {
|
||||
}
|
||||
|
||||
public get preloadProvides() {
|
||||
return flatten(this.preloads.map(p => p.provides));
|
||||
return this.preloads.map(p => p.provides).flat();
|
||||
}
|
||||
|
||||
constructor(data: INotebookKernelDto2, private _languageService: ILanguageService) {
|
||||
|
||||
+1
-2
@@ -3,7 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
import { disposableTimeout, Throttler } from 'vs/base/common/async';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -119,7 +118,7 @@ class CellStatusBarHelper extends Disposable {
|
||||
return;
|
||||
}
|
||||
|
||||
const items = flatten(itemLists.map(itemList => itemList.items));
|
||||
const items = itemLists.map(itemList => itemList.items).flat();
|
||||
const newIds = this._notebookViewModel.deltaCellStatusBarItems(this._currentItemIds, [{ handle: this._cell.handle, items }]);
|
||||
|
||||
this._currentItemLists.forEach(itemList => itemList.dispose && itemList.dispose());
|
||||
|
||||
@@ -23,7 +23,6 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { registerEditorAction, EditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { Progress } from 'vs/platform/progress/common/progress';
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
|
||||
|
||||
// format notebook
|
||||
@@ -91,7 +90,7 @@ registerAction2(class extends Action2 {
|
||||
return [];
|
||||
}));
|
||||
|
||||
await bulkEditService.apply(/* edit */flatten(allCellEdits), { label: localize('label', "Format Notebook"), code: 'undoredo.formatNotebook', });
|
||||
await bulkEditService.apply(/* edit */allCellEdits.flat(), { label: localize('label', "Format Notebook"), code: 'undoredo.formatNotebook', });
|
||||
|
||||
} finally {
|
||||
disposable.dispose();
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
import { Emitter, Event, PauseableEmitter } from 'vs/base/common/event';
|
||||
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
@@ -502,7 +501,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
|
||||
return [...otherEdits.reverse(), ...replaceEdits];
|
||||
});
|
||||
|
||||
const flattenEdits = flatten(edits);
|
||||
const flattenEdits = edits.flat();
|
||||
|
||||
for (const { edit, cellIndex } of flattenEdits) {
|
||||
switch (edit.editType) {
|
||||
|
||||
Reference in New Issue
Block a user