Hi Bram and Nice Vim developers,
2015/1/6(Tue) 4:58:27 UTC+9 Bram Moolenaar:
> Yasuhiro Matsumoto wrote:
>
> > bug.vim
> > -------------------
> > set nocompatible
> >
> > inoremap <F5> <C-R>=ListMonths()<CR>
> >
> > func! ListMonths()
> > call complete(col('.'), ['January', 'February', 'March',
> > \ 'April', 'May', 'June', 'July', 'August', 'September',
> > \ 'October', 'November', 'December'])
> > return ''
> > endfunc
> > -------------------
> >
> > 1. vim -u bug.vim -N
> >
> > 2. press F5
> >
> > 3. type Ctrl-L while popup menu is visible
> >
> > Ctrl-L should not behave like Ctrl-P. ins_compl_key2dir() handles
> > suffix keys after CTRL-X. And also it handles keys while popup menu is
> > visible (ex: CTRL-P/CTRL-N). This should be cleanly separated.
> >
> > https://gist.github.com/mattn/2c83d5a17c9e9505e43d
>
> Thanks!
I update a patch. (Attached to this email)
Please check.
And ...
I found specification inconsistency between 'complete()' and 'backspace' option.
How to reproduce:
1. cat test.vim
inoremap <F5> <C-R>=ListMonths()<CR>
func! ListMonths()
call complete(1, ['One', 'Three'])
return ''
endfunc
2. vim -N -u test.vim
3. Enter insert-mode and input 'ab' and leave insert-mode.
iab<Esc>
4. Reenter insert-mode and use 'complete()'
a<F5>
5. Delete two characters.
<C-H><C-H>
What happen.
- '4.' Edit start columns 3, but 'complete()' starts 1 (by 1st argument).
- '5.' Can't delete column 1 and 2
'backspace' option not contain "start", So vim can not deleted this.
I think this is specification inconsistency.
How Let's fix?
(a) Occurred an error when 'comple()' first argument is can not be deleted by
under the influence of the 'backspace' option.
(b) Adjust the first argument value implicitly in f_complete(). (In this case,
Ajust 3)
(c) Between 'comple ()' is functioning to ignore the 'backspace' option.
I would write the patch when you are determined.
Best regards,
Hirohito Higashi (a.k.a h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff -r b0a227941705 src/edit.c
--- a/src/edit.c Tue Feb 03 19:13:34 2015 +0100
+++ b/src/edit.c Wed Feb 04 10:15:49 2015 +0900
@@ -34,6 +34,7 @@
#define CTRL_X_OMNI 13
#define CTRL_X_SPELL 14
#define CTRL_X_LOCAL_MSG 15 /* only used in "ctrl_x_msgs" */
+#define CTRL_X_EVAL 16 /* for builtin function complete() */
#define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT]
@@ -55,6 +56,7 @@
N_(" Omni completion (^O^N^P)"),
N_(" Spelling suggestion (s^N^P)"),
N_(" Keyword Local completion (^N^P)"),
+ NULL, /* CTRL_X_EVAL doesn't use msg. */
};
static char e_hitend[] = N_("Hit end of paragraph");
@@ -2267,6 +2269,8 @@
#endif
case CTRL_X_SPELL:
return (c == Ctrl_S || c == Ctrl_P || c == Ctrl_N);
+ case CTRL_X_EVAL:
+ return (c == Ctrl_P || c == Ctrl_N);
}
EMSG(_(e_internal));
return FALSE;
@@ -2773,8 +2777,7 @@
-1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK)
return;
- /* Handle like dictionary completion. */
- ctrl_x_mode = CTRL_X_WHOLE_LINE;
+ ctrl_x_mode = CTRL_X_EVAL;
ins_compl_add_list(list);
compl_matches = ins_compl_make_cyclic();
@@ -3394,7 +3397,7 @@
* allow the word to be deleted, we won't match everything. */
if ((int)(p - line) - (int)compl_col < 0
|| ((int)(p - line) - (int)compl_col == 0
- && ctrl_x_mode != CTRL_X_OMNI))
+ && ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL)
return K_BS;
/* Deleted more than what was used to find matches or didn't finish