|
Karsten Hopp |
933ae9 |
To: vim-dev@vim.org
|
|
Karsten Hopp |
933ae9 |
Subject: patch 7.1.067
|
|
Karsten Hopp |
933ae9 |
Fcc: outbox
|
|
Karsten Hopp |
933ae9 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
933ae9 |
Mime-Version: 1.0
|
|
Karsten Hopp |
933ae9 |
Content-Type: text/plain; charset=ISO-8859-1
|
|
Karsten Hopp |
933ae9 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
933ae9 |
------------
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
Patch 7.1.067
|
|
Karsten Hopp |
933ae9 |
Problem: 'thesaurus' doesn't work when 'infercase' is set. (Mohsin)
|
|
Karsten Hopp |
933ae9 |
Solution: Don't copy the characters being completed but check the case and
|
|
Karsten Hopp |
933ae9 |
apply it to the suggested word. Also fix that the first word in
|
|
Karsten Hopp |
933ae9 |
the thesaurus line is not used. (Martin Toft)
|
|
Karsten Hopp |
933ae9 |
Files: src/edit.c
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
*** ../vim-7.1.066/src/edit.c Sun Jul 29 15:02:34 2007
|
|
Karsten Hopp |
933ae9 |
--- src/edit.c Sat Aug 11 17:16:51 2007
|
|
Karsten Hopp |
933ae9 |
***************
|
|
Karsten Hopp |
933ae9 |
*** 2057,2063 ****
|
|
Karsten Hopp |
933ae9 |
* case of the originally typed text is used, and the case of the completed
|
|
Karsten Hopp |
933ae9 |
* text is inferred, ie this tries to work out what case you probably wanted
|
|
Karsten Hopp |
933ae9 |
* the rest of the word to be in -- webb
|
|
Karsten Hopp |
933ae9 |
- * TODO: make this work for multi-byte characters.
|
|
Karsten Hopp |
933ae9 |
*/
|
|
Karsten Hopp |
933ae9 |
int
|
|
Karsten Hopp |
933ae9 |
ins_compl_add_infercase(str, len, icase, fname, dir, flags)
|
|
Karsten Hopp |
933ae9 |
--- 2057,2062 ----
|
|
Karsten Hopp |
933ae9 |
***************
|
|
Karsten Hopp |
933ae9 |
*** 2068,2121 ****
|
|
Karsten Hopp |
933ae9 |
int dir;
|
|
Karsten Hopp |
933ae9 |
int flags;
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
int has_lower = FALSE;
|
|
Karsten Hopp |
933ae9 |
int was_letter = FALSE;
|
|
Karsten Hopp |
933ae9 |
- int idx;
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! if (p_ic && curbuf->b_p_inf && len < IOSIZE)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! /* Infer case of completed part -- webb */
|
|
Karsten Hopp |
933ae9 |
! /* Use IObuff, str would change text in buffer! */
|
|
Karsten Hopp |
933ae9 |
! vim_strncpy(IObuff, str, len);
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! /* Rule 1: Were any chars converted to lower? */
|
|
Karsten Hopp |
933ae9 |
! for (idx = 0; idx < compl_length; ++idx)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! if (islower(compl_orig_text[idx]))
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! has_lower = TRUE;
|
|
Karsten Hopp |
933ae9 |
! if (isupper(IObuff[idx]))
|
|
Karsten Hopp |
933ae9 |
! {
|
|
Karsten Hopp |
933ae9 |
! /* Rule 1 is satisfied */
|
|
Karsten Hopp |
933ae9 |
! for (idx = compl_length; idx < len; ++idx)
|
|
Karsten Hopp |
933ae9 |
! IObuff[idx] = TOLOWER_LOC(IObuff[idx]);
|
|
Karsten Hopp |
933ae9 |
! break;
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! /*
|
|
Karsten Hopp |
933ae9 |
! * Rule 2: No lower case, 2nd consecutive letter converted to
|
|
Karsten Hopp |
933ae9 |
! * upper case.
|
|
Karsten Hopp |
933ae9 |
! */
|
|
Karsten Hopp |
933ae9 |
! if (!has_lower)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! for (idx = 0; idx < compl_length; ++idx)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! if (was_letter && isupper(compl_orig_text[idx])
|
|
Karsten Hopp |
933ae9 |
! && islower(IObuff[idx]))
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! /* Rule 2 is satisfied */
|
|
Karsten Hopp |
933ae9 |
! for (idx = compl_length; idx < len; ++idx)
|
|
Karsten Hopp |
933ae9 |
! IObuff[idx] = TOUPPER_LOC(IObuff[idx]);
|
|
Karsten Hopp |
933ae9 |
! break;
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
- was_letter = isalpha(compl_orig_text[idx]);
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
- }
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! /* Copy the original case of the part we typed */
|
|
Karsten Hopp |
933ae9 |
! STRNCPY(IObuff, compl_orig_text, compl_length);
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
return ins_compl_add(IObuff, len, icase, fname, NULL, dir,
|
|
Karsten Hopp |
933ae9 |
flags, FALSE);
|
|
Karsten Hopp |
933ae9 |
--- 2067,2213 ----
|
|
Karsten Hopp |
933ae9 |
int dir;
|
|
Karsten Hopp |
933ae9 |
int flags;
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
+ char_u *p;
|
|
Karsten Hopp |
933ae9 |
+ int i, c;
|
|
Karsten Hopp |
933ae9 |
+ int actual_len; /* Take multi-byte characters */
|
|
Karsten Hopp |
933ae9 |
+ int actual_compl_length; /* into account. */
|
|
Karsten Hopp |
933ae9 |
+ int *wca; /* Wide character array. */
|
|
Karsten Hopp |
933ae9 |
int has_lower = FALSE;
|
|
Karsten Hopp |
933ae9 |
int was_letter = FALSE;
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! if (p_ic && curbuf->b_p_inf)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! /* Infer case of completed part. */
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! /* Find actual length of completion. */
|
|
Karsten Hopp |
933ae9 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
! if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! p = str;
|
|
Karsten Hopp |
933ae9 |
! actual_len = 0;
|
|
Karsten Hopp |
933ae9 |
! while (*p != NUL)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! mb_ptr_adv(p);
|
|
Karsten Hopp |
933ae9 |
! ++actual_len;
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
+ else
|
|
Karsten Hopp |
933ae9 |
+ #endif
|
|
Karsten Hopp |
933ae9 |
+ actual_len = len;
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! /* Find actual length of original text. */
|
|
Karsten Hopp |
933ae9 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
! if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! p = compl_orig_text;
|
|
Karsten Hopp |
933ae9 |
! actual_compl_length = 0;
|
|
Karsten Hopp |
933ae9 |
! while (*p != NUL)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! mb_ptr_adv(p);
|
|
Karsten Hopp |
933ae9 |
! ++actual_compl_length;
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
! else
|
|
Karsten Hopp |
933ae9 |
! #endif
|
|
Karsten Hopp |
933ae9 |
! actual_compl_length = compl_length;
|
|
Karsten Hopp |
933ae9 |
!
|
|
Karsten Hopp |
933ae9 |
! /* Allocate wide character array for the completion and fill it. */
|
|
Karsten Hopp |
933ae9 |
! wca = (int *)alloc(actual_len * sizeof(int));
|
|
Karsten Hopp |
933ae9 |
! if (wca != NULL)
|
|
Karsten Hopp |
933ae9 |
! {
|
|
Karsten Hopp |
933ae9 |
! p = str;
|
|
Karsten Hopp |
933ae9 |
! for (i = 0; i < actual_len; ++i)
|
|
Karsten Hopp |
933ae9 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
! if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
! wca[i] = mb_ptr2char_adv(&p);
|
|
Karsten Hopp |
933ae9 |
! else
|
|
Karsten Hopp |
933ae9 |
! #endif
|
|
Karsten Hopp |
933ae9 |
! wca[i] = *(p++);
|
|
Karsten Hopp |
933ae9 |
!
|
|
Karsten Hopp |
933ae9 |
! /* Rule 1: Were any chars converted to lower? */
|
|
Karsten Hopp |
933ae9 |
! p = compl_orig_text;
|
|
Karsten Hopp |
933ae9 |
! for (i = 0; i < actual_compl_length; ++i)
|
|
Karsten Hopp |
933ae9 |
! {
|
|
Karsten Hopp |
933ae9 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
! if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
! c = mb_ptr2char_adv(&p);
|
|
Karsten Hopp |
933ae9 |
! else
|
|
Karsten Hopp |
933ae9 |
! #endif
|
|
Karsten Hopp |
933ae9 |
! c = *(p++);
|
|
Karsten Hopp |
933ae9 |
! if (MB_ISLOWER(c))
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
! has_lower = TRUE;
|
|
Karsten Hopp |
933ae9 |
! if (MB_ISUPPER(wca[i]))
|
|
Karsten Hopp |
933ae9 |
! {
|
|
Karsten Hopp |
933ae9 |
! /* Rule 1 is satisfied. */
|
|
Karsten Hopp |
933ae9 |
! for (i = actual_compl_length; i < actual_len; ++i)
|
|
Karsten Hopp |
933ae9 |
! wca[i] = MB_TOLOWER(wca[i]);
|
|
Karsten Hopp |
933ae9 |
! break;
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! /*
|
|
Karsten Hopp |
933ae9 |
! * Rule 2: No lower case, 2nd consecutive letter converted to
|
|
Karsten Hopp |
933ae9 |
! * upper case.
|
|
Karsten Hopp |
933ae9 |
! */
|
|
Karsten Hopp |
933ae9 |
! if (!has_lower)
|
|
Karsten Hopp |
933ae9 |
! {
|
|
Karsten Hopp |
933ae9 |
! p = compl_orig_text;
|
|
Karsten Hopp |
933ae9 |
! for (i = 0; i < actual_compl_length; ++i)
|
|
Karsten Hopp |
933ae9 |
! {
|
|
Karsten Hopp |
933ae9 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
! if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
! c = mb_ptr2char_adv(&p);
|
|
Karsten Hopp |
933ae9 |
! else
|
|
Karsten Hopp |
933ae9 |
! #endif
|
|
Karsten Hopp |
933ae9 |
! c = *(p++);
|
|
Karsten Hopp |
933ae9 |
! if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i]))
|
|
Karsten Hopp |
933ae9 |
! {
|
|
Karsten Hopp |
933ae9 |
! /* Rule 2 is satisfied. */
|
|
Karsten Hopp |
933ae9 |
! for (i = actual_compl_length; i < actual_len; ++i)
|
|
Karsten Hopp |
933ae9 |
! wca[i] = MB_TOUPPER(wca[i]);
|
|
Karsten Hopp |
933ae9 |
! break;
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
! was_letter = MB_ISLOWER(c) || MB_ISUPPER(c);
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
!
|
|
Karsten Hopp |
933ae9 |
! /* Copy the original case of the part we typed. */
|
|
Karsten Hopp |
933ae9 |
! p = compl_orig_text;
|
|
Karsten Hopp |
933ae9 |
! for (i = 0; i < actual_compl_length; ++i)
|
|
Karsten Hopp |
933ae9 |
! {
|
|
Karsten Hopp |
933ae9 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
! if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
! c = mb_ptr2char_adv(&p);
|
|
Karsten Hopp |
933ae9 |
! else
|
|
Karsten Hopp |
933ae9 |
! #endif
|
|
Karsten Hopp |
933ae9 |
! c = *(p++);
|
|
Karsten Hopp |
933ae9 |
! if (MB_ISLOWER(c))
|
|
Karsten Hopp |
933ae9 |
! wca[i] = MB_TOLOWER(wca[i]);
|
|
Karsten Hopp |
933ae9 |
! else if (MB_ISUPPER(c))
|
|
Karsten Hopp |
933ae9 |
! wca[i] = MB_TOUPPER(wca[i]);
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
!
|
|
Karsten Hopp |
933ae9 |
! /*
|
|
Karsten Hopp |
933ae9 |
! * Generate encoding specific output from wide character array.
|
|
Karsten Hopp |
933ae9 |
! * Multi-byte characters can occupy up to five bytes more than
|
|
Karsten Hopp |
933ae9 |
! * ASCII characters, and we also need one byte for NUL, so stay
|
|
Karsten Hopp |
933ae9 |
! * six bytes away from the edge of IObuff.
|
|
Karsten Hopp |
933ae9 |
! */
|
|
Karsten Hopp |
933ae9 |
! p = IObuff;
|
|
Karsten Hopp |
933ae9 |
! i = 0;
|
|
Karsten Hopp |
933ae9 |
! while (i < actual_len && (p - IObuff + 6) < IOSIZE)
|
|
Karsten Hopp |
933ae9 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
! if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
! p += mb_char2bytes(wca[i++], p);
|
|
Karsten Hopp |
933ae9 |
! else
|
|
Karsten Hopp |
933ae9 |
! #endif
|
|
Karsten Hopp |
933ae9 |
! *(p++) = wca[i++];
|
|
Karsten Hopp |
933ae9 |
! *p = NUL;
|
|
Karsten Hopp |
933ae9 |
!
|
|
Karsten Hopp |
933ae9 |
! vim_free(wca);
|
|
Karsten Hopp |
933ae9 |
! }
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
return ins_compl_add(IObuff, len, icase, fname, NULL, dir,
|
|
Karsten Hopp |
933ae9 |
flags, FALSE);
|
|
Karsten Hopp |
933ae9 |
***************
|
|
Karsten Hopp |
933ae9 |
*** 2842,2847 ****
|
|
Karsten Hopp |
933ae9 |
--- 2934,2940 ----
|
|
Karsten Hopp |
933ae9 |
/*
|
|
Karsten Hopp |
933ae9 |
* Add the other matches on the line
|
|
Karsten Hopp |
933ae9 |
*/
|
|
Karsten Hopp |
933ae9 |
+ ptr = buf;
|
|
Karsten Hopp |
933ae9 |
while (!got_int)
|
|
Karsten Hopp |
933ae9 |
{
|
|
Karsten Hopp |
933ae9 |
/* Find start of the next word. Skip white
|
|
Karsten Hopp |
933ae9 |
***************
|
|
Karsten Hopp |
933ae9 |
*** 2851,2857 ****
|
|
Karsten Hopp |
933ae9 |
break;
|
|
Karsten Hopp |
933ae9 |
wstart = ptr;
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! /* Find end of the word and add it. */
|
|
Karsten Hopp |
933ae9 |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
/* Japanese words may have characters in
|
|
Karsten Hopp |
933ae9 |
--- 2944,2950 ----
|
|
Karsten Hopp |
933ae9 |
break;
|
|
Karsten Hopp |
933ae9 |
wstart = ptr;
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
! /* Find end of the word. */
|
|
Karsten Hopp |
933ae9 |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
933ae9 |
if (has_mbyte)
|
|
Karsten Hopp |
933ae9 |
/* Japanese words may have characters in
|
|
Karsten Hopp |
933ae9 |
***************
|
|
Karsten Hopp |
933ae9 |
*** 2868,2876 ****
|
|
Karsten Hopp |
933ae9 |
else
|
|
Karsten Hopp |
933ae9 |
#endif
|
|
Karsten Hopp |
933ae9 |
ptr = find_word_end(ptr);
|
|
Karsten Hopp |
933ae9 |
! add_r = ins_compl_add_infercase(wstart,
|
|
Karsten Hopp |
933ae9 |
! (int)(ptr - wstart),
|
|
Karsten Hopp |
933ae9 |
! p_ic, files[i], *dir, 0);
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
if (add_r == OK)
|
|
Karsten Hopp |
933ae9 |
--- 2961,2972 ----
|
|
Karsten Hopp |
933ae9 |
else
|
|
Karsten Hopp |
933ae9 |
#endif
|
|
Karsten Hopp |
933ae9 |
ptr = find_word_end(ptr);
|
|
Karsten Hopp |
933ae9 |
!
|
|
Karsten Hopp |
933ae9 |
! /* Add the word. Skip the regexp match. */
|
|
Karsten Hopp |
933ae9 |
! if (wstart != regmatch->startp[0])
|
|
Karsten Hopp |
933ae9 |
! add_r = ins_compl_add_infercase(wstart,
|
|
Karsten Hopp |
933ae9 |
! (int)(ptr - wstart),
|
|
Karsten Hopp |
933ae9 |
! p_ic, files[i], *dir, 0);
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
}
|
|
Karsten Hopp |
933ae9 |
if (add_r == OK)
|
|
Karsten Hopp |
933ae9 |
*** ../vim-7.1.066/src/version.c Sun Aug 12 15:50:26 2007
|
|
Karsten Hopp |
933ae9 |
--- src/version.c Sun Aug 12 16:36:34 2007
|
|
Karsten Hopp |
933ae9 |
***************
|
|
Karsten Hopp |
933ae9 |
*** 668,669 ****
|
|
Karsten Hopp |
933ae9 |
--- 668,671 ----
|
|
Karsten Hopp |
933ae9 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
933ae9 |
+ /**/
|
|
Karsten Hopp |
933ae9 |
+ 67,
|
|
Karsten Hopp |
933ae9 |
/**/
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
--
|
|
Karsten Hopp |
933ae9 |
hundred-and-one symptoms of being an internet addict:
|
|
Karsten Hopp |
933ae9 |
128. You can access the Net -- via your portable and cellular phone.
|
|
Karsten Hopp |
933ae9 |
|
|
Karsten Hopp |
933ae9 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
933ae9 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
933ae9 |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
933ae9 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|