lib/rib/extra/autoindent.rb in rib-1.2.5 vs lib/rib/extra/autoindent.rb in rib-1.2.6

- old
+ new

@@ -22,25 +22,25 @@ # rescue E=>e # rescue E # rescue E => e # rescue E=> e # rescue E =>e - /^begin$/ => /^(end)\b|^else$|^rescue *((\w+)? *(=> *\w+)?)?$/, + /^begin$/ => /^(end)\b|^else$|^rescue *((\w+)? *(=> *\w+)?)?$/, # elsif Expression # consider cases: # elsif(true) # elsif true # elsif true == true # elsif (a = true) && false - /^if/ => /^(end)\b|^else$|^elsif\b/, - /^unless/ => /^(end)\b|^else$|^elsif\b/, - /^case/ => /^(end)\b|^when\b/ , - /^def/ => /^(end)\b/ , - /^class/ => /^(end)\b/ , - /^module/ => /^(end)\b/ , - /^while/ => /^(end)\b/ , - /^until/ => /^(end)\b/ , + /^if\b/ => /^(end)\b|^else$|^elsif\b/, + /^unless\b/ => /^(end)\b|^else$|^elsif\b/, + /^case\b/ => /^(end)\b|^else$|when\b/ , + /^def\b/ => /^(end)\b/ , + /^class\b/ => /^(end)\b/ , + /^module\b/ => /^(end)\b/ , + /^while\b/ => /^(end)\b/ , + /^until\b/ => /^(end)\b/ , # consider cases: # 'do # ' do # "' do # /do @@ -86,15 +86,11 @@ def eval_input raw_input return super if Autoindent.disabled? input = raw_input.strip indent = detect_autoindent(input) - result, err = if indent.first.to_s.start_with?('left') - super(handle_last_line(input)) - else - super - end + result, err = super handle_autoindent(input, indent, err) [result, err] end # --------------- Plugin API --------------- @@ -126,9 +122,10 @@ end end when :left_end # we need to go back # could happen in either multiline or not + handle_last_line(input) autoindent_stack.pop when :left_tmp # temporarily go back handle_last_line(input) if multiline?(err) end