@@ -328,7 +328,112 @@ T["get_chunks"]["sets need_to_be_under for long lines"] = function()
328328 }
329329
330330 local result = chunk .get_chunks (opts , diags , 1 , 0 , 0 , buf )
331- MiniTest .expect .equality (type (result .need_to_be_under ), " boolean" )
331+ MiniTest .expect .equality (result .need_to_be_under , true )
332+ end )
333+ end
334+
335+ T [" get_chunks" ][" does not set need_to_be_under for short lines" ] = function ()
336+ local short_line = " short"
337+ H .with_win_buf ({ short_line }, nil , 80 , function (buf , win )
338+ local opts = H .make_opts ({
339+ options = {
340+ overflow = { mode = " wrap" },
341+ multilines = { enabled = false },
342+ softwrap = 10 ,
343+ break_line = { enabled = false },
344+ show_source = { enabled = false },
345+ },
346+ })
347+ local diags = {
348+ { message = " test error" , severity = vim .diagnostic .severity .ERROR , lnum = 0 },
349+ }
350+
351+ local result = chunk .get_chunks (opts , diags , 1 , 0 , 0 , buf )
352+ MiniTest .expect .equality (result .need_to_be_under , false )
353+ end )
354+ end
355+
356+ T [" get_chunks" ][" uses display width not byte length" ] = function ()
357+ local line_with_multibyte = string.rep (" こんにちは世界" , 10 )
358+ H .with_win_buf ({ line_with_multibyte }, nil , 80 , function (buf , win )
359+ local opts = H .make_opts ({
360+ options = {
361+ overflow = { mode = " wrap" },
362+ multilines = { enabled = false },
363+ softwrap = 5 ,
364+ break_line = { enabled = false },
365+ show_source = { enabled = false },
366+ },
367+ })
368+ local diags = {
369+ { message = " test" , severity = vim .diagnostic .severity .ERROR , lnum = 0 },
370+ }
371+
372+ local result = chunk .get_chunks (opts , diags , 1 , 0 , 0 , buf )
373+ MiniTest .expect .equality (result .need_to_be_under , true )
374+ end )
375+ end
376+
377+ T [" get_chunks" ][" uses virtcol when cursor on diagnostic line" ] = function ()
378+ local line = string.rep (" x" , 50 )
379+ H .with_win_buf ({ line }, { 1 , 0 }, 80 , function (buf , win )
380+ local opts = H .make_opts ({
381+ options = {
382+ overflow = { mode = " wrap" },
383+ multilines = { enabled = false },
384+ softwrap = 10 ,
385+ break_line = { enabled = false },
386+ show_source = { enabled = false },
387+ },
388+ })
389+ local diags = {
390+ { message = " test error" , severity = vim .diagnostic .severity .ERROR , lnum = 0 },
391+ }
392+
393+ local result = chunk .get_chunks (opts , diags , 1 , 0 , 0 , buf )
394+ MiniTest .expect .equality (result .need_to_be_under , false )
395+ end )
396+ end
397+
398+ T [" get_chunks" ][" accounts for window width in wrapping decision" ] = function ()
399+ local line = string.rep (" x" , 60 )
400+ H .with_win_buf ({ line }, nil , 80 , function (buf , win )
401+ local opts = H .make_opts ({
402+ options = {
403+ overflow = { mode = " wrap" },
404+ multilines = { enabled = false },
405+ softwrap = 10 ,
406+ break_line = { enabled = false },
407+ show_source = { enabled = false },
408+ },
409+ })
410+ local diags = {
411+ { message = " test" , severity = vim .diagnostic .severity .ERROR , lnum = 0 },
412+ }
413+
414+ local result = chunk .get_chunks (opts , diags , 1 , 0 , 0 , buf )
415+ MiniTest .expect .equality (result .need_to_be_under , false )
416+ end )
417+ end
418+
419+ T [" get_chunks" ][" wraps when line exceeds window width minus softwrap" ] = function ()
420+ local line = string.rep (" x" , 80 )
421+ H .with_win_buf ({ line }, nil , 80 , function (buf , win )
422+ local opts = H .make_opts ({
423+ options = {
424+ overflow = { mode = " wrap" },
425+ multilines = { enabled = false },
426+ softwrap = 5 ,
427+ break_line = { enabled = false },
428+ show_source = { enabled = false },
429+ },
430+ })
431+ local diags = {
432+ { message = " test" , severity = vim .diagnostic .severity .ERROR , lnum = 0 },
433+ }
434+
435+ local result = chunk .get_chunks (opts , diags , 1 , 0 , 0 , buf )
436+ MiniTest .expect .equality (result .need_to_be_under , true )
332437 end )
333438end
334439
0 commit comments