Skip to content

Commit cfd604a

Browse files
committed
Fixed bug where multiline commands were always being expanded in history output.
Since the intention was to display their raw versions on 1 line in non-verbose mode, the code was rewritten to do so.
1 parent 5663d9f commit cfd604a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

cmd2/history.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,19 @@ def pr(self, script=False, expanded=False, verbose=False) -> str:
4848
if self.raw != self.expanded.rstrip():
4949
ret_str += self._ex_listformat.format(self.idx, self.expanded.rstrip())
5050
else:
51-
if script:
52-
# display without entry numbers
53-
if expanded or self.statement.multiline_command:
54-
ret_str = self.expanded.rstrip()
55-
else:
56-
ret_str = self.raw.rstrip()
51+
if expanded:
52+
ret_str = self.expanded.rstrip()
5753
else:
58-
# display a numbered list
59-
if expanded or self.statement.multiline_command:
60-
ret_str = self._listformat.format(self.idx, self.expanded.rstrip())
61-
else:
62-
ret_str = self._listformat.format(self.idx, self.raw.rstrip())
54+
ret_str = self.raw.rstrip()
55+
56+
# In non-verbose mode, display raw multiline commands on 1 line
57+
if self.statement.multiline_command:
58+
ret_str = ret_str.replace('\n', ' ')
59+
60+
# Display a numbered list if not writing to a script
61+
if not script:
62+
ret_str = self._listformat.format(self.idx, ret_str)
63+
6364
return ret_str
6465

6566

0 commit comments

Comments
 (0)