File tree Expand file tree Collapse file tree 2 files changed +23
-17
lines changed Expand file tree Collapse file tree 2 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -138,27 +138,21 @@ endfunction
138138" Find possible indent(s) of the block starter that matches the current line.
139139function ! s: find_start_of_block (lnum, types, multiple)
140140 let r = []
141- let types = copy (a: types )
142141 let re = ' \V\^\s\*\(' .join (a: types , ' \|' ).' \)\>'
143142 let lnum = a: lnum
144143 let last_indent = indent (lnum) + 1
145144 while lnum > 0 && last_indent > 0
146145 let indent = indent (lnum)
147146 if indent < last_indent
148- for type in types
149- let re = ' \v^\s*' .type .' >'
150- if getline (lnum) = ~# re
151- if ! a: multiple
152- return [indent ]
153- endif
154- if index (r , indent ) == -1
155- let r += [indent ]
156- endif
157- " Remove any handled type, e.g. 'if'.
158- call remove (types, index (types, type ))
147+ if getline (lnum) = ~# re
148+ if ! a: multiple
149+ return [indent ]
159150 endif
160- endfor
161- let last_indent = indent (lnum)
151+ if index (r , indent ) == -1
152+ let r += [indent ]
153+ endif
154+ let last_indent = indent
155+ endif
162156 endif
163157 let lnum = prevnonblank (lnum - 1 )
164158 endwhile
Original file line number Diff line number Diff line change 401401 end
402402
403403 describe "when an else is used inside of a nested if" do
404- before { vim . feedkeys 'iif foo:\<CR>\<TAB> if bar:\<CR>\<TAB>\<TAB >pass\<CR>' }
405- it "indents an else to the inner if" do
404+ before { vim . feedkeys 'iif foo:\<CR>if bar:\<CR>pass\<CR>' }
405+ it "indents the else to the inner if" do
406406 vim . feedkeys 'else:'
407- indent . should == shiftwidth * 2
407+ indent . should == shiftwidth
408+ end
409+ end
410+
411+ describe "when an else is used outside of a nested if" do
412+ before { vim . feedkeys 'iif True:\<CR>if True:\<CR>pass\<CR>\<Esc>0' }
413+ it "indents the else to the outer if" do
414+ indent . should == 0
415+ proposed_indent . should == shiftwidth
416+
417+ vim . feedkeys 'ielse:'
418+ indent . should == 0
419+ proposed_indent . should == 0
408420 end
409421 end
410422
You can’t perform that action at this time.
0 commit comments