limit maximum detail length at 1024 bytes (#1048)

This commit is contained in:
Techatrix 2023-03-11 01:06:17 +00:00 committed by GitHub
parent b8eb6aab7f
commit 3c26892c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1533,10 +1533,11 @@ pub fn formatDetailledLabel(item: *types.CompletionItem, arena: std.mem.Allocato
if (item.detail == null) if (item.detail == null)
return; return;
var detailLen: usize = item.detail.?.len; const detail = item.detail.?[0..@min(1024, item.detail.?.len)];
var detailLen: usize = detail.len;
var it: []u8 = try arena.alloc(u8, detailLen); var it: []u8 = try arena.alloc(u8, detailLen);
detailLen -= std.mem.replace(u8, item.detail.?, " ", " ", it) * 3; detailLen -= std.mem.replace(u8, detail, " ", " ", it) * 3;
it = it[0..detailLen]; it = it[0..detailLen];
// HACK: for enums 'MyEnum.', item.detail shows everything, we don't want that // HACK: for enums 'MyEnum.', item.detail shows everything, we don't want that