Skip to content

Commit c7e3227

Browse files
authored
Do not save consecutive duplicate commands to history (#1120)
* Do not save consecutive duplicate commands to history * Cast Readline/Reline history to array to support older versions
1 parent f711800 commit c7e3227

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/irb/input-method.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def gets
223223
Readline.input = @stdin
224224
Readline.output = @stdout
225225
if l = Readline.readline(@prompt, false)
226-
Readline::HISTORY.push(l) if !l.empty?
226+
Readline::HISTORY.push(l) if !l.empty? && l != Readline::HISTORY.to_a.last
227227
@line[@line_no += 1] = l + "\n"
228228
else
229229
@eof = true
@@ -480,7 +480,7 @@ def gets
480480
Reline.prompt_proc = @prompt_proc
481481
Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
482482
if l = Reline.readmultiline(@prompt, false, &@check_termination_proc)
483-
Reline::HISTORY.push(l) if !l.empty?
483+
Reline::HISTORY.push(l) if !l.empty? && l != Reline::HISTORY.to_a.last
484484
@line[@line_no += 1] = l + "\n"
485485
else
486486
@eof = true

0 commit comments

Comments
 (0)