Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// const [cwd] = atom.project.relativizePath(file)
options.cwd = path.dirname(file) //cwd
try {
const stringWithACToken = insertAutocompleteToken(currentContents, line, col)
const result = await promisedExec(that.cmdString, args, options, stringWithACToken)
if (!result || !result.length) {
return []
}
// If it is just whitespace and punctuation, ignore it (this keeps us
// from eating leading dots).
const replacementPrefix = /^[\s.]*$/.test(prefix) ? '' : prefix
const candidates = result.map(item => processAutocompleteItem(replacementPrefix, item))
// return candidates
return filter(candidates, replacementPrefix, { key: 'displayText' })
} catch (e) {
const errorM: string = String(e).toLowerCase()
if ( errorM.includes('rechecking')
|| errorM.includes('launching')
|| errorM.includes('processing')
|| errorM.includes('starting')
|| errorM.includes('spawned')
|| errorM.includes('logs')
|| errorM.includes('initializing')
) {
return []
}
console.log('[autocomplete-flow] ERROR:', e)
return []
}
}
export function getFilteredItems(args: { items: T[], textify: (item: T) => string, filterValue: string }): T[] {
// Store the items for each text value
let textValueToItems: { [text: string]: T[] } = Object.create(null);
args.items.forEach((item) => {
let text = args.textify(item);
if (!textValueToItems[text]) textValueToItems[text] = [];
textValueToItems[text].push(item);
})
// Get the unique text values
let textValues = Object.keys(utils.createMap(args.items.map(args.textify)));
// filter them
let filteredTextValues = fuzzyFilter(textValues, args.filterValue);
return utils.selectMany(filteredTextValues.map((textvalue) => textValueToItems[textvalue]));
}
function getFuzzySuggestions(data, prefix, key, suffix) {
return filter(data, prefix, {key: key}).map(function(elm) {
let cloned = Object.assign({}, elm);
if (suffix && !/_$/.test(elm.text)) {
cloned.displayText = elm.text;
cloned.text += suffix;
}
cloned.replacementPrefix = prefix;
return cloned;
});
}
this.connection.onWorkspaceSymbol(async(params) => {
const analysis =
await this.analyzer.analyzePackage({reason: 'get workspace symbols'});
const symbols = this.findSymbols(analysis);
return fuzzaldrin.filter(symbols, params.query, {key: 'name'});
});
description: "search box placeholder"
})}
fullWidth
/>
<hr>
{filter(countries, data.query, {
key: "country"
}).map(country => {
const isChecked = countrySelectionMap[country.code];
return (
{country.country}
{filter(countries, data.query, {
key: "country"
}).map(country => {
const isChecked = countrySelectionMap[country.code];
return (
{country.country}
placeholder={i18n.t("Search by country name", {
context: "country search input placeholder"
})}
fullWidth
/>
<hr>
{i18n.t("Countries A to Z", {
context: "country selection"
})}
{filter(countries, data.query, {
key: "country"
}).map(country => {
const isChecked = countrySelectionMap[country.code];
return (
{country.country}
<table>
</table>
export const search = text => {
const matchedLangs = filter(languages, text, { key: 'name' })
return matchedLangs
.map(({ name }) => getModeFromName(name))
.filter(lang => !!lang)
}
const getIcon = title => {
loadIcons();
const processNameMatches = title.match(processNameRegex);
let processName = 'shell';
if (
Array.isArray(processNameMatches) &&
processNameMatches[processNameMatch]
) processName = processNameMatches[processNameMatch];
const results = filter(classes, processName, { maxResults: 1 });
const match = results.length === 0 ? 'shell' : results[0];
return { class: icons[match], name: match };
};
getSuggestions ({ editor, bufferPosition }) {
const prefix = this.getPrefix(editor, bufferPosition)
if (!prefix) return []
const matches = fuzzaldrin(api, prefix, { key: 'name' })
if (!matches.length) return []
return matches.map(method => {
const name = method.name
return copy(this.methodCache[name] = (
this.methodCache[name] || this.getMethodSuggestion(method)
))
})
}