+ describe "when inside an unfinished string" do
+ it "does not indent" do
+ vim.feedkeys 'i"test:\<ESC>'
+ vim.echo('synIDattr(synID(line("."), col("."), 0), "name")'
+ ).downcase.should include 'string'
+ vim.feedkeys 'a\<CR>'
+ proposed_indent.should == -1
+ indent.should == 0
+ end
+
+ it "does not dedent" do
+ vim.feedkeys 'iif True:\<CR>"test:\<ESC>'
+ vim.echo('synIDattr(synID(line("."), col("."), 0), "name")'
+ ).downcase.should include 'string'
+ proposed_indent.should == shiftwidth
+ indent.should == shiftwidth
+ end
+ end
+
+ describe "when the previous line has a colon in a string" do
+ before { vim.feedkeys 'itest(":".join(["1","2"]))\<CR>' }
+ it "does not indent" do
+ vim.feedkeys 'if True:'
+ indent.should == 0
+ proposed_indent.should == 0
+ end
+ end
+
+ describe "when the previous line has a list slice" do
+ it "does not indent" do
+ vim.feedkeys 'ib = a[2:]\<CR>'
+ indent.should == 0
+ proposed_indent.should == 0
+ end
+ end
+
+ describe "when line is empty inside a block" do
+ it "is indented like the previous line" do
+ vim.feedkeys 'idef a():\<CR>1\<CR>\<CR>2\<ESC>kcc'
+ indent.should == shiftwidth
+ end
+ end
+
+ describe "when an empty line is after empty line / before non-empty" do
+ it "is indented like the next line" do
+ vim.feedkeys 'idef a():\<CR>1\<CR>\<CR>\<CR>2\<ESC><<kcc'
+ indent.should == 0
+ end
+ end
+
+ describe "when an empty line is after empty line / before non-empty (nested)" do
+ it "is indented like the next line" do
+ vim.feedkeys 'idef a():\<CR>1\<CR>\<CR>\<CR>\<ESC>0i\<TAB>2\<ESC>kcc'
+ indent.should == shiftwidth
+ end
+ end
+
+ describe "when line is empty inside a block following multi-line statement" do
+ it "is indented like the previous line" do
+ vim.feedkeys 'idef a():\<CR>x = (1 +\<CR>2)\<CR>\<CR>y\<ESC>kcc'
+ indent.should == shiftwidth
+ end
+ end
+
+ describe "when line is empty inside a block following stop statement" do
+ it "is indented like the previous line minus shiftwidth" do
+ vim.feedkeys 'iif x:\<CR>if y:\<CR>pass\<CR>\<CR>z\<ESC>kcc'
+ indent.should == shiftwidth
+ end
+ end
+