diff src/cmdhist.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 268f6a3511df
children 9fe10dc9aeec
line wrap: on
line diff
--- a/src/cmdhist.c
+++ b/src/cmdhist.c
@@ -99,15 +99,15 @@ static char *(history_names[]) =
     char_u *
 get_history_arg(expand_T *xp UNUSED, int idx)
 {
-    static char_u compl[2] = { NUL, NUL };
-    char *short_names = ":=@>?/";
-    int short_names_count = (int)STRLEN(short_names);
-    int history_name_count = ARRAY_LENGTH(history_names) - 1;
+    char    *short_names = ":=@>?/";
+    int	    short_names_count = (int)STRLEN(short_names);
+    int	    history_name_count = ARRAY_LENGTH(history_names) - 1;
 
     if (idx < short_names_count)
     {
-	compl[0] = (char_u)short_names[idx];
-	return compl;
+	xp->xp_buf[0] = (char_u)short_names[idx];
+	xp->xp_buf[1] = NUL;
+	return xp->xp_buf;
     }
     if (idx < short_names_count + history_name_count)
 	return (char_u *)history_names[idx - short_names_count];