0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.1333: when redo'ing twice <ScriptCmd> may not get the script ID

Problem:    When redo'ing twice <ScriptCmd> may not get the script ID.
Solution:   When "last_used_map" map is not set use "last_used_sid".
            (closes #11930)
This commit is contained in:
Bram Moolenaar
2023-02-20 18:44:33 +00:00
parent b444ee761a
commit 6b066c6d8f
2 changed files with 15 additions and 6 deletions

View File

@@ -3974,23 +3974,30 @@ getcmdkeycmd(
#if defined(FEAT_EVAL) || defined(PROTO) #if defined(FEAT_EVAL) || defined(PROTO)
/* /*
* If there was a mapping put info about it in the redo buffer, so that "." * If there was a mapping we get its SID. Otherwise, use "last_used_sid", it
* will use the same script context. We only need the SID. * is set when redo'ing.
* Put this SID in the redo buffer, so that "." will use the same script
* context.
*/ */
void void
may_add_last_used_map_to_redobuff(void) may_add_last_used_map_to_redobuff(void)
{ {
char_u buf[3 + 20]; char_u buf[3 + 20];
int sid = -1;
if (last_used_map == NULL || last_used_map->m_script_ctx.sc_sid < 0) if (last_used_map != NULL)
sid = last_used_map->m_script_ctx.sc_sid;
if (sid < 0)
sid = last_used_sid;
if (sid < 0)
return; return;
// <K_SID>{nr}; // <K_SID>{nr};
buf[0] = K_SPECIAL; buf[0] = K_SPECIAL;
buf[1] = KS_EXTRA; buf[1] = KS_EXTRA;
buf[2] = KE_SID; buf[2] = KE_SID;
vim_snprintf((char *)buf + 3, 20, "%d;", vim_snprintf((char *)buf + 3, 20, "%d;", sid);
last_used_map->m_script_ctx.sc_sid);
add_buff(&redobuff, buf, -1L); add_buff(&redobuff, buf, -1L);
} }
#endif #endif

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1333,
/**/ /**/
1332, 1332,
/**/ /**/