Skip to content

Commit

Permalink
Recalculate number of columns after lines
Browse files Browse the repository at this point in the history
Prevents the situation where (eg) 9 completion candidates are split 6/3
instead of 5/4 and subsequent columns calculations are incorrect.

Fixes #191
  • Loading branch information
tpoliaw committed Nov 30, 2017
1 parent 4b9e3e7 commit ed016da
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4487,8 +4487,10 @@ else if (items instanceof List) {
while (c > 1 && c * maxWidth + (c - 1) * MARGIN_BETWEEN_COLUMNS >= width) {
c--;
}
int columns = c;
int lines = (candidates.size() + columns - 1) / columns;
int lines = (candidates.size() + c - 1) / c;
// Try to minimize the number of columns for the given number of rows
// Prevents eg 9 candiates being split 6/3 instead of 5/4.
final int columns = (candidates.size() + lines - 1) / lines;
IntBinaryOperator index;
if (isSet(Option.LIST_ROWS_FIRST)) {
index = (i, j) -> i * columns + j;
Expand Down

0 comments on commit ed016da

Please sign in to comment.