All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
5 before(:each) { vim.normal 'gg"_dG' } # clear buffer
7 describe "when using the indent plugin" do
8 it "sets the indentexpr and indentkeys options" do
9 vim.command("set indentexpr?").should include "GetPythonPEPIndent("
10 vim.command("set indentkeys?").should include "=elif"
13 it "sets autoindent and expandtab" do
14 vim.command("set autoindent?").should match(/\s*autoindent/)
15 vim.command("set expandtab?").should match(/\s*expandtab/)
19 describe "when entering the first line" do
20 before { vim.feedkeys 'ipass' }
22 it "does not indent" do
23 proposed_indent.should == 0
27 it "does not indent when using '=='" do
33 describe "when after a '(' that is at the end of its line" do
34 before { vim.feedkeys 'itest(\<CR>' }
36 it "indents by one level" do
37 proposed_indent.should == shiftwidth
38 vim.feedkeys 'something'
39 indent.should == shiftwidth
41 indent.should == shiftwidth
44 it "puts the closing parenthesis at the same level" do
50 describe "when after an '(' that is followed by something" do
51 before { vim.feedkeys 'itest(something,\<CR>' }
53 it "lines up on following lines" do
55 vim.feedkeys 'more,\<CR>'
59 it "lines up the closing parenthesis" do
64 it "does not touch the closing parenthesis if it is already indented further" do
70 describe "when using simple control structures" do
71 it "indents shiftwidth spaces" do
72 vim.feedkeys 'iwhile True:\<CR>pass'
73 indent.should == shiftwidth
77 describe "when a line breaks with a manual '\\'" do
78 it "indents shiftwidth spaces on normal line" do
79 vim.feedkeys 'ivalue = test + \\\\\<CR>'
80 indent.should == shiftwidth
83 it "indents 2x shiftwidth spaces for control structures" do
84 vim.feedkeys 'iif somevalue == xyz and \\\\\<CR>'
85 indent.should == shiftwidth * 2
88 it "indents relative to line above" do
89 vim.feedkeys 'i\tvalue = test + \\\\\<CR>'
90 indent.should == shiftwidth * 2
94 describe "when current line is dedented compared to previous line" do
95 before { vim.feedkeys 'i\<TAB>\<TAB>if x:\<CR>return True\<CR>\<ESC>' }
96 it "and current line has a valid indentation (Part 1)" do
97 vim.feedkeys '0i\<TAB>if y:'
98 proposed_indent.should == -1
101 it "and current line has a valid indentation (Part 2)" do
102 vim.feedkeys '0i\<TAB>\<TAB>if y:'
103 proposed_indent.should == -1
106 it "and current line has an invalid indentation" do
107 vim.feedkeys 'i while True:\<CR>'
108 indent.should == previous_indent + shiftwidth
113 @shiftwidth ||= vim.echo("exists('*shiftwidth') ? shiftwidth() : &sw").to_i
116 @tabstop ||= vim.echo("&tabstop").to_i
119 vim.echo("indent('.')").to_i
122 pline = vim.echo("line('.')").to_i - 1
123 vim.echo("indent('#{pline}')").to_i
126 line = vim.echo("line('.')")
127 col = vim.echo("col('.')")
128 indent_value = vim.echo("GetPythonPEPIndent(line('.'))").to_i
129 vim.command("call cursor(#{line}, #{col})")