diff src/userfunc.c @ 19035:b920ae62c7b1 v8.2.0078

patch 8.2.0078: expanding <sfile> works differently the second time Commit: https://github.com/vim/vim/commit/b9adef79eca6f95bc7376ff3a6a383e436c5d6ea Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 2 14:31:22 2020 +0100 patch 8.2.0078: expanding <sfile> works differently the second time Problem: Expanding <sfile> works differently the second time. Solution: Keep the expanded name when redefining a function. (closes https://github.com/vim/vim/issues/5425)
author Bram Moolenaar <Bram@vim.org>
date Thu, 02 Jan 2020 14:45:03 +0100
parents dd9ab0674eec
children af1eca322b9e
line wrap: on
line diff
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -2572,9 +2572,13 @@ ex_function(exarg_T *eap)
 	    }
 	    else
 	    {
-		// redefine existing function
+		char_u *exp_name = fp->uf_name_exp;
+
+		// redefine existing function, keep the expanded name
 		VIM_CLEAR(name);
+		fp->uf_name_exp = NULL;
 		func_clear_items(fp);
+		fp->uf_name_exp = exp_name;
 #ifdef FEAT_PROFILE
 		fp->uf_profiling = FALSE;
 		fp->uf_prof_initialized = FALSE;