Skip to content

Commit

Permalink
Improve/fix indent with closing parenthesis (#129)
Browse files Browse the repository at this point in the history
Fixes #126
  • Loading branch information
blueyed authored May 13, 2019
1 parent 784f6cc commit b3a7395
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
7 changes: 6 additions & 1 deletion indent/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,12 @@ function! s:indent_like_opening_paren(lnum)
if starts_with_closing_paren && !hang_closing
let res = base
else
return base + s:sw()
let res = base + s:sw()

" Special case for parenthesis.
if text[paren_col-1] ==# '(' && getline(a:lnum) !~# '\v\)\s*:?\s*$'
return res
endif
endif
else
" Indent to match position of opening paren.
Expand Down
17 changes: 16 additions & 1 deletion spec/indent/indent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,24 @@
end

describe "when using a function definition" do
it "indents shiftwidth spaces" do
it "handles indent with closing parenthesis on same line" do
vim.feedkeys 'idef long_function_name(\<CR>arg'
indent.should == shiftwidth
vim.feedkeys '):'
indent.should == shiftwidth * 2
end

it "handles indent with closing parenthesis on new line" do
vim.feedkeys 'idef long_function_name(\<CR>arg'
indent.should == shiftwidth
vim.feedkeys '\<CR>'
indent.should == shiftwidth
vim.feedkeys ')'
indent.should == (hang_closing ? shiftwidth * 2 : 0)
vim.feedkeys ':'
indent.should == (hang_closing ? shiftwidth * 2 : 0)
vim.feedkeys '\<Esc>k'
indent.should == shiftwidth
end
end

Expand Down

0 comments on commit b3a7395

Please sign in to comment.