aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-09-26 16:56:19 +0200
committerGitHub <noreply@github.com>2021-09-26 16:56:19 +0200
commitd4fa1649fbafe7bedb4bee0b014dd4723ad0ee97 (patch)
tree55324b1771b69ff551677801e328d76215d1d4cd /src/nvim/edit.c
parentc273eb310098a4ddae577401aca5e07b45107f48 (diff)
parent392c658d4d0f9457f143748adf98ecd4cdc8dc85 (diff)
downloadrneovim-d4fa1649fbafe7bedb4bee0b014dd4723ad0ee97.tar.gz
rneovim-d4fa1649fbafe7bedb4bee0b014dd4723ad0ee97.tar.bz2
rneovim-d4fa1649fbafe7bedb4bee0b014dd4723ad0ee97.zip
Merge pull request #15351 from bfredl/virt_line
feat(screen): virtual lines
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 5c4030d8d5..085bbc2409 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -3344,12 +3344,10 @@ static char_u *ins_compl_mode(void)
*/
static int ins_compl_bs(void)
{
- char_u *line;
- char_u *p;
-
- line = get_cursor_line_ptr();
- p = line + curwin->w_cursor.col;
+ char_u *line = get_cursor_line_ptr();
+ char_u *p = line + curwin->w_cursor.col;
MB_PTR_BACK(line, p);
+ ptrdiff_t p_off = p - line;
// Stop completion when the whole word was deleted. For Omni completion
// allow the word to be deleted, we won't match everything.
@@ -3369,8 +3367,12 @@ static int ins_compl_bs(void)
ins_compl_restart();
}
+ // ins_compl_restart() calls update_screen(0) which may invalidate the pointer
+ // TODO(bfredl): get rid of random update_screen() calls deep inside completion logic
+ line = get_cursor_line_ptr();
+
xfree(compl_leader);
- compl_leader = vim_strnsave(line + compl_col, (int)(p - line) - compl_col);
+ compl_leader = vim_strnsave(line + compl_col, (int)p_off - compl_col);
ins_compl_new_leader();
if (compl_shown_match != NULL) {
// Make sure current match is not a hidden item.