From: LeoMao Date: Sun, 21 Jul 2013 13:33:11 +0000 (+0800) Subject: Indent correctly after lines with '#'s in strings X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/31a2fd4cf80abba74dc3ef9fb0ceed8b540d2a1c?ds=sidebyside;hp=--cc Indent correctly after lines with '#'s in strings Fixes #5. --- 31a2fd4cf80abba74dc3ef9fb0ceed8b540d2a1c diff --git a/indent/python.vim b/indent/python.vim index c632c7b..4d1edc2 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -3,7 +3,6 @@ " Maintainer: Hynek Schlawack " Prev Maintainer: Eric Mc Sween (address invalid) " Original Author: David Bustos (address invalid) -" Last Change: 2012-06-21 " License: Public Domain " Only load this indent file when no other was loaded. @@ -176,6 +175,12 @@ function! GetPythonPEPIndent(lnum) " If the previous line ended with a colon and is not a comment, indent " relative to statement start. + let pline = substitute(pline, '\\\\', '', 'g') + if v:version > 703 || (v:version == 703 && has('patch1037')) + let pline = substitute(pline, '".\{-}\\\@1pass' + indent.should == shiftwidth + end + end + + describe "when '#' is not contained in a string and is followed by a colon" do + it "does not indent" do + vim.feedkeys 'iif "some#thing" == "test"#:test\' + indent.should == 0 + end + end + describe "when using simple control structures" do it "indents shiftwidth spaces" do vim.feedkeys 'iwhile True:\pass'