Gombault Damien wrote:

> > A few questions:
> >
> > - What is 'encoding' set to?
> > - What is the actual text in the entries with problems?  Give this
> >   byte-for-byte.  You may need to insert an entry to find out.
> > - Can you reproduce it by setting 'omnifunc' to a simple function that
> >   returns a fixed list of text entries?  If so, please give us the
> >   script with this.  Otherwise, give us a text file to reproduce the
> >   problem.
> > - The entries in the menu appear not to be sorted.  How did this happen?
> > - What did you type to get to these screenshots?
> 
> My system is UTF-8, so 'encoding' is also set to 'utf-8'. On the screenshot, 
> the file was wrotten in 'latin1' charset.
> 
> After some tests, I noticed this bugs seems only appears when 'encoding' 
> and 'fileencoding' are not the same. Finally, I could get this bug on win32 : 
> I set 'encoding' to 'utf-8' then open some 'latin-1' files.
> 
> I wrote two very simple C++ file to help you to reproduce the bug. These two 
> files are written in 'latin1' charset. Their content is simple C++ comments 
> containing French text with accented characters like é, è, à, etc.
> 
> Put the two files in the same directory.
> Then open gvim and set your 'encoding' to 'utf-8'.
> Edit the '2.cpp' file.
> Verify that 'fileencoding' is set to 'latin1'.
> Insert a new line between #include and the begin of the /* comment. (o key)
> Then type CTRL+x CTRL+i and the include completion menu appears like this :
> http://img131.imageshack.us/img131/4117/vim5ls3.png
> 
> Another test : 
> 'encoding' = latin1 and utf-8 texts, you get this :
> http://img78.imageshack.us/img78/483/vim6nt2.png
> Accents are not correctly displayed.
> 
> The completion menu uses 'encoding' to display its text.
> When you edit a file, the buffer is converted to the current encoding (the 
> [converted] message). When you use the completion menu with current buffer 
> words, accented characters will be correctly displayed.
> 
> But if you use completion menu with words in other files (like with include 
> completion) with a different fileencoding than your current buffer encoding, 
> accented characters will not be displayed correctly because they are not 
> converted to the current encoding.
> 
> So words from other files should be converted to the current buffer
> 'encoding'  before display them in the completion menu. That will
> certainly fix this problem.

Thanks for the clear example.  I'm now able to reproduce the problem.

There are actually two problems.  One is that text with non-printable
characters causes trouble in the popup menu.  I'll fix that now (see
patch below).

The other is that completions obtained from a file in another encoding
result in text with the wrong encoding.  That's difficult to fix.  It
would require loading the file as if editing it, so that the encoding is
detected.  I'll put this in the todo list, but don't expect it to be
fixed soon.


*** ../vim-7.0.219/src/charset.c        Tue Apr 18 00:04:40 2006
--- src/charset.c       Sat Mar 24 21:10:37 2007
***************
*** 317,323 ****
      }
  }
  
! #if defined(FEAT_EVAL) || defined(FEAT_TITLE) || defined(PROTO)
  /*
   * Translate a string into allocated memory, replacing special chars with
   * printable chars.  Returns NULL when out of memory.
--- 317,324 ----
      }
  }
  
! #if defined(FEAT_EVAL) || defined(FEAT_TITLE) || defined(FEAT_INS_EXPAND) \
!       || defined(PROTO)
  /*
   * Translate a string into allocated memory, replacing special chars with
   * printable chars.  Returns NULL when out of memory.
*** ../vim-7.0.219/src/popupmnu.c       Tue Aug 22 21:51:18 2006
--- src/popupmnu.c      Sat Mar 24 21:07:39 2007
***************
*** 280,287 ****
                    w = ptr2cells(p);
                    if (*p == NUL || *p == TAB || totwidth + w > pum_width)
                    {
!                       /* Display the text that fits or comes before a Tab. */
!                       screen_puts_len(s, (int)(p - s), row, col, attr);
                        col += width;
  
                        if (*p != TAB)
--- 280,299 ----
                    w = ptr2cells(p);
                    if (*p == NUL || *p == TAB || totwidth + w > pum_width)
                    {
!                       /* Display the text that fits or comes before a Tab.
!                        * First convert it to printable characters. */
!                       char_u *st;
!                       int  saved = *p;
! 
!                       *p = NUL;
!                       st = transstr(s);
!                       *p = saved;
!                       if (st != NULL)
!                       {
!                           screen_puts_len(st, (int)STRLEN(st), row, col,
!                                                                       attr);
!                           vim_free(st);
!                       }
                        col += width;
  
                        if (*p != TAB)


-- 
Dreams are free, but there's a small charge for alterations.

 /// 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    ///

Reply via email to