vim-patch:9.1.1152: Patch v9.1.1151 causes problems

Problem:  Patch v9.1.1151 causes problems
Solution: partially revert it (John Marriott)

closes: vim/vim#16736

18bacc811c

Co-authored-by: John Marriott <basilisk@internode.on.net>
This commit is contained in:
zeertzjq
2025-02-27 08:52:38 +08:00
parent e1a3128ec4
commit f56d2b3c59
2 changed files with 10 additions and 18 deletions

View File

@@ -155,8 +155,6 @@ static uint8_t noremapbuf_init[TYPELEN_INIT]; ///< initial typebuf.tb_noremap
static size_t last_recorded_len = 0; ///< number of last recorded chars
static size_t last_get_recorded_len = 0; ///< length of the string returned from the
///< last call to get_recorded()
static size_t last_get_inserted_len = 0; ///< length of the string returned from the
///< last call to get_inserted()
@@ -230,7 +228,8 @@ static char *get_buffcont(buffheader_T *buffer, int dozero, size_t *len)
/// K_SPECIAL in the returned string is escaped.
char *get_recorded(void)
{
char *p = get_buffcont(&recordbuff, true, &last_get_recorded_len);
size_t len;
char *p = get_buffcont(&recordbuff, true, &len);
if (p == NULL) {
return NULL;
}
@@ -239,28 +238,20 @@ char *get_recorded(void)
// Remove the characters that were added the last time, these must be the
// (possibly mapped) characters that stopped the recording.
if (last_get_recorded_len >= last_recorded_len) {
last_get_recorded_len -= last_recorded_len;
p[last_get_recorded_len] = NUL;
if (len >= last_recorded_len) {
len -= last_recorded_len;
p[len] = NUL;
}
// When stopping recording from Insert mode with CTRL-O q, also remove the
// CTRL-O.
if (last_get_recorded_len > 0 && restart_edit != 0
&& p[last_get_recorded_len - 1] == Ctrl_O) {
last_get_recorded_len--;
p[last_get_recorded_len] = NUL;
if (len > 0 && restart_edit != 0 && p[len - 1] == Ctrl_O) {
p[len - 1] = NUL;
}
return p;
}
/// Return the length of string returned from the last call of get_recorded().
size_t get_recorded_len(void)
{
return last_get_recorded_len;
}
/// Return the contents of the redo buffer as a single string.
/// K_SPECIAL in the returned string is escaped.
char *get_inserted(void)

View File

@@ -1039,7 +1039,7 @@ int do_record(int c)
// restore the current register name.
yankreg_T *old_y_previous = y_previous;
retval = stuff_yank(regname, p, get_recorded_len());
retval = stuff_yank(regname, p);
y_previous = old_y_previous;
}
@@ -1051,7 +1051,7 @@ int do_record(int c)
/// uppercase). "p" must have been allocated.
///
/// @return FAIL for failure, OK otherwise
static int stuff_yank(int regname, char *p, size_t plen)
static int stuff_yank(int regname, char *p)
{
// check for read-only register
if (regname != 0 && !valid_yank_reg(regname, true)) {
@@ -1063,6 +1063,7 @@ static int stuff_yank(int regname, char *p, size_t plen)
return OK;
}
const size_t plen = strlen(p);
yankreg_T *reg = get_yank_register(regname, YREG_YANK);
if (is_append_register(regname) && reg->y_array != NULL) {
String *pp = &(reg->y_array[reg->y_size - 1]);