Re: Bug report: display bug with accented characters and completion menu

2007-03-24 Thread Bram Moolenaar

Gombault Damien wrote:

 I noticed a display bug with the completion menu.
 
 If accented characters appears in the completion menu, some others characters 
 from the edited file appears too in the menu ! It's quite difficult to 
 explain so I've made some screenshots. You can also notice these bad 
 characters appears only if a filename is displayed next to the word.
 
 Screenshots taken from  Ubuntu Feisty (VIM 7.0-164) :
  - GVIM (GTK+) with custom config : 
 http://img139.imageshack.us/img139/21/vim1et2.png
 
  - GVIM (GTK+) with custom config (another colorscheme) :
 http://img115.imageshack.us/img115/6541/vim2jb9.png
 
  - GVIM (GTK+) with default config :
 http://img163.imageshack.us/img163/2661/vim3fp1.png
 
  - VIM (gnome-terminal) with default config :
 http://img53.imageshack.us/img53/6716/vim4xk5.png
 
 I noticed this bug with :
 - GVIM (GTK+) 7.0-164 (Ubuntu Feisty)
 - VIM (gnome-terminal) 7.0-164 (Ubuntu Feisty)
 - GVIM (GTK+) 7.0-201 (Gentoo)
 - GVIM (x11) 7.0-201 (Gentoo) (I have not tested x11 on other builds)
 - VIM (konsole) 7.0-201 (Gentoo)
 - GVIM (GTK+) 7.0-219 (custom build on Gentoo)
 - VIM (konsole) 7.0-219 (custom build on Gentoo)
 
 I have NOT noticed this bug with :
  - GVIM (win32) 7.0-219 (Cream build without Cream config)

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?

-- 
When I die, I want a tombstone that says GAME OVER - Ton Richters

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


Re: Bug report: display bug with accented characters and completion menu

2007-03-24 Thread Gombault Damien
 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.

Regards.
-- 
Gombault Damien | Powered by Gentoo Linux AMD64


texts.tar.gz
Description: application/tgz


Re: Bug report: display bug with accented characters and completion menu

2007-03-24 Thread Gombault Damien
Another test with 3 files :
   1.cpp : UTF-8 file with French accented characters.
   2.cpp : the same file but with Latin-1 charset.
   3.cpp : a file to test 'include' completion.

Yes, it's a bit strange because it's not a great idea to work with different 
encodings. But it shows the problem. :)

Put the 3 files in the same directory.
Run Gvim, set your 'encoding' to 'latin1'.
Edit 3.cpp file.
Type, before the comment, CTRL-x CTRL-i for 'include' completion. Words 
from 1.cpp are not displayed in the completion menu because words are not 
converted to the current encoding.

Run Gvim, set your 'encoding' to 'utf-8'.
Edit 3.cpp file.
Type, before the comment, CTRL-x CTRL-i for 'include' completion. Words 
from 2.cpp are displayed but you have a display bug with the completion 
menu because words are not converted to the current encoding. 

Regards.
-- 
Gombault Damien | Powered by Gentoo Linux AMD64


another_test.tar.gz
Description: application/tgz


Re: Bug report: display bug with accented characters and completion menu

2007-03-24 Thread Bram Moolenaar

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.cTue 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