From fa0f4802afec544c313f4590825dd48400539440 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johann=20Kl=C3=A4hn?= Date: Tue, 7 Jan 2014 17:28:46 +0100 Subject: [PATCH 1/1] prevent ':' from indenting inside unfinished string --- indent/python.vim | 43 +++++++++++++++++++++----------------- spec/indent/indent_spec.rb | 19 +++++++++++++++++ spec/spec_helper.rb | 1 + 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/indent/python.vim b/indent/python.vim index 9b8e9b1..d86eabb 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -27,11 +27,10 @@ let s:block_rules = { let s:paren_pairs = ['()', '{}', '[]'] let s:control_statement = '^\s*\(if\|while\|with\|for\|except\)\>' let s:stop_statement = '^\s*\(break\|continue\|raise\|return\|pass\)\>' -if v:version >= 704 || (v:version == 703 && has('patch1037')) - let s:string_literal = '".\{-}\\\@1' + vim.echo('synIDattr(synID(line("."), col("."), 0), "name")' + ).downcase.should include 'string' + vim.feedkeys 'a\' + proposed_indent.should == 0 + indent.should == 0 + end + + it "does not dedent" do + vim.feedkeys 'iif True:\"test:\' + vim.echo('synIDattr(synID(line("."), col("."), 0), "name")' + ).downcase.should include 'string' + proposed_indent.should == shiftwidth + indent.should == shiftwidth + end + end + describe "when using simple control structures" do it "indents shiftwidth spaces" do vim.feedkeys 'iwhile True:\pass' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b1e82a1..022f65b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,6 +14,7 @@ Vimrunner::RSpec.configure do |config| # vim.add_plugin(plugin_path, 'indent/python.vim') vim.command "set rtp^=#{plugin_path}" + vim.command "runtime syntax/python.vim" vim.command "runtime indent/python.vim" vim -- 2.39.5