mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
fix(prompt): "%" prefix repeated on newlines with formatoptions+=r #34584
Problem: With `formatoptions+=r`, the prompt prefix "%" is treated as comment-start (because of global default 'comments' option contains "%"), so it gets added to the start of the line when a new line is input in a prompt. Solution: Unset the 'comments' option in prompt buffers by default.
This commit is contained in:
@ -696,8 +696,11 @@ const char *did_set_buftype(optset_T *args)
|
||||
|| opt_strings_flags(buf->b_p_bt, opt_bt_values, NULL, false) != OK) {
|
||||
return e_invarg;
|
||||
}
|
||||
// buftype=prompt: set the prompt start position to lastline.
|
||||
// buftype=prompt:
|
||||
if (buf->b_p_bt[0] == 'p') {
|
||||
// Set default value for 'comments'
|
||||
set_option_direct(kOptComments, STATIC_CSTR_AS_OPTVAL(""), OPT_LOCAL, SID_NONE);
|
||||
// set the prompt start position to lastline.
|
||||
pos_T next_prompt = { .lnum = buf->b_ml.ml_line_count, .col = 1, .coladd = 0 };
|
||||
RESET_FMARK(&buf->b_prompt_start, next_prompt, 0, ((fmarkv_T)INIT_FMARKV));
|
||||
}
|
||||
|
@ -273,6 +273,22 @@ describe('prompt buffer', function()
|
||||
{1:~ }|*3
|
||||
{5:-- INSERT --} |
|
||||
]])
|
||||
|
||||
-- % prompt is not repeated with formatoptions+=r
|
||||
source([[
|
||||
bwipeout!
|
||||
set formatoptions+=r
|
||||
set buftype=prompt
|
||||
call prompt_setprompt(bufnr(), "% ")
|
||||
]])
|
||||
feed('iline1<s-cr>line2')
|
||||
screen:expect([[
|
||||
other buffer |
|
||||
% line1 |
|
||||
line2^ |
|
||||
{1:~ }|*6
|
||||
{5:-- INSERT --} |
|
||||
]])
|
||||
end)
|
||||
|
||||
it('can put (p) multiline text', function()
|
||||
|
Reference in New Issue
Block a user