mirror of
https://github.com/neovim/neovim.git
synced 2025-10-14 05:46:12 +00:00
vim-patch:9.0.0020: with some completion reading past end of string (#19922)
Problem: With some completion reading past end of string.
Solution: Check the length of the string.
f12129f171
This commit is contained in:
@@ -1839,10 +1839,18 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
|
|||||||
// but only do this, if the Popup is still visible
|
// but only do this, if the Popup is still visible
|
||||||
if (c == Ctrl_E) {
|
if (c == Ctrl_E) {
|
||||||
ins_compl_delete();
|
ins_compl_delete();
|
||||||
|
char_u *p = NULL;
|
||||||
if (compl_leader != NULL) {
|
if (compl_leader != NULL) {
|
||||||
ins_bytes(compl_leader + get_compl_len());
|
p = compl_leader;
|
||||||
} else if (compl_first_match != NULL) {
|
} else if (compl_first_match != NULL) {
|
||||||
ins_bytes(compl_orig_text + get_compl_len());
|
p = compl_orig_text;
|
||||||
|
}
|
||||||
|
if (p != NULL) {
|
||||||
|
const int compl_len = get_compl_len();
|
||||||
|
const int len = (int)STRLEN(p);
|
||||||
|
if (len > compl_len) {
|
||||||
|
ins_bytes_len(p + compl_len, (size_t)(len - compl_len));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
retval = true;
|
retval = true;
|
||||||
}
|
}
|
||||||
|
@@ -947,4 +947,12 @@ func Test_complete_smartindent()
|
|||||||
delfunction! FooBarComplete
|
delfunction! FooBarComplete
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_complete_overrun()
|
||||||
|
" this was going past the end of the copied text
|
||||||
|
new
|
||||||
|
sil norm si0s0
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user