lib/ripl/rc/multiline.rb in ripl-rc-0.2.1 vs lib/ripl/rc/multiline.rb in ripl-rc-0.2.2

- old
+ new

@@ -8,16 +8,17 @@ # test those: # ruby -e '"' # ruby -e '{' # ruby -e '[' # ruby -e '(' + # ruby -e '/' # ruby -e 'class C' # ruby -e 'def f' # ruby -e 'begin' ERROR_REGEXP = Regexp.new( - [ # string - "unterminated string meets end of file", + [ # string or regexp + "unterminated \\w+ meets end of file", # mri and rubinius "syntax error, unexpected \\$end", # rubinius "expecting '.+'( or '.+')*", # jruby @@ -49,11 +50,10 @@ def print_eval_error(e) return super if Multiline.disabled? if e.is_a?(SyntaxError) && e.message =~ ERROR_REGEXP @rc_multiline_buffer << @input if @rc_multiline_buffer.empty? - history.pop throw :rc_multiline_cont else super end end @@ -62,27 +62,22 @@ return super if Multiline.disabled? if @rc_multiline_buffer.empty? super else @rc_multiline_buffer << input - history.pop - history << "\n" + (str = @rc_multiline_buffer.join("\n")) - super str + super @rc_multiline_buffer.join("\n") end end def handle_interrupt return super if Multiline.disabled? if @rc_multiline_buffer.empty? super else line = @rc_multiline_buffer.pop - if @rc_multiline_buffer.empty? - super - else - puts "[removed this line: #{line}]" - throw :rc_multiline_cont - end + print "[removed this line: #{line}]" + super + throw :rc_multiline_cont end end end Ripl::Shell.include(Ripl::Rc::Multiline)