mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Use flatten array helper
This commit is contained in:
@@ -81,8 +81,10 @@ export default class LinkProvider implements vscode.DocumentLinkProvider {
|
||||
const base = document.uri.scheme === 'file' ? path.dirname(document.uri.fsPath) : '';
|
||||
const text = document.getText();
|
||||
|
||||
return this.providerInlineLinks(text, document, base)
|
||||
.concat(this.provideReferenceLinks(text, document, base));
|
||||
return [
|
||||
...this.providerInlineLinks(text, document, base),
|
||||
...this.provideReferenceLinks(text, document, base)
|
||||
];
|
||||
}
|
||||
|
||||
private providerInlineLinks(
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Token } from 'markdown-it';
|
||||
import * as vscode from 'vscode';
|
||||
import { MarkdownEngine } from '../markdownEngine';
|
||||
import { TableOfContentsProvider } from '../tableOfContentsProvider';
|
||||
import { flatten } from '../util/arrays';
|
||||
|
||||
const rangeLimit = 5000;
|
||||
|
||||
@@ -53,7 +54,7 @@ export default class MarkdownFoldingProvider implements vscode.FoldingRangeProvi
|
||||
this.getRegions(document),
|
||||
this.getHeaderFoldingRanges(document),
|
||||
this.getBlockFoldingRanges(document)]);
|
||||
return ([] as vscode.FoldingRange[]).concat.apply([], foldables).slice(0, rangeLimit);
|
||||
return flatten(foldables).slice(0, rangeLimit);
|
||||
}
|
||||
|
||||
private async getHeaderFoldingRanges(document: vscode.TextDocument) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { isMarkdownFile } from '../util/file';
|
||||
import { Lazy, lazy } from '../util/lazy';
|
||||
import MDDocumentSymbolProvider from './documentSymbolProvider';
|
||||
import { SkinnyTextDocument } from '../tableOfContentsProvider';
|
||||
import { flatten } from '../util/arrays';
|
||||
|
||||
export interface WorkspaceMarkdownDocumentProvider {
|
||||
getAllMarkdownDocuments(): Thenable<Iterable<SkinnyTextDocument>>;
|
||||
@@ -108,7 +109,7 @@ export default class MarkdownWorkspaceSymbolProvider extends Disposable implemen
|
||||
}
|
||||
|
||||
const allSymbolsSets = await Promise.all(Array.from(this._symbolCache.values()).map(x => x.value));
|
||||
const allSymbols: vscode.SymbolInformation[] = Array.prototype.concat.apply([], allSymbolsSets);
|
||||
const allSymbols = flatten(allSymbolsSets);
|
||||
return allSymbols.filter(symbolInformation => symbolInformation.name.toLowerCase().indexOf(query.toLowerCase()) !== -1);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,3 +16,7 @@ export function equals<T>(one: ReadonlyArray<T>, other: ReadonlyArray<T>, itemEq
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function flatten<T>(arr: ReadonlyArray<T>[]): T[] {
|
||||
return ([] as T[]).concat.apply([], arr);
|
||||
}
|
||||
Reference in New Issue
Block a user