mirror of
https://github.com/neovim/neovim.git
synced 2026-02-20 02:18:31 +00:00
Merge #37875 prompt-buffer fixes
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "nvim/eval/typval_defs.h"
|
||||
#include "nvim/eval/window.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/macros_defs.h"
|
||||
#include "nvim/memline.h"
|
||||
@@ -790,6 +791,7 @@ void f_prompt_setprompt(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
// If for some odd reason the old prompt is missing,
|
||||
// replace prompt line with new-prompt (discards user-input).
|
||||
ml_replace_buf(buf, prompt_lno, (char *)new_prompt, true, false);
|
||||
extmark_splice_cols(buf, prompt_lno - 1, 0, old_line_len, new_prompt_len, kExtmarkUndo);
|
||||
cursor_col = new_prompt_len;
|
||||
} else {
|
||||
// Replace prev-prompt + user-input with new-prompt + user-input
|
||||
@@ -797,14 +799,15 @@ void f_prompt_setprompt(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
if (ml_replace_buf(buf, prompt_lno, new_line, false, false) != OK) {
|
||||
xfree(new_line);
|
||||
}
|
||||
extmark_splice_cols(buf, prompt_lno - 1, 0, buf->b_prompt_start.mark.col, new_prompt_len,
|
||||
kExtmarkUndo);
|
||||
cursor_col += new_prompt_len - old_prompt_len;
|
||||
}
|
||||
|
||||
if (curwin->w_buffer == buf && curwin->w_cursor.lnum == prompt_lno) {
|
||||
coladvance(curwin, cursor_col);
|
||||
curwin->w_cursor.col = cursor_col;
|
||||
}
|
||||
changed_lines_redraw_buf(buf, prompt_lno, prompt_lno + 1, 0);
|
||||
redraw_buf_later(buf, UPD_INVERTED);
|
||||
changed_lines(buf, prompt_lno, 0, prompt_lno + 1, 0, true);
|
||||
}
|
||||
|
||||
// Clear old prompt text and replace with the new one
|
||||
|
||||
Reference in New Issue
Block a user