mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	fix(highlight): correct hi command output
This commit is contained in:
		@@ -824,7 +824,7 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
 | 
			
		||||
    g->sg_link = 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  g->sg_gui = attrs.rgb_ae_attr;
 | 
			
		||||
  g->sg_gui = attrs.rgb_ae_attr &~HL_DEFAULT;
 | 
			
		||||
 | 
			
		||||
  g->sg_rgb_fg = attrs.rgb_fg_color;
 | 
			
		||||
  g->sg_rgb_bg = attrs.rgb_bg_color;
 | 
			
		||||
@@ -851,7 +851,7 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  g->sg_cterm = attrs.cterm_ae_attr;
 | 
			
		||||
  g->sg_cterm = attrs.cterm_ae_attr &~HL_DEFAULT;
 | 
			
		||||
  g->sg_cterm_bg = attrs.cterm_bg_color;
 | 
			
		||||
  g->sg_cterm_fg = attrs.cterm_fg_color;
 | 
			
		||||
  g->sg_cterm_bold = g->sg_cterm & HL_BOLD;
 | 
			
		||||
@@ -1441,7 +1441,7 @@ void restore_cterm_colors(void)
 | 
			
		||||
/// @param check_link  if true also check for an existing link.
 | 
			
		||||
///
 | 
			
		||||
/// @return true if highlight group "idx" has any settings.
 | 
			
		||||
static int hl_has_settings(int idx, bool check_link)
 | 
			
		||||
static bool hl_has_settings(int idx, bool check_link)
 | 
			
		||||
{
 | 
			
		||||
  return hl_table[idx].sg_cleared == 0
 | 
			
		||||
         && (hl_table[idx].sg_attr != 0
 | 
			
		||||
 
 | 
			
		||||
@@ -608,4 +608,21 @@ describe('API: get highlight', function()
 | 
			
		||||
    meths.set_hl(0, 'Tried', { fg = "#00ff00", default = true })
 | 
			
		||||
    eq({ fg = tonumber('00ff00', 16), default = true }, meths.get_hl(0, { name = 'Tried' }))
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('should not output empty gui and cterm #23474', function()
 | 
			
		||||
    meths.set_hl(0, 'Foo', {default = true})
 | 
			
		||||
    meths.set_hl(0, 'Bar', { default = true, fg = '#ffffff' })
 | 
			
		||||
    meths.set_hl(0, 'FooBar', { default = true, fg = '#ffffff', cterm = {bold = true} })
 | 
			
		||||
    meths.set_hl(0, 'FooBarA', { default = true, fg = '#ffffff', cterm = {bold = true,italic = true}})
 | 
			
		||||
 | 
			
		||||
    eq('Foo            xxx cleared',
 | 
			
		||||
      exec_capture('highlight Foo'))
 | 
			
		||||
    eq({default = true}, meths.get_hl(0, {name = 'Foo'}))
 | 
			
		||||
    eq('Bar            xxx guifg=#ffffff',
 | 
			
		||||
      exec_capture('highlight Bar'))
 | 
			
		||||
    eq('FooBar         xxx cterm=bold guifg=#ffffff',
 | 
			
		||||
      exec_capture('highlight FooBar'))
 | 
			
		||||
    eq('FooBarA        xxx cterm=bold,italic guifg=#ffffff',
 | 
			
		||||
      exec_capture('highlight FooBarA'))
 | 
			
		||||
  end)
 | 
			
		||||
end)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user