Skip to content

Commit

Permalink
Indent dictionary values on a new line extra
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Oct 6, 2016
1 parent 7dfebca commit be5bd7d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
10 changes: 7 additions & 3 deletions indent/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,14 @@ function! s:indent_like_opening_paren(lnum)
" indent further to distinguish the continuation line
" from the next logical line.
if text =~# b:control_statement && res == base + s:sw()
return base + s:sw() * 2
else
return res
let res = base + s:sw() * 2
endif

" If a colon is the final charactar on previous line
if getline(a:lnum-1) =~ ':\s*$'
let res = res + s:sw()
endif
return res
endfunction

" Match indent of first block of this type.
Expand Down
16 changes: 16 additions & 0 deletions spec/indent/indent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@
end
end

describe "after a dictionary key" do
before { vim.feedkeys 'imydict = {"12345": ' }

it "indents to opening paren + shiftwidth" do
vim.feedkeys '\<CR>'
indent.should == 10 + shiftwidth
end
it "on a new line indents to opening paren + shiftwidth" do
vim.feedkeys '123,\<CR>"4567": '
indent.should == 10
vim.feedkeys '\<CR>'
indent.should == 10 + shiftwidth
end
end


describe "when using gq to reindent a '(' that is" do
before { vim.feedkeys 'itest(' }
it "something and has a string without spaces at the end" do
Expand Down

0 comments on commit be5bd7d

Please sign in to comment.