From 6df244d4294b33a72cdf24038db5002f9e421cf3 Mon Sep 17 00:00:00 2001 From: Daniel Marcotte Date: Wed, 25 Feb 2015 16:43:39 -0800 Subject: [PATCH] Fit what metadata we can into autocompletes The whole meta string currently gets dropped from the autocompletes popup if it doesn't fit. This leads to confusing autocompletes where the meta for some entries are missing for no apparent reason. So, instead of dropping the entire meta string when it doesn't fit, insert what we can and append "..." to communicate that we clipped it. --- lib/ace/autocomplete/popup.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ace/autocomplete/popup.js b/lib/ace/autocomplete/popup.js index 862a1c5e..b504357a 100644 --- a/lib/ace/autocomplete/popup.js +++ b/lib/ace/autocomplete/popup.js @@ -197,8 +197,12 @@ var AcePopup = function(parentNode) { if (data.meta) { var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth; - if (data.meta.length + data.caption.length < maxW - 2) - tokens.push({type: "rightAlignedText", value: data.meta}); + var metaData = data.meta; + if (metaData.length + data.caption.length > maxW - 2) { + // trim meta to fit this popup and add ellipsis + metaData = metaData.substr(0, maxW - data.caption.length - 5) + '...' + } + tokens.push({type: "rightAlignedText", value: metaData}); } return tokens; }; @@ -338,4 +342,4 @@ dom.importCssString("\ exports.AcePopup = AcePopup; -}); \ No newline at end of file +});