mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(ui): fix cursor position with multiple inline virtual text
vim-patch9.0.0121: cannot put virtual text after or below a line
Problem:    Cannot put virtual text after or below a line.
Solution:   Add "text_align" and "text_wrap" arguments.
b7963df98f
This only patches the fix, not the whole thing.
			
			
This commit is contained in:
		| @@ -1796,8 +1796,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, | |||||||
|       if (has_decor && v >= 0) { |       if (has_decor && v >= 0) { | ||||||
|         bool selected = (area_active || (area_highlighting && noinvcur |         bool selected = (area_active || (area_highlighting && noinvcur | ||||||
|                                          && wlv.vcol == wp->w_virtcol)); |                                          && wlv.vcol == wp->w_virtcol)); | ||||||
|         extmark_attr = decor_redraw_col(wp, (colnr_T)v, wlv.off, |         extmark_attr = decor_redraw_col(wp, (colnr_T)v, wlv.off, selected, &decor_state); | ||||||
|                                             selected, &decor_state); |  | ||||||
|  |  | ||||||
|         // we could already be inside an existing virt_line with multiple chunks |         // we could already be inside an existing virt_line with multiple chunks | ||||||
|         if (!(virt_inline_i < kv_size(virt_inline))) { |         if (!(virt_inline_i < kv_size(virt_inline))) { | ||||||
|   | |||||||
| @@ -396,12 +396,13 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) | |||||||
|       mtkey_t mark = marktree_itr_current(cts->cts_iter); |       mtkey_t mark = marktree_itr_current(cts->cts_iter); | ||||||
|       if (mark.pos.row != cts->cts_row || mark.pos.col > col) { |       if (mark.pos.row != cts->cts_row || mark.pos.col > col) { | ||||||
|         break; |         break; | ||||||
|       } else if (mark.pos.col == col) { // TODO: or maybe unconditionally, what if byte-misaligned? |       } else if (mark.pos.col | ||||||
|  |                  == col) {  // TODO(bfredl): or maybe unconditionally, what if byte-misaligned? | ||||||
|         if (!mt_end(mark)) { |         if (!mt_end(mark)) { | ||||||
|           Decoration decor = get_decor(mark); |           Decoration decor = get_decor(mark); | ||||||
|           if (decor.virt_text_pos == kVTInline) { |           if (decor.virt_text_pos == kVTInline) { | ||||||
|             cts->cts_cur_text_width = decor.virt_text_width; |             cts->cts_cur_text_width += decor.virt_text_width; | ||||||
|             size += cts->cts_cur_text_width; |             size += decor.virt_text_width; | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -1245,6 +1245,33 @@ end]] | |||||||
|                                                               | |                                                               | | ||||||
|     ]]} |     ]]} | ||||||
|   end) |   end) | ||||||
|  |  | ||||||
|  |   it('cursor positions are correct with multiple inline virtual text', function() | ||||||
|  |     insert('12345678') | ||||||
|  |     meths.buf_set_extmark(0, ns, 0, 4, | ||||||
|  |         { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) | ||||||
|  |     meths.buf_set_extmark(0, ns, 0, 4, | ||||||
|  |         { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) | ||||||
|  |     feed '^' | ||||||
|  |     feed '4l' | ||||||
|  |         screen:expect { grid = [[ | ||||||
|  |       1234{28: virtual text  virtual text }^5678              | | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |       {1:~                                                 }| | ||||||
|  |                                                         | | ||||||
|  |       ]]} | ||||||
|  |   end) | ||||||
| end) | end) | ||||||
|  |  | ||||||
| describe('decorations: virtual lines', function() | describe('decorations: virtual lines', function() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ibby
					Ibby