File tree 2 files changed +23
-17
lines changed
2 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -138,27 +138,21 @@ endfunction
138
138
" Find possible indent(s) of the block starter that matches the current line.
139
139
function ! s: find_start_of_block (lnum, types, multiple)
140
140
let r = []
141
- let types = copy (a: types )
142
141
let re = ' \V\^\s\*\(' .join (a: types , ' \|' ).' \)\>'
143
142
let lnum = a: lnum
144
143
let last_indent = indent (lnum) + 1
145
144
while lnum > 0 && last_indent > 0
146
145
let indent = indent (lnum)
147
146
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 ]
159
150
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
162
156
endif
163
157
let lnum = prevnonblank (lnum - 1 )
164
158
endwhile
Original file line number Diff line number Diff line change 401
401
end
402
402
403
403
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
406
406
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
408
420
end
409
421
end
410
422
You can’t perform that action at this time.
0 commit comments