diff options
author | Bram Moolenaar <Bram@vim.org> | 2004-07-26 12:53:41 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2004-07-26 12:53:41 +0000 |
commit | 5eb86f91992f5291b8b472d3e1be1888508777e6 (patch) | |
tree | 15dcd4c748c38e99951e79d02eb1b93f3a6d3db9 /runtime/indent/python.vim | |
parent | 89cb5e0f646970371359c70927bf3a0cdaf47f27 (diff) | |
download | vim-git-5eb86f91992f5291b8b472d3e1be1888508777e6.tar.gz |
updated for version 7.0012v7.0012
Diffstat (limited to 'runtime/indent/python.vim')
-rw-r--r-- | runtime/indent/python.vim | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/runtime/indent/python.vim b/runtime/indent/python.vim index 3c030f8d8..b5a0849f9 100644 --- a/runtime/indent/python.vim +++ b/runtime/indent/python.vim @@ -2,7 +2,7 @@ " Language: Python " Maintainer: Bram Moolenaar <Bram@vim.org> " Original Author: David Bustos <bustos@caltech.edu> -" Last Change: 2004 Jun 15 +" Last Change: 2004 Jul 25 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -99,15 +99,36 @@ function GetPythonIndent(lnum) " Use syntax highlighting attributes when possible. let pline = getline(plnum) let pline_len = strlen(pline) - let col = 0 - while col < pline_len - if pline[col] == '#' && (!has('syntax_items') - \ || synIDattr(synID(plnum, col + 1, 1), "name") =~ "Comment$") - let pline = strpart(pline, 0, col) - break + if has('syntax_items') + " If the last character in the line is a comment, do a binary search for + " the start of the comment. synID() is slow, a linear search would take + " too long on a long line. + if synIDattr(synID(plnum, pline_len, 1), "name") =~ "Comment$" + let min = 1 + let max = pline_len + while min < max + let col = (min + max) / 2 + if synIDattr(synID(plnum, col, 1), "name") =~ "Comment$" + let max = col + else + let min = col + 1 + endif + endwhile + echomsg min + let pline = strpart(pline, 0, min - 1) + echomsg pline + sleep 1 endif - let col = col + 1 - endwhile + else + let col = 0 + while col < pline_len + if pline[col] == '#' + let pline = strpart(pline, 0, col) + break + endif + let col = col + 1 + endwhile + endif " If the previous line ended with a colon, indent this line if pline =~ ':\s*$' |