comparison src/syntax.c @ 29892:db0939444c96 v9.0.0284

patch 9.0.0284: using static buffer for multiple completion functions Commit: https://github.com/vim/vim/commit/5ff595d9db2d9a33aa10cc9f18f256826226862f Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 26 22:36:41 2022 +0100 patch 9.0.0284: using static buffer for multiple completion functions Problem: Using static buffer for multiple completion functions. Solution: Use one buffer in expand_T.
author Bram Moolenaar <Bram@vim.org>
date Fri, 26 Aug 2022 23:45:03 +0200
parents 80929331a836
children 029c59bf78f1
comparison
equal deleted inserted replaced
29891:6c571257924c 29892:db0939444c96
6418 /* 6418 /*
6419 * Function given to ExpandGeneric() to obtain the list syntax names for 6419 * Function given to ExpandGeneric() to obtain the list syntax names for
6420 * expansion. 6420 * expansion.
6421 */ 6421 */
6422 char_u * 6422 char_u *
6423 get_syntax_name(expand_T *xp UNUSED, int idx) 6423 get_syntax_name(expand_T *xp, int idx)
6424 { 6424 {
6425 #define CBUFFER_LEN 256
6426 static char_u cbuffer[CBUFFER_LEN]; // TODO: better solution
6427
6428 switch (expand_what) 6425 switch (expand_what)
6429 { 6426 {
6430 case EXP_SUBCMD: 6427 case EXP_SUBCMD:
6431 return (char_u *)subcommands[idx].name; 6428 return (char_u *)subcommands[idx].name;
6432 case EXP_CASE: 6429 case EXP_CASE:
6450 } 6447 }
6451 case EXP_CLUSTER: 6448 case EXP_CLUSTER:
6452 { 6449 {
6453 if (idx < curwin->w_s->b_syn_clusters.ga_len) 6450 if (idx < curwin->w_s->b_syn_clusters.ga_len)
6454 { 6451 {
6455 vim_snprintf((char *)cbuffer, CBUFFER_LEN, "@%s", 6452 vim_snprintf((char *)xp->xp_buf, EXPAND_BUF_LEN, "@%s",
6456 SYN_CLSTR(curwin->w_s)[idx].scl_name); 6453 SYN_CLSTR(curwin->w_s)[idx].scl_name);
6457 return cbuffer; 6454 return xp->xp_buf;
6458 } 6455 }
6459 else 6456 else
6460 return NULL; 6457 return NULL;
6461 } 6458 }
6462 } 6459 }