X Tutup
Skip to content

Commit c0f29ce

Browse files
committed
Fix displaying of docstrings.
1 parent 3640beb commit c0f29ce

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bpython/cli.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,8 @@ def lsize():
878878
docstring = self.format_docstring(self.docstring, max_w - 2,
879879
max_h - height_offset)
880880
docstring_string = ''.join(docstring)
881-
rows = len(docstring) - 1
882-
self.list_win.resize(rows + 3, max_w)
881+
rows += len(docstring)
882+
self.list_win.resize(rows, max_w)
883883

884884
if down:
885885
self.list_win.mvwin(y + 1, 0)
@@ -898,7 +898,7 @@ def lsize():
898898
self.list_win.addstr('\n ')
899899

900900
if self.docstring is not None:
901-
self.list_win.addstr(docstring_string, get_colpair('comment'))
901+
self.list_win.addstr('\n' + docstring_string, get_colpair('comment'))
902902
# XXX: After all the trouble I had with sizing the list box (I'm not very good
903903
# at that type of thing) I decided to do this bit of tidying up here just to
904904
# make sure there's no unnececessary blank lines, it makes things look nicer.
@@ -928,13 +928,16 @@ def format_docstring(self, docstring, width, height):
928928
out = []
929929
i = 0
930930
for line in lines:
931-
out.append('\n')
932931
i += 1
932+
if not line.strip():
933+
out.append('\n')
933934
for block in textwrap.wrap(line, width):
934-
out.append(' ' + block)
935+
out.append(' ' + block + '\n')
935936
if i >= height:
936937
return out
937938
i += 1
939+
# Drop the last newline
940+
out[-1] = out[-1].rstrip()
938941
return out
939942

940943
def mkargspec(self, topline, down):

0 commit comments

Comments
 (0)
X Tutup