From 8d0bb6dc9f2e5d94ebb59671d592c1b7fa325ca6 Mon Sep 17 00:00:00 2001 From: glepnir Date: Tue, 24 Dec 2024 09:44:35 +0100 Subject: [PATCH 1/3] patch 9.1.0956: completion may crash, completion highlight wrong with preview window Problem: completion may crash, completion highlight wrong with preview window (after v9.1.0954) Solution: correctly calculate scroll offset, check for preview window when adding extra highlighting (glepnir) when there have a preview window prepare_tagpreview will change curwin to preview window and this may cause ComplMatchIns check condition not correct. check wp is curwin and also the type of wp is not a preview or poup info fixes: #16284 closes: #16283 Signed-off-by: glepnir Signed-off-by: Christian Brabandt --- src/drawline.c | 5 +++-- src/insexpand.c | 17 +++++++++++++++++ src/popupmenu.c | 5 +++-- src/proto/insexpand.pro | 1 + src/testdir/dumps/Test_pum_matchins_11.dump | 20 ++++++++++++++++++++ src/testdir/test_popup.vim | 21 ++++++++++++++++++++- src/version.c | 2 ++ 7 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 src/testdir/dumps/Test_pum_matchins_11.dump diff --git a/src/drawline.c b/src/drawline.c index bc8e4d2ad7b8d4..f3838572c31df0 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -1869,7 +1869,7 @@ win_line( } #endif - if ((State & MODE_INSERT) && in_curline && ins_compl_active()) + if ((State & MODE_INSERT) && in_curline && ins_compl_win_active(wp)) area_highlighting = TRUE; #ifdef FEAT_SYN_HL @@ -2415,7 +2415,8 @@ win_line( #endif // Check if ComplMatchIns highlight is needed. - if ((State & MODE_INSERT) && in_curline && ins_compl_active()) + if ((State & MODE_INSERT) && in_curline + && ins_compl_win_active(wp)) { int ins_match_attr = ins_compl_col_range_attr((int)(ptr - line)); diff --git a/src/insexpand.c b/src/insexpand.c index 2d1490428b721c..522b7f73ea1579 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -1864,6 +1864,23 @@ ins_compl_active(void) return compl_started; } +/* + * Return True when wp is the actual completion window + */ + int +ins_compl_win_active(win_T *wp UNUSED) +{ + return ins_compl_active() +#if defined(FEAT_QUICKFIX) + && (!wp->w_p_pvw +# ifdef FEAT_PROP_POPUP + && !(wp->w_popup_flags & POPF_INFO) +# endif + ) +#endif + ; +} + /* * Selected one of the matches. When FALSE the match was edited or using the * longest common string. diff --git a/src/popupmenu.c b/src/popupmenu.c index 6298b5cb62a84f..ea2edca9ab0bf2 100644 --- a/src/popupmenu.c +++ b/src/popupmenu.c @@ -917,7 +917,7 @@ pum_set_selected(int n, int repeat UNUSED) { int resized = FALSE; int context = pum_height / 2; - int scroll_offset = pum_selected - pum_height; + int scroll_offset; #ifdef FEAT_QUICKFIX int prev_selected = pum_selected; unsigned cur_cot_flags = get_cot_flags(); @@ -927,6 +927,7 @@ pum_set_selected(int n, int repeat UNUSED) #endif pum_selected = n; + scroll_offset = pum_selected - pum_height; if (pum_selected >= 0 && pum_selected < pum_size) { @@ -950,7 +951,7 @@ pum_set_selected(int n, int repeat UNUSED) // scroll up; when we did a jump it's probably a PageDown then // scroll a whole page if (pum_first < scroll_offset + 3) - pum_first = MAX(pum_first, scroll_offset + 1); + pum_first = MAX(pum_first + pum_height - 2, scroll_offset + 1); else pum_first = scroll_offset + 1; } diff --git a/src/proto/insexpand.pro b/src/proto/insexpand.pro index 2e769b89f89bb8..24c325fe6eec1f 100644 --- a/src/proto/insexpand.pro +++ b/src/proto/insexpand.pro @@ -36,6 +36,7 @@ char_u *find_word_start(char_u *ptr); char_u *find_word_end(char_u *ptr); void ins_compl_clear(void); int ins_compl_active(void); +int ins_compl_win_active(win_T *wp); int ins_compl_used_match(void); void ins_compl_init_get_longest(void); int ins_compl_interrupted(void); diff --git a/src/testdir/dumps/Test_pum_matchins_11.dump b/src/testdir/dumps/Test_pum_matchins_11.dump new file mode 100644 index 00000000000000..a44a6ee5666864 --- /dev/null +++ b/src/testdir/dumps/Test_pum_matchins_11.dump @@ -0,0 +1,20 @@ +|i+0&#ffffff0|n|f|o| @70 +|~+0#4040ff13&| @73 +|~| @73 +|[+1#0000000&|S|c|r|a|t|c|h|]| |[|P|r|e|v|i|e|w|]| @37|1|,|1| @11|A|l@1 +|f+0&&|o@1> @71 +|f+0#0000001#e0e0e08|o@1| @11| +0#4040ff13#ffffff0@59 +|b+0#0000001#ffd7ff255|a|r| @11| +0#4040ff13#ffffff0@59 +|你*0#0000001#ffd7ff255|好| +&@10| +0#4040ff13#ffffff0@59 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|A|l@1 +|-+2&&@1| |O|m|n|i| |c|o|m|p|l|e|t|i|o|n| |(|^|O|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |3| +0#0000000&@34 diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim index 8f053fab89ee49..729fbecffa44ed 100644 --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -1715,11 +1715,15 @@ endfunc func Test_pum_matchins_highlight() CheckScreendump let lines =<< trim END + let g:change = 0 func Omni_test(findstart, base) if a:findstart return col(".") endif - return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}] + if g:change == 0 + return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}] + endif + return [#{word: "foo", info: "info"}, #{word: "bar"}, #{word: "你好"}] endfunc set omnifunc=Omni_test hi ComplMatchIns ctermfg=red @@ -1766,6 +1770,10 @@ func Test_pum_matchins_highlight() call VerifyScreenDump(buf, 'Test_pum_matchins_10', {}) call term_sendkeys(buf, "\") + call term_sendkeys(buf, ":let g:change=1\S\\") + call VerifyScreenDump(buf, 'Test_pum_matchins_11', {}) + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) endfunc @@ -1811,4 +1819,15 @@ func Test_pum_matchins_highlight_combine() call StopVimInTerminal(buf) endfunc +" this used to crash +func Test_popup_completion_many_ctrlp() + new + let candidates=repeat(['a0'], 99) + call setline(1, candidates) + exe ":norm! VGg\" + norm! G + call feedkeys("o" .. repeat("\", 100), 'tx') + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index d668ad77a1d313..700603962b6512 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 956, /**/ 955, /**/ From 084529c03dd3e74c0d4f46a93f76e33789ac112e Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Tue, 24 Dec 2024 09:50:01 +0100 Subject: [PATCH 2/3] patch 9.1.0957: MS-Windows: conversion warnings Problem: MS-Windows: conversion warnings Solution: add explicit type casts (Yegappan Lakshmanan) closes: #16288 Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- src/ex_getln.c | 14 +++++++------- src/filepath.c | 2 +- src/option.c | 6 +++--- src/undo.c | 2 +- src/usercmd.c | 4 ++-- src/version.c | 2 ++ src/vim9compile.c | 2 +- src/vim9execute.c | 2 +- src/viminfo.c | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/ex_getln.c b/src/ex_getln.c index 163c474dbb480a..93d612a70026d2 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -628,7 +628,7 @@ may_adjust_incsearch_highlighting( return FAIL; } skiplen = 0; - patlen = last_search_pattern_len(); + patlen = (int)last_search_pattern_len(); } else pat = ccline.cmdbuff + skiplen; @@ -1472,7 +1472,7 @@ cmdline_browse_history( } if (i == 0) { - alloc_cmdbuff(len); + alloc_cmdbuff((int)len); if (ccline.cmdbuff == NULL) { res = GOTO_NORMAL_MODE; @@ -1481,18 +1481,18 @@ cmdline_browse_history( } } ccline.cmdbuff[len] = NUL; - ccline.cmdpos = ccline.cmdlen = len; + ccline.cmdpos = ccline.cmdlen = (int)len; } else { - alloc_cmdbuff(plen); + alloc_cmdbuff((int)plen); if (ccline.cmdbuff == NULL) { res = GOTO_NORMAL_MODE; goto done; } STRCPY(ccline.cmdbuff, p); - ccline.cmdpos = ccline.cmdlen = plen; + ccline.cmdpos = ccline.cmdlen = (int)plen; } redrawcmd(); @@ -4778,8 +4778,8 @@ open_cmdwin(void) { // Execute the command directly. ccline.cmdbuff = vim_strnsave(p, plen); - ccline.cmdlen = plen; - ccline.cmdbufflen = plen + 1; + ccline.cmdlen = (int)plen; + ccline.cmdbufflen = (int)(plen + 1); cmdwin_result = CAR; } else diff --git a/src/filepath.c b/src/filepath.c index 3dd71bc407e92b..1ac2f868a43ffc 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -675,7 +675,7 @@ modify_fname( if (s != NULL) { *fnamep = s; - *fnamelen = slen; + *fnamelen = (int)slen; vim_free(*bufp); *bufp = s; didit = TRUE; diff --git a/src/option.c b/src/option.c index f069d0f4bc51bc..e4c52bd35081a1 100644 --- a/src/option.c +++ b/src/option.c @@ -193,7 +193,7 @@ set_init_default_backupskip(void) itemlen = vim_snprintf((char *)item, itemsize, "%s%s*", p, (has_trailing_path_sep) ? "" : PATHSEPSTR); if (find_dup_item(ga.ga_data, item, itemlen, options[opt_idx].flags) == NULL - && ga_grow(&ga, itemseplen + itemlen + 1) == OK) + && ga_grow(&ga, (int)(itemseplen + itemlen + 1)) == OK) { ga.ga_len += vim_snprintf((char *)ga.ga_data + ga.ga_len, itemseplen + itemlen + 1, @@ -8415,7 +8415,7 @@ vimrc_found(char_u *fname, char_u *envname) if (vim_getenv((char_u *)"MYVIMDIR", &dofree) == NULL) { size_t usedlen = 0; - int len = 0; + size_t len = 0; char_u *fbuf = NULL; if (STRNCMP(gettail(fname), ".vimrc", 6) == 0) @@ -8452,7 +8452,7 @@ vimrc_found(char_u *fname, char_u *envname) } #endif else - (void)modify_fname((char_u *)":h", FALSE, &usedlen, &p, &fbuf, &len); + (void)modify_fname((char_u *)":h", FALSE, &usedlen, &p, &fbuf, (int *)&len); if (p != NULL) { diff --git a/src/undo.c b/src/undo.c index 52df9394fc13b7..764912ae61c3d2 100644 --- a/src/undo.c +++ b/src/undo.c @@ -3124,7 +3124,7 @@ ex_undolist(exarg_T *eap UNUSED) // we have to call STRLEN() here because add_time() does not report // the number of characters added. - len += STRLEN(IObuff + len); + len += (int)STRLEN(IObuff + len); if (uhp->uh_save_nr > 0) { int n = (len >= 33) ? 0 : 33 - len; diff --git a/src/usercmd.c b/src/usercmd.c index c0d1bdb6905fba..ff2c353e392055 100644 --- a/src/usercmd.c +++ b/src/usercmd.c @@ -671,7 +671,7 @@ uc_list(char_u *name, size_t name_len) if (entry != NULL) { STRCPY(IObuff + len, entry->value.string); - len += entry->value.length; + len += (int)entry->value.length; #ifdef FEAT_EVAL if (p_verbose > 0 && cmd->uc_compl_arg != NULL) { @@ -681,7 +681,7 @@ uc_list(char_u *name, size_t name_len) { IObuff[len++] = ','; STRCPY(IObuff + len, cmd->uc_compl_arg); - len += uc_compl_arglen; + len += (int)uc_compl_arglen; } } #endif diff --git a/src/version.c b/src/version.c index 700603962b6512..8fa6c6996fe1fe 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 957, /**/ 956, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index c8409636041ee9..c8a50cf4c1ac1d 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1838,7 +1838,7 @@ compile_lhs_script_var( int script_var = FALSE; imported_T *import; char_u *var_name; - int var_name_len; + size_t var_name_len; if (lhs->lhs_varlen > 1 && STRNCMP(var_start, "s:", 2) == 0) script_namespace = TRUE; diff --git a/src/vim9execute.c b/src/vim9execute.c index f20ff4064721f8..de49aaa70c7994 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -3184,7 +3184,7 @@ any_var_get_obj_member(class_T *current_class, isn_T *iptr, typval_T *tv) copy_tv(tv, &mtv); // 'name' can either be a object variable or a object method - int namelen = STRLEN(iptr->isn_arg.string); + int namelen = (int)STRLEN(iptr->isn_arg.string); int save_did_emsg = did_emsg; if (get_member_tv(obj->obj_class, TRUE, iptr->isn_arg.string, namelen, diff --git a/src/viminfo.c b/src/viminfo.c index 0a433a7cf432ef..5f1ad74758eca2 100644 --- a/src/viminfo.c +++ b/src/viminfo.c @@ -1142,7 +1142,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values) // freed later, also need to free "buf" later value->bv_tofree = buf; s = sconv; - len = STRLEN(s); + len = (int)STRLEN(s); converted = TRUE; } } From e62d93ead10b4c5818e3c0b7551f1784d24bfe33 Mon Sep 17 00:00:00 2001 From: "Wu, Zhenyu" Date: Tue, 24 Dec 2024 09:54:27 +0100 Subject: [PATCH 3/3] patch 9.1.0958: filetype: supertux2 config files detected as lisp Problem: filetype: supertux2 config files detected as lisp Solution: detect supertux2 config files as scheme instead (Wu, Zhenyu) References: https://github.com/SuperTux/supertux/wiki/S-Expression supertux uses #t and #f as bool type, which is same as scheme, not common lisp closes: #16287 Signed-off-by: Wu, Zhenyu Signed-off-by: Christian Brabandt --- runtime/filetype.vim | 8 ++++---- src/testdir/test_filetype.vim | 4 ++-- src/version.c | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 8b3d44db55404d..3eb173646d5d92 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1384,9 +1384,9 @@ au BufNewFile,BufRead *.ly,*.ily setf lilypond " Lisp (*.el = ELisp) " *.jl was removed, it's also used for Julia, better skip than guess wrong. if has("fname_case") - au BufNewFile,BufRead *.lsp,*.lisp,*.asd,*.el,*.L,.emacs,.sawfishrc,*.stsg,*/supertux2/config setf lisp + au BufNewFile,BufRead *.lsp,*.lisp,*.asd,*.el,*.L,.emacs,.sawfishrc setf lisp else - au BufNewFile,BufRead *.lsp,*.lisp,*.asd,*.el,.emacs,.sawfishrc,*.stsg,*/supertux2/config setf lisp + au BufNewFile,BufRead *.lsp,*.lisp,*.asd,*.el,.emacs,.sawfishrc setf lisp endif " *.cl = Common Lisp or OpenCL @@ -2314,8 +2314,8 @@ au BufNewFile,BufRead *.zsh,*.zsh-theme,*.zunit setf zsh " Salt state files au BufNewFile,BufRead *.sls setf salt -" Scheme ("racket" patterns are now separate, see above) -au BufNewFile,BufRead *.scm,*.ss,*.sld setf scheme +" Scheme, Supertux configuration ("racket" patterns are now separate, see above) +au BufNewFile,BufRead *.scm,*.ss,*.sld,*.stsg,*/supertux2/config setf scheme " Screen RC au BufNewFile,BufRead .screenrc,screenrc setf screen diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index b5e2dc0b150629..20a11ae432b2cf 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -429,7 +429,7 @@ def s:GetFilenameChecks(): dict> limits: ['/etc/limits', '/etc/anylimits.conf', '/etc/anylimits.d/file.conf', '/etc/limits.conf', '/etc/limits.d/file.conf', '/etc/some-limits.conf', '/etc/some-limits.d/file.conf', 'any/etc/limits', 'any/etc/limits.conf', 'any/etc/limits.d/file.conf', 'any/etc/some-limits.conf', 'any/etc/some-limits.d/file.conf'], liquidsoap: ['file.liq'], liquid: ['file.liquid'], - lisp: ['file.lsp', 'file.lisp', 'file.asd', 'file.el', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc', 'file.stsg', 'any/local/share/supertux2/config'], + lisp: ['file.lsp', 'file.lisp', 'file.asd', 'file.el', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc'], lite: ['file.lite', 'file.lt'], litestep: ['/LiteStep/any/file.rc', 'any/LiteStep/any/file.rc'], logcheck: ['/etc/logcheck/file.d-some/file', '/etc/logcheck/file.d/file', 'any/etc/logcheck/file.d-some/file', 'any/etc/logcheck/file.d/file'], @@ -671,7 +671,7 @@ def s:GetFilenameChecks(): dict> sather: ['file.sa'], sbt: ['file.sbt'], scala: ['file.scala'], - scheme: ['file.scm', 'file.ss', 'file.sld'], + scheme: ['file.scm', 'file.ss', 'file.sld', 'file.stsg', 'any/local/share/supertux2/config'], scilab: ['file.sci', 'file.sce'], screen: ['.screenrc', 'screenrc'], scss: ['file.scss'], diff --git a/src/version.c b/src/version.c index 8fa6c6996fe1fe..aa5380d353573c 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 958, /**/ 957, /**/