Mercurial > vim
changeset 29355:796198629190 v9.0.0020
patch 9.0.0020: with some completion reading past end of string
Commit: https://github.com/vim/vim/commit/f12129f1714f7d2301935bb21d896609bdac221c
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 1 19:58:30 2022 +0100
patch 9.0.0020: with some completion reading past end of string
Problem: With some completion reading past end of string.
Solution: Check the length of the string.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 01 Jul 2022 21:00:03 +0200 |
parents | 3a49645302e6 |
children | 6dadd92ee4ae |
files | src/insexpand.c src/testdir/test_ins_complete.vim src/version.c |
diffstat | 3 files changed, 22 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/insexpand.c +++ b/src/insexpand.c @@ -2209,11 +2209,21 @@ ins_compl_stop(int c, int prev_mode, int // but only do this, if the Popup is still visible if (c == Ctrl_E) { + char_u *p = NULL; + ins_compl_delete(); if (compl_leader != NULL) - ins_bytes(compl_leader + get_compl_len()); + p = compl_leader; else if (compl_first_match != NULL) - ins_bytes(compl_orig_text + get_compl_len()); + p = compl_orig_text; + if (p != NULL) + { + int compl_len = get_compl_len(); + int len = (int)STRLEN(p); + + if (len > compl_len) + ins_bytes_len(p + compl_len, len - compl_len); + } retval = TRUE; }
--- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -2184,4 +2184,12 @@ func Test_complete_smartindent() delfunction! FooBarComplete 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