comparison src/insexpand.c @ 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 755ab148288b
children 979ce206409a
comparison
equal deleted inserted replaced
29354:3a49645302e6 29355:796198629190
2207 2207
2208 // CTRL-E means completion is Ended, go back to the typed text. 2208 // CTRL-E means completion is Ended, go back to the typed text.
2209 // but only do this, if the Popup is still visible 2209 // but only do this, if the Popup is still visible
2210 if (c == Ctrl_E) 2210 if (c == Ctrl_E)
2211 { 2211 {
2212 char_u *p = NULL;
2213
2212 ins_compl_delete(); 2214 ins_compl_delete();
2213 if (compl_leader != NULL) 2215 if (compl_leader != NULL)
2214 ins_bytes(compl_leader + get_compl_len()); 2216 p = compl_leader;
2215 else if (compl_first_match != NULL) 2217 else if (compl_first_match != NULL)
2216 ins_bytes(compl_orig_text + get_compl_len()); 2218 p = compl_orig_text;
2219 if (p != NULL)
2220 {
2221 int compl_len = get_compl_len();
2222 int len = (int)STRLEN(p);
2223
2224 if (len > compl_len)
2225 ins_bytes_len(p + compl_len, len - compl_len);
2226 }
2217 retval = TRUE; 2227 retval = TRUE;
2218 } 2228 }
2219 2229
2220 auto_format(FALSE, TRUE); 2230 auto_format(FALSE, TRUE);
2221 2231