Skip to content

Commit 3329e5f

Browse files
committed
Adding individual lines of commands to readline history to match how it was entered
1 parent cfd604a commit 3329e5f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cmd2/cmd2.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3503,11 +3503,13 @@ def _initialize_history(self, hist_file):
35033503
if rl_type != RlType.NONE:
35043504
last = None
35053505
for item in history:
3506-
# readline only adds a single entry for multiple sequential identical commands
3507-
# so we emulate that behavior here
3508-
if item.raw != last:
3509-
readline.add_history(item.raw)
3510-
last = item.raw
3506+
# Break the command into its individual lines
3507+
for line in item.raw.splitlines():
3508+
# readline only adds a single entry for multiple sequential identical lines
3509+
# so we emulate that behavior here
3510+
if line != last:
3511+
readline.add_history(line)
3512+
last = line
35113513

35123514
# register a function to write history at save
35133515
# if the history file is in plain text format from 0.9.12 or lower

0 commit comments

Comments
 (0)