util: Compute the size of the split properly for vertical splits

This commit is contained in:
Tomas Babej 2015-03-21 14:38:22 +01:00
parent 97698b2162
commit 7cbc7d1f0a

View file

@ -88,8 +88,14 @@ def selected_line_numbers():
return range(vim.current.range.start, vim.current.range.end + 1)
def show_in_split(lines, size=None, position="belowright", vertical=False):
# Compute the size of the split
if size is None:
size = len(lines)
if vertical:
# Maximum number of columns used + small offset
size = max([len(l) for l in lines]) + 5
else:
# Number of lines
size = len(lines)
# Call 'vsplit' for vertical, otherwise 'split'
vertical_prefix = 'v' if vertical else ''