Permalink
Browse files

Merge pull request #1 from arnar/master~1

Two bugfixes
  • Loading branch information...
2 parents 3ee1061 + 87b485a commit 3f33a8776feeff3c0a2ccb2e5e39aa7c96da7cb9 @natw committed Mar 2, 2012
Showing with 12 additions and 14 deletions.
  1. +12 −14 ftplugin/python/pythontextobj.vim
@@ -75,34 +75,32 @@ function! s:NextIndent(start)
endwhile
return lastline
endfunction
-
+
function! s:StartDecorators(start)
- " get def/class start pos
- " move upwards, breaking on first line of different indent that doesn't
- " start w/ @
+ " Returns the line of the first decorator line above the starting line,
+ " counting only decorators with the same level.
exec a:start
normal ^
let def_indent = indent(line("."))
- let found = 0
- while (! found)
+ normal k
+ while (indent(line(".") == def_indent) && getline(".") =~ '\v^\s*\@')
normal k
- let ln = line(".")
- if (ln == 1)
- return ln
- endif
- if (indent(ln) != def_indent || getline(ln) =~ '\v^\s*[^@].+$')
- return line(".") + 1
- endif
endwhile
+ return line(".") + 1
endfunction
function! s:FindPythonObjectStart(obj)
" TODO: don't match definitions at equal or greater indent unless it matches
" at cursor position
let cursor_start_pos = line(".")
- let cursor_indent = indent(cursor_start_pos)
+ " Empty lines have the indentation of the previous non-empty line in python,
+ " so we skip backwards until we find one that is not empty
+ while (getline(".") =~ '^\s*$') && (line(".") > 1)
+ exec line(".") - 1
+ endwhile
+ let cursor_indent = indent(line("."))
if (a:obj == "class")
let objregexp = "^\\s*class\\s\\+[a-zA-Z0-9_]\\+"
\ . "\\s*\\((\\([a-zA-Z0-9_,. \\t\\n]\\)*)\\)\\=\\s*:"

0 comments on commit 3f33a87

Please sign in to comment.