Dominique Pelle wrote:

> On Tue, Jul 8, 2008 at 9:32 PM, Dominique Pelle wrote:
> 
> > Hi,
> >
> > I observe a bug in the omni completion popup menu when doing omni
> > completion at the end of a line which is longer than the terminal
> > width and with "set nowrap".  The menu is not drawn at the correct
> > location when pressing <Down> when trying to select an item in the
> > popup menu.
> >
> > Bug happens in both Vim and gvim version 7.2a.19 BETA.
> >
> > Steps to reproduce:
> >
> > 1/ Install OmniCppComplete script located at:
> >
> >   http://www.vim.org/scripts/script.php?script_id=1520
> >
> > 2/ Download the c++ sample source file "bug-omni.cpp":
> >
> >   $ wget http://dominique.pelle.free.fr/bug-omni.cpp
> >
> > 3/ Build a tag file with:
> >
> >   $ ctags --language-force=c++ --c++-kinds=+p \
> >           --fields=+iaS --extra=+f+q  bug-omni.cpp
> >
> > 4/ Create a minimalistic simple_vimrc file:
> >
> >   $ cat simple_vimrc
> >
> >   filetype plugin on
> >   set nocompatible
> >   set columns=80
> >   set nowrap
> >   set tags=tags
> >
> > 5/ Start vim with:
> >
> >   $ vim -u simple.vimrc bug-omni.cpp
> >
> > 6/ Append  s->  at the end of line 10 (the line with a long comment).
> >   In Normal mode:
> >
> >     10GAs->
> >
> >   After pressing  ->  the omni menu should popup up (at correct location).
> >
> > 7/ Press <Down> to browse though items in menu and observe that menu is
> >   then re-drawn at incorrect location, at bottom of screen, corrupting
> >   the content of the screen) as shown in the following screen shot:
> >
> >   http://dominique.pelle.free.fr/bug-omni.png
> >
> >
> > I can try to debug it when I have time during the weekend but perhaps
> > someone can reproduce it and fix it before that.
> >
> > -- Dominique
> 
> 
> The attached patch fixes the bug with the pum misplaced when doing
> omni completion on long lines with "set nowrap".  I remind that not only
> the pum was misplaced, but it could also cause a memory corruption
> with crash, which I observed when the pum had many entries.
> 
> The problem was probably old: at least vim-7.1.138 and vim-7.2a.19
> are affected.
> 
> The problem was that depending on where curwin->w_wcol was
> set, its value was different. Functions validate_cursor_col() and
> curs_columns() set curwin->w_wcol differently: function
> curs_columns() removes curwin->w_leftcol while function
> validate_cursor_col() did not.
> 
> When entering pum_display(), validate_virtcol() is called. If
> (curwin->w_valid & VALID_WCOL) was false, then pum was
> displayed correctly, if  (curwin->w_valid & VALID_WCOL) was
> true, then curwin->w_wcol was not recalculted (which is OK)
> but if its value came from curs_column(), then it was inconsistent
> with the value which would have been set in validate_cursor_col().
> 
> I changed the code so that validate_cursor_col() now returns
> something consistent with curs_columns().
> 
> The pum is now placed correctly.  I've tested with "set wrap"
> and "set nowrap", "set rightleft" with scrolling horizonally (zl zh)
> and the pum was always currectly placed after patch.
> "make test" also passes all tests.
> 
> What puzzles me a bit, is that the problem seemed to be known
> since function validate_cursor_col() has the following comment:
> "Only correct when 'wrap' on!"
> 
> Please review the patch and test even further.

Thanks for yet another good patch and excellent description!

I think the change in validate_cursor_col() could reflect the code in
curs_columns() a bit more:

        if (col > (int)curwin->w_leftcol)
            col -= curwin->w_leftcol;
        else
            col = 0;


-- 
hundred-and-one symptoms of being an internet addict:
217. Your sex life has drastically improved...so what if it's only cyber-sex!

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui