fix(mouse): early return when clicking in padded 'statuscolumn' (#29394)

Problem:  Hit assert when clicking inside a padded 'statuscolumn' that
          is padded beyond the length of the allocated click_defs.
Solution: Still consider this a "in_statuscol" click, but return early
          when about to execute the click func.
This commit is contained in:
luukvbaal 2024-06-19 00:00:39 +02:00 committed by GitHub
parent 2791fd4e17
commit 102971a396
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -688,6 +688,9 @@ popupexit:
if (in_statuscol && wp->w_p_rl) { if (in_statuscol && wp->w_p_rl) {
click_col = wp->w_width_inner - click_col - 1; click_col = wp->w_width_inner - click_col - 1;
} }
if (in_statuscol && click_col >= (int)wp->w_statuscol_click_defs_size) {
return false;
}
if (click_defs != NULL) { if (click_defs != NULL) {
switch (click_defs[click_col].type) { switch (click_defs[click_col].type) {

View File

@ -91,6 +91,10 @@ describe('statuscolumn', function()
{8:2 }aaaaa | {8:2 }aaaaa |
| |
]]) ]])
-- Doesn't crash when clicking inside padded area without click_defs
command('set numberwidth=10')
api.nvim_input_mouse('left', 'press', '', 0, 0, 5)
assert_alive()
end) end)
it("works with 'number' and 'relativenumber'", function() it("works with 'number' and 'relativenumber'", function()