vim-patch:9.1.1633: Search pattern shown incorrectly with negative offset (#35337)

Problem:  Search pattern shown incorrectly with negative offset.
          (lkintact)
Solution: Don't prepend a '+' sign to a negative offset (zeertzjq).

fixes: vim/vim#17993
closes: vim/vim#17994

ade0815856
This commit is contained in:
zeertzjq
2025-08-15 08:06:32 +08:00
committed by GitHub
parent 7afcfb6c9a
commit 8d154e5927
2 changed files with 73 additions and 16 deletions

View File

@@ -1209,13 +1209,10 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, size_t patlen
} else if (!spats[0].off.line) {
off_buf[off_len++] = 's';
}
if (spats[0].off.off > 0 || spats[0].off.line) {
off_buf[off_len++] = '+';
}
off_buf[off_len] = NUL;
if (spats[0].off.off != 0 || spats[0].off.line) {
off_len += (size_t)snprintf(off_buf + off_len, sizeof(off_buf) - off_len,
"%" PRId64, spats[0].off.off);
"%+" PRId64, spats[0].off.off);
}
}