Skip to content

Commit 7d4ddee

Browse files
committed
"fix" problem with long docstring display. i.e. it doesn't crash anymore,
hooray
1 parent 230875f commit 7d4ddee

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bpython/cli.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,8 @@ def lsize():
825825
if self.docstring is None:
826826
self.list_win.resize(rows + 2, w)
827827
else:
828-
docstring = self.format_docstring(self.docstring, max_w - 2)
828+
docstring = self.format_docstring(self.docstring, max_w - 2,
829+
max_h - height_offset)
829830
docstring_string = ''.join(docstring)
830831
rows = len(docstring) - 1
831832
self.list_win.resize(rows + 3, max_w)
@@ -869,17 +870,21 @@ def lsize():
869870
self.scr.move(*self.scr.getyx())
870871
self.list_win.refresh()
871872

872-
def format_docstring(self, docstring, width):
873+
def format_docstring(self, docstring, width, height):
873874
"""Take a string and try to format it into a sane list of strings to be
874875
put into the suggestion box."""
875876

876877
lines = docstring.split('\n')
877878
out = []
879+
i = 0
878880
for line in lines:
879881
out.append('\n')
882+
i += 1
880883
for block in textwrap.wrap(line, width):
881884
out.append(' ' + block)
882-
w = self.scr.getmaxyx()[1]
885+
if i >= height:
886+
return out
887+
i += 1
883888
return out
884889

885890
def mkargspec(self, topline, down):

0 commit comments

Comments
 (0)