unexpected screen redraw in complete function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

unexpected screen redraw in complete function

KKde
Hi dev,

I have written my own user defined complete function(written
completely in vim scripting only, no other lang's used). In complete
function, one part of code finds the line no of opening parenthesis of
a function.
I have used the below code to do that.

let line=1
while ( line != 0)
            let line = searchpair('(', '', ')', 'bW',
'synIDattr(synID(line("."), col("."), 1), "name") =~ "cComment"')
endwhile

The problem with the above code is searchpair function is very slow.
It takes 6-7 seconds to match the opening parenthesis (Note: opening
parenthesis not farther than 10-15 lines).

I posted in vim_use groups to find effective way of matching
parenthesis ( link :http://groups.google.co.in/group/vim_use/
browse_thread/thread/f44b76248fef00ce)

It was suggested that I use normal % command. Now time to find the
opening parenthesis is reduced to 0.1 sec. But the main problem here
is just before the popup of complete function shows up, screen
flickers a bit.  Sometimes the popup menu isn't showed or sometimes it
is showed at the wrong line other than the cursor. The behavior is
unpredictable. This is irritating me :(



First of all, why searchpair function is damn slow and normal %
command is faster.
And why screen flickers or cursor line is disturbed in complete
function? (as per help manual, the complete function is allowed to
move the cursor)
Can you please suggest what can be done here?

Thanks for your time and help.

Regards,
kkde



--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unexpected screen redraw in complete function

KKde

Hi,

Can someone please check on this??

Regards,
Kkde

--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unexpected screen redraw in complete function

Lech Lorens
On 9 July 2010 13:00, KKde <[hidden email]> wrote:
>
> Hi,
>
> Can someone please check on this??
>
> Regards,
> Kkde

Have you tried using winsaveview() before moving the cursor around and
then winrestview()?

--
Cheers,
Lech Lorens

--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unexpected screen redraw in complete function

KKde

>
> Have you tried using winsaveview() before moving the cursor around and
> then winrestview()?
>

As per the help manual (:he complete-functions)
"The function is allowed to move the cursor, it is restored
afterwards.  This
option cannot be set from a |modeline| or in the |sandbox|, for
security
reasons."

so wouldn't it be the job of 'complete functions' to restore the
cursor?

Regards,
Kkde

--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unexpected screen redraw in complete function

KKde



> > Have you tried using winsaveview() before moving the cursor around and
> > then winrestview()?
>
> As per the help manual (:he complete-functions)
> "The function is allowed to move the cursor, it is restored
> afterwards.  This
> option cannot be set from a |modeline| or in the |sandbox|, for
> security
> reasons."
>
> so wouldn't it be the job of 'complete functions' to restore the
> cursor?
>

Can someone please help on this??

Regards,
Kkde

--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unexpected screen redraw in complete function

KKde
Can someone please help on this?

Regards,
Kkde

--
You received this message from the "vim_dev" 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unexpected screen redraw in complete function

James Vega-3
In reply to this post by KKde
On Thu, Jul 8, 2010 at 12:00 PM, KKde <[hidden email]> wrote:

> I have written my own user defined complete function(written
> completely in vim scripting only, no other lang's used). In complete
> function, one part of code finds the line no of opening parenthesis of
> a function.
> I have used the below code to do that.
>
> let line=1
> while ( line != 0)
>            let line = searchpair('(', '', ')', 'bW',
> 'synIDattr(synID(line("."), col("."), 1), "name") =~ "cComment"')
> endwhile
>
> The problem with the above code is searchpair function is very slow.
> It takes 6-7 seconds to match the opening parenthesis (Note: opening
> parenthesis not farther than 10-15 lines).

Why do you have the while loop?  searchpair() returns the line on which
the paired item was found, 0 if it couldn't find a matching pair, or -1
if the skip expression caused an error while being evaluated.

By using the while loop, you're not only discarding any match that you
do find, but you're then causing Vim to search the entire buffer
previous to the cursor position for any other match.  That's likely the
cause for the delay you're seeing.

--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[hidden email]>

--
You received this message from the "vim_dev" 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
Loading...