Skip to content

Commit

Permalink
Merge pull request #1 from arnar/master~1
Browse files Browse the repository at this point in the history
Two bugfixes
  • Loading branch information
natw committed Mar 2, 2012
2 parents 3ee1061 + 87b485a commit 3f33a87
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions ftplugin/python/pythontextobj.vim
Expand Up @@ -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*:"
Expand Down

0 comments on commit 3f33a87

Please sign in to comment.