Skip to content

Commit d679f72

Browse files
committed
Fixed issue where input line was being saved before all of a multiline command had been fully read
1 parent 5635962 commit d679f72

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd2/cmd2.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,13 +1917,17 @@ def _input_line_to_statement(self, line: str) -> Statement:
19171917
:return: parsed command line as a Statement
19181918
"""
19191919
used_macros = []
1920-
orig_line = line
1920+
orig_line = None
19211921

19221922
# Continue until all macros are resolved
19231923
while True:
19241924
# Make sure all input has been read and convert it to a Statement
19251925
statement = self._complete_statement(line)
19261926

1927+
# Save the fully entered line if this is the first loop iteration
1928+
if orig_line is None:
1929+
orig_line = statement.raw
1930+
19271931
# Check if this command matches a macro and wasn't already processed to avoid an infinite loop
19281932
if statement.command in self.macros.keys() and statement.command not in used_macros:
19291933
used_macros.append(statement.command)
@@ -1934,7 +1938,7 @@ def _input_line_to_statement(self, line: str) -> Statement:
19341938
break
19351939

19361940
# This will be true when a macro was used
1937-
if not statement.multiline_command and orig_line != statement.raw:
1941+
if orig_line != statement.raw:
19381942
# Build a Statement that contains the resolved macro line
19391943
# but the originally typed line for its raw member.
19401944
statement = Statement(statement.args,

0 commit comments

Comments
 (0)