mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	Merge pull request #24460 from neovim/backport-24459-to-release-0.9
[Backport release-0.9] fix(statuscolumn): don't update clicks if current width is 0
This commit is contained in:
		| @@ -679,7 +679,7 @@ static void get_statuscol_str(win_T *wp, linenr_T lnum, int virtnum, statuscol_T | ||||
|   int width = build_statuscol_str(wp, lnum, relnum, stcp); | ||||
|   // Force a redraw in case of error or when truncated | ||||
|   if (*wp->w_p_stc == NUL || (stcp->truncate > 0 && wp->w_nrwidth < MAX_NUMBERWIDTH)) { | ||||
|     if (stcp->truncate) {  // Avoid truncating 'statuscolumn' | ||||
|     if (stcp->truncate > 0) {  // Avoid truncating 'statuscolumn' | ||||
|       wp->w_nrwidth = MIN(MAX_NUMBERWIDTH, wp->w_nrwidth + stcp->truncate); | ||||
|       wp->w_nrwidth_width = wp->w_nrwidth; | ||||
|     } else {  // 'statuscolumn' reset due to error | ||||
|   | ||||
| @@ -890,7 +890,9 @@ void draw_tabline(void) | ||||
| /// @return  The width of the built status column string for line "lnum" | ||||
| int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp) | ||||
| { | ||||
|   bool fillclick = relnum >= 0 && lnum == wp->w_topline; | ||||
|   // Only update click definitions once per window per redraw. | ||||
|   // Don't update when current width is 0, since it will be redrawn again if not empty. | ||||
|   const bool fillclick = relnum >= 0 && stcp->width > 0 && lnum == wp->w_topline; | ||||
|  | ||||
|   if (relnum >= 0) { | ||||
|     set_vim_var_nr(VV_LNUM, lnum); | ||||
| @@ -903,7 +905,6 @@ int build_statuscol_str(win_T *wp, linenr_T lnum, long relnum, statuscol_T *stcp | ||||
|                                stcp->width, &stcp->hlrec, fillclick ? &clickrec : NULL, stcp); | ||||
|   xfree(stc); | ||||
|  | ||||
|   // Only update click definitions once per window per redraw | ||||
|   if (fillclick) { | ||||
|     stl_clear_click_defs(wp->w_statuscol_click_defs, wp->w_statuscol_click_defs_size); | ||||
|     wp->w_statuscol_click_defs = stl_alloc_click_defs(wp->w_statuscol_click_defs, stcp->width, | ||||
| @@ -1970,8 +1971,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n | ||||
|  | ||||
|   int width = vim_strsize(out); | ||||
|   // Return truncated width for 'statuscolumn' | ||||
|   if (stcp != NULL && width > maxwidth) { | ||||
|     stcp->truncate = width - maxwidth; | ||||
|   if (stcp != NULL && width > stcp->width) { | ||||
|     stcp->truncate = width - stcp->width; | ||||
|   } | ||||
|   if (maxwidth > 0 && width > maxwidth) { | ||||
|     // Result is too long, must truncate somewhere. | ||||
|   | ||||
| @@ -9,6 +9,7 @@ local exec_lua = helpers.exec_lua | ||||
| local feed = helpers.feed | ||||
| local meths = helpers.meths | ||||
| local pcall_err = helpers.pcall_err | ||||
| local assert_alive = helpers.assert_alive | ||||
|  | ||||
| local mousemodels = { "extend", "popup", "popup_setpos" } | ||||
|  | ||||
| @@ -575,8 +576,8 @@ describe('statuscolumn', function() | ||||
|     end) | ||||
|   end | ||||
|  | ||||
|   it('click labels do not leak memory', function() | ||||
|     command([[ | ||||
|   it('click labels do not leak memory #21878', function() | ||||
|     exec([[ | ||||
|       set laststatus=2 | ||||
|       setlocal statuscolumn=%0@MyClickFunc@abcd%T | ||||
|       4vsplit | ||||
| @@ -588,6 +589,18 @@ describe('statuscolumn', function() | ||||
|     ]]) | ||||
|   end) | ||||
|  | ||||
|   it('click labels do not crash when initial width is 0 #24428', function() | ||||
|     exec([[ | ||||
|       set nonumber | ||||
|       bwipe! | ||||
|       setlocal statuscolumn=abcd | ||||
|       redraw | ||||
|       setlocal statuscolumn=%0@MyClickFunc@abcd%T | ||||
|       redraw | ||||
|     ]]) | ||||
|     assert_alive() | ||||
|   end) | ||||
|  | ||||
|   it('works with foldcolumn', function() | ||||
|     -- Fits maximum multibyte foldcolumn #21759 | ||||
|     command([[set stc=%C%=%l\  fdc=9 fillchars=foldsep:𒀀]]) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 zeertzjq
					zeertzjq