@@ -288,6 +288,7 @@ T["get_chunks"]["returns chunk info for diagnostic"] = function()
288288 softwrap = 10 ,
289289 break_line = { enabled = false },
290290 show_source = { enabled = false },
291+ show_code = false ,
291292 },
292293 })
293294 local diags = {
@@ -312,6 +313,7 @@ T["get_chunks"]["includes source when show_source is enabled"] = function()
312313 softwrap = 10 ,
313314 break_line = { enabled = false },
314315 show_source = { enabled = true },
316+ show_code = false ,
315317 },
316318 })
317319 local diags = {
@@ -326,6 +328,35 @@ T["get_chunks"]["includes source when show_source is enabled"] = function()
326328 local result = chunk .get_chunks (opts , diags , 1 , 0 , 0 , buf )
327329 local full_message = table.concat (result .chunks , " " )
328330 MiniTest .expect .equality (full_message :find (" test_lsp" ) ~= nil , true )
331+ MiniTest .expect .equality (full_message :find (" E308" ) ~= nil , false )
332+ end )
333+ end
334+
335+ T [" get_chunks" ][" includes code when show_code is enabled" ] = function ()
336+ H .with_buf ({ " test line" }, function (buf )
337+ local opts = H .make_opts ({
338+ options = {
339+ overflow = { mode = " none" },
340+ multilines = { enabled = false },
341+ softwrap = 10 ,
342+ break_line = { enabled = false },
343+ show_source = { enabled = true },
344+ show_code = true ,
345+ },
346+ })
347+ local diags = {
348+ {
349+ message = " test error" ,
350+ severity = vim .diagnostic .severity .ERROR ,
351+ lnum = 0 ,
352+ source = " test_lsp" ,
353+ code = " E308" ,
354+ },
355+ }
356+
357+ local result = chunk .get_chunks (opts , diags , 1 , 0 , 0 , buf )
358+ local full_message = table.concat (result .chunks , " " )
359+ MiniTest .expect .equality (full_message :find (" %[E308%] %(test_lsp%)" ) ~= nil , true )
329360 end )
330361end
331362
@@ -339,6 +370,7 @@ T["get_chunks"]["sets need_to_be_under for long lines"] = function()
339370 softwrap = 10 ,
340371 break_line = { enabled = false },
341372 show_source = { enabled = false },
373+ show_code = false ,
342374 },
343375 })
344376 local diags = {
@@ -360,6 +392,7 @@ T["get_chunks"]["does not set need_to_be_under for short lines"] = function()
360392 softwrap = 10 ,
361393 break_line = { enabled = false },
362394 show_source = { enabled = false },
395+ show_code = false ,
363396 },
364397 })
365398 local diags = {
@@ -381,6 +414,7 @@ T["get_chunks"]["uses display width not byte length"] = function()
381414 softwrap = 5 ,
382415 break_line = { enabled = false },
383416 show_source = { enabled = false },
417+ show_code = false ,
384418 },
385419 })
386420 local diags = {
@@ -402,6 +436,7 @@ T["get_chunks"]["uses virtcol when cursor on diagnostic line"] = function()
402436 softwrap = 10 ,
403437 break_line = { enabled = false },
404438 show_source = { enabled = false },
439+ show_code = false ,
405440 },
406441 })
407442 local diags = {
@@ -423,6 +458,7 @@ T["get_chunks"]["accounts for window width in wrapping decision"] = function()
423458 softwrap = 10 ,
424459 break_line = { enabled = false },
425460 show_source = { enabled = false },
461+ show_code = false ,
426462 },
427463 })
428464 local diags = {
@@ -444,6 +480,7 @@ T["get_chunks"]["wraps when line exceeds window width minus softwrap"] = functio
444480 softwrap = 5 ,
445481 break_line = { enabled = false },
446482 show_source = { enabled = false },
483+ show_code = false ,
447484 },
448485 })
449486 local diags = {
0 commit comments