Skip to content

Commit

Permalink
Make autocomplete popup only as wide as the biggest suggestion, refs #3
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Aug 11, 2017
1 parent fc05068 commit 14dc85a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,6 @@ JanewayClass.setMethod(function popup(id, options) {
list = this.blessed.list({
//bottom: 2,
position: options.position,
width: '100%',
items: options.items,
mouse: true, // Allow selecting items with the mouse
scrollbar: this.config.popup.scrollbar,
Expand Down Expand Up @@ -942,6 +941,7 @@ JanewayClass.setMethod(function autocomplete(cmd, key) {
var pieces,
target,
hidden,
width,
items,
item,
last,
Expand Down Expand Up @@ -999,8 +999,23 @@ JanewayClass.setMethod(function autocomplete(cmd, key) {
}
}

width = 0;

for (i = 0; i < items.length; i++) {
if (items[i] && items[i].length > width) {
width = items[i].length;
}
}

if (cmd.trim() && items.length) {
list = this.popup('autocomplete', {position: {left: left, height: this.config.autocomplete.height}, items: items});
list = this.popup('autocomplete', {
position: {
left : left,
height : this.config.autocomplete.height,
width : width + 4
},
items : items
});
} else {
list = this.popup('autocomplete', false);
}
Expand Down

0 comments on commit 14dc85a

Please sign in to comment.