diff options
Diffstat (limited to 'lib/irb/ext/history.rb')
-rw-r--r-- | lib/irb/ext/history.rb | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb index 3239c57a6c..d991f4d33b 100644 --- a/lib/irb/ext/history.rb +++ b/lib/irb/ext/history.rb @@ -21,10 +21,10 @@ module IRB # :nodoc: def set_last_value(value) _set_last_value(value) -# @workspace.evaluate self, "_ = IRB.CurrentContext.last_value" + # @workspace.evaluate self, "_ = IRB.CurrentContext.last_value" if @eval_history #and !@eval_history_values.equal?(llv) - @eval_history_values.push @line_no, @last_value - @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}" + @eval_history_values.push @line_no, @last_value + @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}" end @last_value @@ -43,16 +43,16 @@ module IRB # :nodoc: # If +no+ is +nil+, execution result history isn't used (default). def eval_history=(no) if no - if defined?(@eval_history) && @eval_history - @eval_history_values.size(no) - else - @eval_history_values = History.new(no) - IRB.conf[:__TMP__EHV__] = @eval_history_values - @workspace.evaluate(self, "__ = IRB.conf[:__TMP__EHV__]") - IRB.conf.delete(:__TMP_EHV__) - end + if defined?(@eval_history) && @eval_history + @eval_history_values.size(no) + else + @eval_history_values = History.new(no) + IRB.conf[:__TMP__EHV__] = @eval_history_values + @workspace.evaluate(self, "__ = IRB.conf[:__TMP__EHV__]") + IRB.conf.delete(:__TMP_EHV__) + end else - @eval_history_values = nil + @eval_history_values = nil end @eval_history = no end @@ -68,20 +68,20 @@ module IRB # :nodoc: def size(size) if size != 0 && size < @size - @contents = @contents[@size - size .. @size] + @contents = @contents[@size - size .. @size] end @size = size end def [](idx) begin - if idx >= 0 - @contents.find{|no, val| no == idx}[1] - else - @contents[idx][1] - end + if idx >= 0 + @contents.find{|no, val| no == idx}[1] + else + @contents[idx][1] + end rescue NameError - nil + nil end end @@ -94,22 +94,22 @@ module IRB # :nodoc: def inspect if @contents.empty? - return real_inspect + return real_inspect end unless (last = @contents.pop)[1].equal?(self) - @contents.push last - last = nil + @contents.push last + last = nil end str = @contents.collect{|no, val| - if val.equal?(self) - "#{no} ...self-history..." - else - "#{no} #{val.inspect}" - end + if val.equal?(self) + "#{no} ...self-history..." + else + "#{no} #{val.inspect}" + end }.join("\n") if str == "" - str = "Empty." + str = "Empty." end @contents.push last if last str |