patch 9.1.0742: getcmdprompt() implementation can be improved
Problem: getcmdprompt() implementation can be improved
Solution: Improve and simplify it (h-east)
closes: #15743
Signed-off-by: h-east <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 61f8379..ef7ca91 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -30,7 +30,6 @@
#ifdef FEAT_EVAL
static int new_cmdpos; // position set by set_cmdline_pos()
-static char_u current_prompt[CMDBUFFSIZE + 1] = "";
#endif
static int extra_char = NUL; // extra character to display when redrawing
@@ -50,9 +49,6 @@
static void draw_cmdline(int start, int len);
static void save_cmdline(cmdline_info_T *ccp);
static void restore_cmdline(cmdline_info_T *ccp);
-#ifdef FEAT_EVAL
-static char_u *get_prompt(void);
-#endif
static int cmdline_paste(int regname, int literally, int remcr);
static void redrawcmdprompt(void);
static int ccheck_abbr(int);
@@ -4236,24 +4232,6 @@
}
/*
- * Get current command line prompt.
- */
- static char_u *
-get_prompt(void)
-{
- return current_prompt;
-}
-
-/*
- * Set current command line prompt.
- */
- void
-set_prompt(char_u* str)
-{
- vim_strncpy(current_prompt, str, sizeof(current_prompt) - 1);
-}
-
-/*
* "getcmdpos()" function
*/
void
@@ -4272,7 +4250,8 @@
{
cmdline_info_T *p = get_ccline_ptr();
rettv->v_type = VAR_STRING;
- rettv->vval.v_string = p != NULL ? vim_strsave(get_prompt()) : NULL;
+ rettv->vval.v_string = p != NULL && p->cmdprompt != NULL ?
+ vim_strsave(p->cmdprompt) : NULL;
}
/*
@@ -4898,8 +4877,6 @@
cmd_silent = FALSE; // Want to see the prompt.
if (prompt != NULL)
{
- set_prompt(prompt);
-
// Only the part of the message after the last NL is considered as
// prompt for the command line
p = vim_strrchr(prompt, '\n');