mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	fix(ui): adjust the cursor when inserting virtual text
Credit to: Jesse Bakker https://github.com/neovim/neovim/pull/20130#issuecomment-1369652743 Co-authored-by: Jesse Bakker <github@jessebakker.com>
This commit is contained in:
		@@ -83,6 +83,9 @@ void decor_redraw(buf_T *buf, int row1, int row2, Decoration *decor)
 | 
			
		||||
 | 
			
		||||
  if (decor && decor_virt_pos(*decor)) {
 | 
			
		||||
    redraw_buf_line_later(buf, row1 + 1, false);
 | 
			
		||||
    if (decor->virt_text_pos == kVTInline) {
 | 
			
		||||
      changed_line_display_buf(buf);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (decor && kv_size(decor->virt_lines)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1272,6 +1272,32 @@ end]]
 | 
			
		||||
                                                        |
 | 
			
		||||
      ]]}
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('adjusts cursor location correctly when inserting around inline virtual text', function()
 | 
			
		||||
        insert('12345678')
 | 
			
		||||
        feed '$'
 | 
			
		||||
        meths.buf_set_extmark(0, ns, 0, 4,
 | 
			
		||||
            { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
 | 
			
		||||
 | 
			
		||||
        screen:expect { grid = [[
 | 
			
		||||
      1234{28: virtual text }567^8                            |
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
      {1:~                                                 }|
 | 
			
		||||
                                                        |
 | 
			
		||||
      ]]
 | 
			
		||||
        }
 | 
			
		||||
  end)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
describe('decorations: virtual lines', function()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user