Hi all, I am having a real hard time with an indeterminate bug in a
VIM function. First, here is the function:
set cul
hi CursorLine term=none cterm=none ctermbg=20
set nu
set statusline+=%{WhatFunctionAreWeIn()}
set laststatus=2
fun WhatFunctionAreWeIn()
let strList = ["while", "foreach", "ifelse", "if else", "for",
"if", "else", "try", "catch", "case"]
let foundcontrol = 1
let position = ""
normal mz
while (foundcontrol)
let foundcontrol = 0
normal [{
?\S
let tempchar = getline(".")[col(".") - 1]
if (match(tempchar, ")") >=0 )
normal %
?\S
endif
let tempstring = getline(".")
for item in strList
if( match(tempstring,item) >= 0 )
let position = item . " - " . position
let foundcontrol = 1
break
endif
endfor
if(foundcontrol == 0)
normal `z
return tempstring.position
endif
endwhile
normal `z
return tempstring.position
endfun
This function displays the current PHP function name in the status
bar. It is derived from this gem:
http://vim.wikia.com/wiki/VimTip1296
Both the original function from the VIM wiki and my derived version
suffer an indeterminate bug. Sometimes when scrolling down with J the
cursor will "jump" to the wrong location. When this happens one can
simply `z to bring the cursor back to where it should be. I would say
that about one line in every 100 lines of PHP that I have triggers the
bug.
Here is the interesting bit. My home Kubuntu machine and a Debian
virtual machine trigger the bug in different places in the same file!
A CentOS server that I have access to trigger the bug in yet different
places from the first two! This is with an identical file and
identical .vimrc configurations. The VIM versions are likely slightly
different, but they are all 7.X.
I originally asked the question on Stack Overflow before I discovered
that each system triggers the bug in different places. Here is the
Stack Overflow question:
http://stackoverflow.com/questions/9728199/why-does-this-function-skip-on-line-63#comment12370266_9728199
If anybody could take a look and advice me on how to fix the bug I
would much appreciate it. Thanks!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php