fix(api): single-line visual block insert triggers extra on_lines #35098

Problem: Visual block insert on a single line incorrectly triggers two
on_lines callbacks - one for the correct line (0-indexed) and another
for a non-existent additional line.

Solution: Only call changed_lines() in block_insert() when additional
lines beyond the first were actually modified (start.lnum < end.lnum).
This commit is contained in:
glepnir
2025-07-29 21:24:44 +08:00
committed by GitHub
parent 029b7a149f
commit 15d57ab0ba
2 changed files with 18 additions and 1 deletions

View File

@@ -710,7 +710,11 @@ static void block_insert(oparg_T *oap, const char *s, size_t slen, bool b_insert
State = oldstate;
changed_lines(curbuf, oap->start.lnum + 1, 0, oap->end.lnum + 1, 0, true);
// Only call changed_lines if we actually modified additional lines beyond the first
// This matches the condition for the for loop above: start + 1 <= end
if (oap->start.lnum < oap->end.lnum) {
changed_lines(curbuf, oap->start.lnum + 1, 0, oap->end.lnum + 1, 0, true);
}
}
// Keep the last expression line here, for repeating.