diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index d25f60da0e..9d36418693 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -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)); } diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index a24e1b0b9c..0f49b8833a 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -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('iline1line2') + screen:expect([[ + other buffer | + % line1 | + line2^ | + {1:~ }|*6 + {5:-- INSERT --} | + ]]) end) it('can put (p) multiline text', function()