diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-14 16:43:24 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-14 16:43:24 -0400 |
commit | 3329e5fec21f2cc4479bb3358170e2226885ab3b (patch) | |
tree | 5322eb484ee332ac2e11ff37ea2a1fa36694a668 /cmd2/cmd2.py | |
parent | cfd604a04a326ddfc833106e2cfa0ad210760fc8 (diff) | |
download | cmd2-git-3329e5fec21f2cc4479bb3358170e2226885ab3b.tar.gz |
Adding individual lines of commands to readline history to match how it was entered
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index a36fdbf3..a11b0f29 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -3503,11 +3503,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 |