mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	fix(messages): verbose kind for nvim_echo()
Problem: No "verbose" kind for nvim_echo() opts->verbose. Solution: Pass NULL "kind" to indicate no new kind.
This commit is contained in:
		@@ -772,7 +772,8 @@ void nvim_echo(Array chunks, Boolean history, Dict(echo_opts) *opts, Error *err)
 | 
				
			|||||||
    verbose_enter();
 | 
					    verbose_enter();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  msg_multihl(hl_msg, opts->err ? "echoerr" : history ? "echomsg" : "echo", history, opts->err);
 | 
					  char *kind = opts->verbose ? NULL : opts->err ? "echoerr" : history ? "echomsg" : "echo";
 | 
				
			||||||
 | 
					  msg_multihl(hl_msg, kind, history, opts->err);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (opts->verbose) {
 | 
					  if (opts->verbose) {
 | 
				
			||||||
    verbose_leave();
 | 
					    verbose_leave();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -296,6 +296,12 @@ void msg_multiline(String str, int hl_id, bool check_int, bool hist, bool *need_
 | 
				
			|||||||
// Avoid starting a new message for each chunk and adding message to history in msg_keep().
 | 
					// Avoid starting a new message for each chunk and adding message to history in msg_keep().
 | 
				
			||||||
static bool is_multihl = false;
 | 
					static bool is_multihl = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Print message chunks, each with their own highlight ID.
 | 
				
			||||||
 | 
					///
 | 
				
			||||||
 | 
					/// @param hl_msg Message chunks
 | 
				
			||||||
 | 
					/// @param kind Message kind (can be NULL to avoid setting kind)
 | 
				
			||||||
 | 
					/// @param history Whether to add message to history
 | 
				
			||||||
 | 
					/// @param err Whether to print message as an error
 | 
				
			||||||
void msg_multihl(HlMessage hl_msg, const char *kind, bool history, bool err)
 | 
					void msg_multihl(HlMessage hl_msg, const char *kind, bool history, bool err)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  no_wait_return++;
 | 
					  no_wait_return++;
 | 
				
			||||||
@@ -303,7 +309,9 @@ void msg_multihl(HlMessage hl_msg, const char *kind, bool history, bool err)
 | 
				
			|||||||
  msg_clr_eos();
 | 
					  msg_clr_eos();
 | 
				
			||||||
  bool need_clear = false;
 | 
					  bool need_clear = false;
 | 
				
			||||||
  msg_ext_history = history;
 | 
					  msg_ext_history = history;
 | 
				
			||||||
 | 
					  if (kind != NULL) {
 | 
				
			||||||
    msg_ext_set_kind(kind);
 | 
					    msg_ext_set_kind(kind);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  is_multihl = true;
 | 
					  is_multihl = true;
 | 
				
			||||||
  for (uint32_t i = 0; i < kv_size(hl_msg); i++) {
 | 
					  for (uint32_t i = 0; i < kv_size(hl_msg); i++) {
 | 
				
			||||||
    HlMessageChunk chunk = kv_A(hl_msg, i);
 | 
					    HlMessageChunk chunk = kv_A(hl_msg, i);
 | 
				
			||||||
@@ -312,7 +320,7 @@ void msg_multihl(HlMessage hl_msg, const char *kind, bool history, bool err)
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      msg_multiline(chunk.text, chunk.hl_id, true, false, &need_clear);
 | 
					      msg_multiline(chunk.text, chunk.hl_id, true, false, &need_clear);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    assert(!ui_has(kUIMessages) || msg_ext_kind == kind);
 | 
					    assert(!ui_has(kUIMessages) || kind == NULL || msg_ext_kind == kind);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (history && kv_size(hl_msg)) {
 | 
					  if (history && kv_size(hl_msg)) {
 | 
				
			||||||
    add_msg_hist_multihl(NULL, 0, 0, true, hl_msg);
 | 
					    add_msg_hist_multihl(NULL, 0, 0, true, hl_msg);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -319,9 +319,7 @@ describe('ui/ext_messages', function()
 | 
				
			|||||||
    -- kind=echoerr for nvim_echo() err
 | 
					    -- kind=echoerr for nvim_echo() err
 | 
				
			||||||
    feed(':call nvim_echo([["Error"], ["Message", "Special"]], 1, #{ err:1 })<CR>')
 | 
					    feed(':call nvim_echo([["Error"], ["Message", "Special"]], 1, #{ err:1 })<CR>')
 | 
				
			||||||
    screen:expect({
 | 
					    screen:expect({
 | 
				
			||||||
      cmdline = { {
 | 
					      cmdline = { { abort = false } },
 | 
				
			||||||
        abort = false,
 | 
					 | 
				
			||||||
      } },
 | 
					 | 
				
			||||||
      messages = {
 | 
					      messages = {
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          content = { { 'Error', 9, 6 }, { 'Message', 16, 99 } },
 | 
					          content = { { 'Error', 9, 6 }, { 'Message', 16, 99 } },
 | 
				
			||||||
@@ -331,12 +329,23 @@ describe('ui/ext_messages', function()
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    -- kind=verbose for nvim_echo() verbose
 | 
				
			||||||
 | 
					    feed(':call nvim_echo([["Verbose Message"]], 1, #{ verbose:1 })<CR>')
 | 
				
			||||||
 | 
					    screen:expect({
 | 
				
			||||||
 | 
					      cmdline = { { abort = false } },
 | 
				
			||||||
 | 
					      messages = {
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          content = { { 'Verbose Message' } },
 | 
				
			||||||
 | 
					          history = true,
 | 
				
			||||||
 | 
					          kind = 'verbose',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- kind=verbose for :verbose messages
 | 
					    -- kind=verbose for :verbose messages
 | 
				
			||||||
    feed(':1verbose filter Diff[AC] hi<CR>')
 | 
					    feed(':1verbose filter Diff[AC] hi<CR>')
 | 
				
			||||||
    screen:expect({
 | 
					    screen:expect({
 | 
				
			||||||
      cmdline = { {
 | 
					      cmdline = { { abort = false } },
 | 
				
			||||||
        abort = false,
 | 
					 | 
				
			||||||
      } },
 | 
					 | 
				
			||||||
      messages = {
 | 
					      messages = {
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          content = {
 | 
					          content = {
 | 
				
			||||||
@@ -387,9 +396,7 @@ describe('ui/ext_messages', function()
 | 
				
			|||||||
      or '{ echo stdout; echo stderr >&2; exit 3; }'
 | 
					      or '{ echo stdout; echo stderr >&2; exit 3; }'
 | 
				
			||||||
    feed(('<CR>:!%s<CR>'):format(cmd))
 | 
					    feed(('<CR>:!%s<CR>'):format(cmd))
 | 
				
			||||||
    screen:expect({
 | 
					    screen:expect({
 | 
				
			||||||
      cmdline = { {
 | 
					      cmdline = { { abort = false } },
 | 
				
			||||||
        abort = false,
 | 
					 | 
				
			||||||
      } },
 | 
					 | 
				
			||||||
      messages = {
 | 
					      messages = {
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          content = { { (':!%s\r\n[No write since last change]\n'):format(cmd) } },
 | 
					          content = { { (':!%s\r\n[No write since last change]\n'):format(cmd) } },
 | 
				
			||||||
@@ -1126,9 +1133,7 @@ describe('ui/ext_messages', function()
 | 
				
			|||||||
        ^                         |
 | 
					        ^                         |
 | 
				
			||||||
        {1:~                        }|*4
 | 
					        {1:~                        }|*4
 | 
				
			||||||
      ]],
 | 
					      ]],
 | 
				
			||||||
      cmdline = { {
 | 
					      cmdline = { { abort = false } },
 | 
				
			||||||
        abort = false,
 | 
					 | 
				
			||||||
      } },
 | 
					 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    eq(0, eval('&cmdheight'))
 | 
					    eq(0, eval('&cmdheight'))
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user