fix(prompt): wrong changed lnum in init_prompt

Problem: if init_prompt replaces the prompt line at the ': mark, it calls
inserted_bytes with the wrong lnum.

Solution: use the correct lnum. Call appended_lines_mark instead when appending
the prompt at the end.
This commit is contained in:
Sean Dewar
2026-02-15 17:02:40 +00:00
parent 3a10405214
commit 51dc752e6c
3 changed files with 29 additions and 2 deletions

View File

@@ -1609,14 +1609,16 @@ static void init_prompt(int cmdchar_todo)
// prompt is missing, insert it or append a line with it
if (*text == NUL) {
ml_replace(curbuf->b_prompt_start.mark.lnum, prompt, true);
inserted_bytes(curbuf->b_prompt_start.mark.lnum, 0, 0, prompt_len);
} else {
ml_append(curbuf->b_ml.ml_line_count, prompt, 0, false);
const linenr_T lnum = curbuf->b_ml.ml_line_count;
ml_append(lnum, prompt, 0, false);
appended_lines_mark(lnum, 1);
curbuf->b_prompt_start.mark.lnum = curbuf->b_ml.ml_line_count;
}
curbuf->b_prompt_start.mark.col = prompt_len;
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
coladvance(curwin, MAXCOL);
inserted_bytes(curbuf->b_ml.ml_line_count, 0, 0, (colnr_T)prompt_len);
}
// Insert always starts after the prompt, allow editing text after it.