Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
29891:6c571257924c | 29892:db0939444c96 |
---|---|
97 * arguments of the ":history command. | 97 * arguments of the ":history command. |
98 */ | 98 */ |
99 char_u * | 99 char_u * |
100 get_history_arg(expand_T *xp UNUSED, int idx) | 100 get_history_arg(expand_T *xp UNUSED, int idx) |
101 { | 101 { |
102 static char_u compl[2] = { NUL, NUL }; | 102 char *short_names = ":=@>?/"; |
103 char *short_names = ":=@>?/"; | 103 int short_names_count = (int)STRLEN(short_names); |
104 int short_names_count = (int)STRLEN(short_names); | 104 int history_name_count = ARRAY_LENGTH(history_names) - 1; |
105 int history_name_count = ARRAY_LENGTH(history_names) - 1; | |
106 | 105 |
107 if (idx < short_names_count) | 106 if (idx < short_names_count) |
108 { | 107 { |
109 compl[0] = (char_u)short_names[idx]; | 108 xp->xp_buf[0] = (char_u)short_names[idx]; |
110 return compl; | 109 xp->xp_buf[1] = NUL; |
110 return xp->xp_buf; | |
111 } | 111 } |
112 if (idx < short_names_count + history_name_count) | 112 if (idx < short_names_count + history_name_count) |
113 return (char_u *)history_names[idx - short_names_count]; | 113 return (char_u *)history_names[idx - short_names_count]; |
114 if (idx == short_names_count + history_name_count) | 114 if (idx == short_names_count + history_name_count) |
115 return (char_u *)"all"; | 115 return (char_u *)"all"; |