From c8dc34795b552ac69183e803bfff474ba4e595b6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 May 2023 22:23:02 +0800 Subject: vim-patch:9.0.0064: confusing error when using "q:" in command line window Problem: Confusing error when using "q:" in command line window. Solution: Check for the situation and give a better error message. (closes vim/vim#10756) https://github.com/vim/vim/commit/c963ec31a0c293d629e40cb082d4bfb1651def49 Co-authored-by: Bram Moolenaar --- src/nvim/normal.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 7e44e55a8e..c3fdb304a3 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -107,6 +107,8 @@ static int VIsual_mode_orig = NUL; // saved Visual mode #endif static const char e_changelist_is_empty[] = N_("E664: Changelist is empty"); +static const char e_cmdline_window_already_open[] + = N_("E1292: Command-line window is already open"); static inline void normal_state_init(NormalState *s) { @@ -6372,6 +6374,10 @@ static void nv_record(cmdarg_T *cap) } if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') { + if (cmdwin_type != 0) { + emsg(_(e_cmdline_window_already_open)); + return; + } stuffcharReadbuff(cap->nchar); stuffcharReadbuff(K_CMDWIN); } else { -- cgit From 4111530806741bc25bd426ec9b7e9340bdd57991 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 May 2023 22:26:53 +0800 Subject: vim-patch:9.0.0218: reading before the start of the line Problem: Reading before the start of the line. Solution: When displaying "$" check the column is not negative. https://github.com/vim/vim/commit/e98c88c44c308edaea5994b8ad4363e65030968c Co-authored-by: Bram Moolenaar --- src/nvim/edit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 7670d6754f..e3321a8b99 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1528,8 +1528,9 @@ void edit_unputchar(void) // Called when p_dollar is set: display a '$' at the end of the changed text // Only works when cursor is in the line that changes. -void display_dollar(colnr_T col) +void display_dollar(colnr_T col_arg) { + colnr_T col = col_arg < 0 ? 0 : col_arg; colnr_T save_col; if (!redrawing()) { -- cgit From 7eea6b12f98c4319d2f358ee1c1ebd3f5b2dfa62 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 May 2023 22:29:07 +0800 Subject: vim-patch:9.0.0490: using freed memory with cmdwin and BufEnter autocmd Problem: Using freed memory with cmdwin and BufEnter autocmd. Solution: Make sure pointer to b_p_iminsert is still valid. https://github.com/vim/vim/commit/1c3dd8ddcba63c1af5112e567215b3cec2de11d0 Co-authored-by: Bram Moolenaar --- src/nvim/ex_getln.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1345a29a21..a4c1863576 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -127,6 +127,7 @@ typedef struct command_line_state { int break_ctrl_c; expand_T xpc; long *b_im_ptr; + buf_T *b_im_ptr_buf; ///< buffer where b_im_ptr is valid } CommandLineState; typedef struct cmdpreview_win_info { @@ -736,7 +737,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool clea } else { s->b_im_ptr = &curbuf->b_p_imsearch; } - + s->b_im_ptr_buf = curbuf; if (*s->b_im_ptr == B_IMODE_LMAP) { State |= MODE_LANGMAP; } @@ -1538,20 +1539,21 @@ static int command_line_erase_chars(CommandLineState *s) /// language :lmap mappings and/or Input Method. static void command_line_toggle_langmap(CommandLineState *s) { + long *b_im_ptr = buf_valid(s->b_im_ptr_buf) ? s->b_im_ptr : NULL; if (map_to_exists_mode("", MODE_LANGMAP, false)) { // ":lmap" mappings exists, toggle use of mappings. State ^= MODE_LANGMAP; - if (s->b_im_ptr != NULL) { + if (b_im_ptr != NULL) { if (State & MODE_LANGMAP) { - *s->b_im_ptr = B_IMODE_LMAP; + *b_im_ptr = B_IMODE_LMAP; } else { - *s->b_im_ptr = B_IMODE_NONE; + *b_im_ptr = B_IMODE_NONE; } } } - if (s->b_im_ptr != NULL) { - if (s->b_im_ptr == &curbuf->b_p_iminsert) { + if (b_im_ptr != NULL) { + if (b_im_ptr == &curbuf->b_p_iminsert) { set_iminsert_global(curbuf); } else { set_imsearch_global(curbuf); -- cgit From cd9ca700e5053f8a9666c917310dcc39651e3bfa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 May 2023 22:39:28 +0800 Subject: vim-patch:9.0.0598: using negative array index with negative width window Problem: Using negative array index with negative width window. Solution: Make sure the window width does not become negative. https://github.com/vim/vim/commit/8279af514ca7e5fd3c31cf13b0864163d1a0bfeb Co-authored-by: Bram Moolenaar --- src/nvim/window.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 45a48f13cc..87e936b92f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2304,6 +2304,9 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int } if (hnc) { // add next_curwin size next_curwin_size -= (int)p_wiw - (m - n); + if (next_curwin_size < 0) { + next_curwin_size = 0; + } new_size += next_curwin_size; room -= new_size - next_curwin_size; } else { @@ -6686,7 +6689,8 @@ static int win_border_width(win_T *wp) /// Set the width of a window. void win_new_width(win_T *wp, int width) { - wp->w_width = width; + // Should we give an error if width < 0? + wp->w_width = width < 0 ? 0 : width; wp->w_pos_changed = true; win_set_inner_size(wp, true); } -- cgit