fix(prompt): cursor on prompt line, disallow ":edit" #34736

* fix: ensure :edit can not be use on prompt buffer
* fix: starting editing on prompt-line doesn't put cursor at the end
This commit is contained in:
Shadman
2025-07-30 07:36:01 +06:00
committed by GitHub
parent 1256daeead
commit 807a65b2da
4 changed files with 57 additions and 3 deletions

View File

@@ -1532,7 +1532,10 @@ static void init_prompt(int cmdchar_todo)
{
char *prompt = prompt_text();
if (curwin->w_cursor.lnum < curbuf->b_prompt_start.mark.lnum) {
if (curwin->w_cursor.lnum < curbuf->b_prompt_start.mark.lnum
|| (cmdchar_todo != 'O'
&& curwin->w_cursor.lnum == curbuf->b_prompt_start.mark.lnum
&& (curwin->w_cursor.col < (int)strlen(prompt_text())))) {
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
coladvance(curwin, MAXCOL);
}

View File

@@ -5718,6 +5718,12 @@ static void ex_edit(exarg_T *eap)
return;
}
// prevent use of :edit on prompt-buffers
if (bt_prompt(curbuf) && eap->cmdidx == CMD_edit && *eap->arg == NUL) {
emsg("cannot :edit a prompt buffer");
return;
}
do_exedit(eap, NULL);
}