Skip to content

Commit 7339962

Browse files
committed
Fix bug in history command
It output double newlines after each history item
1 parent 20d7520 commit 7339962

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

cmd2.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,10 +2022,12 @@ def parsed(self, raw):
20222022
class HistoryItem(str):
20232023
"""Class used to represent an item in the History list.
20242024
2025-
Thing wrapper around str class which adds a custom format for printing. It also keeps track of its index in the
2026-
list as well as a lowercase representation of itself for convenience/efficiency.
2025+
Thin wrapper around str class which adds a custom format for printing. It
2026+
also keeps track of its index in the list as well as a lowercase
2027+
representation of itself for convenience/efficiency.
2028+
20272029
"""
2028-
listformat = '-------------------------[%d]\n%s\n'
2030+
listformat = '-------------------------[{}]\n{}\n'
20292031

20302032
# noinspection PyUnusedLocal
20312033
def __init__(self, instr):
@@ -2038,7 +2040,7 @@ def pr(self):
20382040
20392041
:return: str - pretty print string version of a HistoryItem
20402042
"""
2041-
return self.listformat % (self.idx, str(self))
2043+
return self.listformat.format(self.idx, str(self).rstrip())
20422044

20432045

20442046
class History(list):

0 commit comments

Comments
 (0)