Refactor history deduplication

We don't need to know the absolute index. We also fix the IndexError.
GSoC/Meterpreter_Web_Console
William Vu 2018-08-05 14:22:59 -05:00
parent fce19cf5b8
commit a0962855bd
1 changed files with 4 additions and 2 deletions

View File

@ -168,8 +168,10 @@ begin
end
if add_history && line
index = ::Readline::HISTORY.length - 1
RbReadline.add_history(line) if not (line == ::Readline::HISTORY[index])
# Don't add duplicate lines to history
if ::Readline::HISTORY.empty? || line != ::Readline::HISTORY[-1]
RbReadline.add_history(line)
end
end
line.try(:dup)