summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 02462d96..8f5a7abe 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1913,13 +1913,17 @@ class Cmd(cmd.Cmd):
:return: parsed command line as a Statement
"""
used_macros = []
- orig_line = line
+ orig_line = None
# Continue until all macros are resolved
while True:
# Make sure all input has been read and convert it to a Statement
statement = self._complete_statement(line)
+ # Save the fully entered line if this is the first loop iteration
+ if orig_line is None:
+ orig_line = statement.raw
+
# Check if this command matches a macro and wasn't already processed to avoid an infinite loop
if statement.command in self.macros.keys() and statement.command not in used_macros:
used_macros.append(statement.command)
@@ -3483,11 +3487,13 @@ class Cmd(cmd.Cmd):
if rl_type != RlType.NONE:
last = None
for item in history:
- # readline only adds a single entry for multiple sequential identical commands
- # so we emulate that behavior here
- if item.raw != last:
- readline.add_history(item.raw)
- last = item.raw
+ # Break the command into its individual lines
+ for line in item.raw.splitlines():
+ # readline only adds a single entry for multiple sequential identical lines
+ # so we emulate that behavior here
+ if line != last:
+ readline.add_history(line)
+ last = line
# register a function to write history at save
# if the history file is in plain text format from 0.9.12 or lower