fixed line wrapping issue in descriptions

master
Gregory Scheerlinck 8 years ago
parent 5b11118ec3
commit d00d29feac

@ -59,6 +59,8 @@ function selectArticle(articles, lang, searchTerms, isDeep, isApro, englishArtic
return b.lastrevid - a.lastrevid;
});
var tWidth = (/chinese|korean|japanese/gi.test(lang)) ? 30 : 60;
if (len === 0) {
if (lang === 'english') {
return reject('No articles match your query.');
@ -69,8 +71,8 @@ function selectArticle(articles, lang, searchTerms, isDeep, isApro, englishArtic
return resolve(sorted[0]);
} else {
choices = sorted.map(function makeChoices(article, index) {
entry = ['[', chalk.yellow(index + 1), '/', chalk.yellow(len), '] ', chalk.green(article.title), ': ', chalk.gray(article.description).slice(0, 150)].join('');
return (article.description.length < 150) ? entry : entry + '...';
entry = ['[', chalk.yellow(index + 1), '/', chalk.yellow(len), '] ', chalk.green(article.title), ': ', chalk.gray(article.description).substr(0, tWidth)].join('').replace('\n', '');
return (article.description.length + article.title.length < tWidth) ? entry : entry + '...';
});
inquirer.prompt([{

Loading…
Cancel
Save