From d00d29feac68353cba9913b935a279a787472871 Mon Sep 17 00:00:00 2001 From: Gregory Scheerlinck Date: Tue, 16 Feb 2016 03:25:14 +0000 Subject: [PATCH] fixed line wrapping issue in descriptions --- lib/find.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/find.js b/lib/find.js index 1287aed..887a45d 100644 --- a/lib/find.js +++ b/lib/find.js @@ -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([{