<commit_before>import {expandHistoricalDirectory} from "../../shell/Command";
import {styles, Suggestion, directoriesSuggestionsProvider} from "./Common";
import * as _ from "lodash";
import {PluginManager} from "../../PluginManager";

PluginManager.registerAutocompletionProvider("cd", async(context) => {
    let suggestions: Suggestion[] = [];

    /**
     * Historical directories.
     */
    if (context.argument.value.startsWith("-")) {
        const historicalDirectoryAliases = _.take(["-", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9"], context.historicalPresentDirectoriesStack.size)
            .map(alias => new Suggestion().withValue(alias).withDescription(expandHistoricalDirectory(alias, context.historicalPresentDirectoriesStack)).withStyle(styles.directory));

        suggestions.push(...historicalDirectoryAliases);
    }

    suggestions.push(...await directoriesSuggestionsProvider(context));

    if (context.argument.value.length > 0) {
        const cdpathDirectories = _.flatten(await Promise.all(context.environment.cdpath
            .filter(directory => directory !== context.environment.pwd)
            .map(async(directory) => (await directoriesSuggestionsProvider(context, directory)).map(suggestion => suggestion.withDescription(`In ${directory}`)))));

        suggestions.push(...cdpathDirectories);
    }

    return suggestions;
});<commit_msg>Use slice instead of take.<commit_after>import {expandHistoricalDirectory} from "../../shell/Command";
import {styles, Suggestion, directoriesSuggestionsProvider} from "./Common";
import * as _ from "lodash";
import {PluginManager} from "../../PluginManager";

PluginManager.registerAutocompletionProvider("cd", async(context) => {
    let suggestions: Suggestion[] = [];

    /**
     * Historical directories.
     */
    if (context.argument.value.startsWith("-")) {
        const historicalDirectoryAliases = ["-", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9"]
            .slice(0, context.historicalPresentDirectoriesStack.size)
            .map(alias => new Suggestion().withValue(alias).withDescription(expandHistoricalDirectory(alias, context.historicalPresentDirectoriesStack)).withStyle(styles.directory));

        suggestions.push(...historicalDirectoryAliases);
    }

    suggestions.push(...await directoriesSuggestionsProvider(context));

    if (context.argument.value.length > 0) {
        const cdpathDirectories = _.flatten(await Promise.all(context.environment.cdpath
            .filter(directory => directory !== context.environment.pwd)
            .map(async(directory) => (await directoriesSuggestionsProvider(context, directory)).map(suggestion => suggestion.withDescription(`In ${directory}`)))));

        suggestions.push(...cdpathDirectories);
    }

    return suggestions;
});
{'fraction_non_alphanumeric': 0.15838398283875582, 'fraction_numerical': 0.006792992491955667, 'mean_word_length': 4.023339317773788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7547017', 'n_tokens_mistral': 757, 'n_tokens_neox': 735, 'n_words': 134}