On May 12, 12:27 pm, Bram Moolenaar <[email protected]> wrote:
> Sean Ma wrote:
> > When leading zero is included, an unexpected Octal conversion is used.
> > This might be a "bug" instead of a "feature".
>
> > >From the help, we have:
>
> > FUNCTIONS FOR FINDING COMPLETIONS
> > *complete-functions*
> > ...
> > On the second invocation the arguments are:
> > a:base the text with which matches should match; the text that
> > was
> > located in the first call (can be empty)
>
> > Therefore, a:base should be "text", as it is.
>
> > However, when "text" including leading zero, auto Octal conversion is
> > done.
> > For example: when input is 0123, output is 83, instead of '0123'.
>
> > My workaround from the script level is to use my self-made s:base
> > variable,
> > instead of using a:base function argument:
>
> > let current_line = getline(line('.'))
> > let start_cursor = col('.')-1
> > " start_column is what found from the first invocation
>
> > let len = start_cursor - start_column
> > let s:base = strpart(current_line, start_column, len)
>
> > In this example, when input is '0123':
> > s:base returns '0123' (expected)
> > a:base returns '83' (surprise!)
>
> I see the problem. When calling the function recognizing a number
> argument is automatically done, so everything that starts with a digit
> is assumed to be a number.
>
> --
> There is no right or wrong, there is only your personal opinion.
> (Bram Moolenaar)
>
> /// 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 ///
Hi Bram,
I am glad that you understood this subtle issue.
I am sending a gift to you:
http://maxiangjiang.googlepages.com/four_corner.gif
(The meaning of the 7th highlighted char is "sound", which is used in
China for thousands of years.)
This is a Chinese indexing system call "four corner", by using 4
digits to map one Chinese. It was invented in 1920s, and still shows
life, thanks to computer, Vim, and VimIM :))
For every Chinese glyph, there is only one unique number to represent.
However, for every 4 digits, there might be many Chinese (1 to 8
mapping on the picture). The Vim omni completion feature comes to
rescue in this situation.
Thanks
Sean
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---