summaryrefslogtreecommitdiff
path: root/cmd2/history.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-14 15:54:32 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-14 15:54:32 -0400
commitcfd604a04a326ddfc833106e2cfa0ad210760fc8 (patch)
treee0680795a4ce561c3962ba9be1497ffd59f30c0a /cmd2/history.py
parent5663d9faa6ae057b42129d9fecc68c7bb4485586 (diff)
downloadcmd2-git-cfd604a04a326ddfc833106e2cfa0ad210760fc8.tar.gz
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.
Diffstat (limited to 'cmd2/history.py')
-rw-r--r--cmd2/history.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/cmd2/history.py b/cmd2/history.py
index 7ec4ce7b..0f47d542 100644
--- a/cmd2/history.py
+++ b/cmd2/history.py
@@ -48,18 +48,19 @@ class HistoryItem():
if self.raw != self.expanded.rstrip():
ret_str += self._ex_listformat.format(self.idx, self.expanded.rstrip())
else:
- if script:
- # display without entry numbers
- if expanded or self.statement.multiline_command:
- ret_str = self.expanded.rstrip()
- else:
- ret_str = self.raw.rstrip()
+ if expanded:
+ ret_str = self.expanded.rstrip()
else:
- # display a numbered list
- if expanded or self.statement.multiline_command:
- ret_str = self._listformat.format(self.idx, self.expanded.rstrip())
- else:
- ret_str = self._listformat.format(self.idx, self.raw.rstrip())
+ ret_str = self.raw.rstrip()
+
+ # In non-verbose mode, display raw multiline commands on 1 line
+ if self.statement.multiline_command:
+ ret_str = ret_str.replace('\n', ' ')
+
+ # Display a numbered list if not writing to a script
+ if not script:
+ ret_str = self._listformat.format(self.idx, ret_str)
+
return ret_str