robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each , pending =t . describe , t . it , t . before_each , t . pending 6local clear =n . clear 7local feed =n . feed 8local insert =n . insert 9local exec_lua =n . exec_lua 10local exec =n . exec 11local expect_events =t . expect_events 12local api =n . api 13local fn =n . fn 14local command =n . command 15local eq =t . eq 16local assert_alive =n . assert_alive 17local pcall_err =t . pcall_err 18 19--- @return integer 20local function setup_provider ( code ) 21return exec_lua ( [[ 22local api = vim.api 23_G.ns1 = api.nvim_create_namespace "ns1" 24]] .. ( code or [[ 25beamtrace = {} 26local function on_do(kind, ...) 27table.insert(beamtrace, {kind, ...}) 28end 29]] ) .. [[ 30api.nvim_set_decoration_provider(_G.ns1, { 31on_start = on_do; on_buf = on_do; 32on_win = on_do; on_line = on_do; on_range = on_do; 33on_end = on_do; _on_spell_nav = on_do; 34}) 35return _G.ns1 36]] ) 37end 38 39local function setup_screen ( screen ) 40screen : set_default_attr_ids { 41[ 1 ] ={ bold =true , foreground =Screen . colors . Blue } , 42[ 2 ] ={ foreground =Screen . colors . Grey100 , background =Screen . colors . Red } , 43[ 3 ] ={ foreground =Screen . colors . Brown } , 44[ 4 ] ={ foreground =Screen . colors . Blue1 } , 45[ 5 ] ={ foreground =Screen . colors . Magenta } , 46[ 6 ] ={ bold =true , foreground =Screen . colors . Brown } , 47[ 7 ] ={ background =Screen . colors . Gray90 } , 48[ 8 ] ={ bold =true , reverse =true } , 49[ 9 ] ={ reverse =true } , 50[ 10 ] ={ italic =true , background =Screen . colors . Magenta } , 51[ 11 ] ={ foreground =Screen . colors . Red , background =tonumber ( '0x005028' ) } , 52[ 12 ] ={ foreground =tonumber ( '0x990000' ) } , 53[ 13 ] ={ background =Screen . colors . LightBlue } , 54[ 14 ] ={ background =Screen . colors . WebGray , foreground =Screen . colors . DarkBlue } , 55[ 15 ] ={ special =Screen . colors . Blue , undercurl =true } , 56[ 16 ] ={ special =Screen . colors . Red , undercurl =true } , 57[ 17 ] ={ foreground =Screen . colors . Red } , 58[ 18 ] ={ bold =true , foreground =Screen . colors . SeaGreen } , 59[ 19 ] ={ bold =true } , 60[ 20 ] ={ foreground =Screen . colors . Grey0 , background =Screen . colors . LightGrey } , 61} 62end 63 64describe ( 'decorations providers' , function () 65local screen ---@type test.functional.ui.screen 66before_each ( function () 67clear () 68screen =Screen . new ( 40 , 8 ) 69setup_screen ( screen ) 70end ) 71 72local mulholland =[[ 73// just to see if there was an accident 74// on Mulholland Drive 75try_start(); 76bufref_T save_buf; 77switch_buffer(&save_buf, buf); 78posp = getmark(mark, false); 79restore_buffer(&save_buf); ]] 80 81local function check_trace ( expected ) 82local actual =exec_lua [[ local b = beamtrace beamtrace = {} return b ]] 83expect_events ( expected , actual , 'beam trace' ) 84end 85 86it ( 'does not OOM when inserting, rather than appending, to the decoration provider vector' , function () 87-- Add a dummy decoration provider with a larger ns id than what setup_provider() creates. 88-- This forces get_decor_provider() to insert into the providers vector, 89-- rather than append, which used to spin in an infinite loop allocating 90-- memory until nvim crashed/was killed. 91setup_provider ( [[ 92local ns2 = api.nvim_create_namespace "ns2" 93api.nvim_set_decoration_provider(ns2, {}) 94]] ) 95assert_alive () 96end ) 97 98it ( 'leave a trace' , function () 99insert ( mulholland ) 100 101setup_provider () 102 103screen : expect { 104grid =[[ 105// just to see if there was an accident | 106// on Mulholland Drive | 107try_start(); | 108bufref_T save_buf; | 109switch_buffer(&save_buf, buf); | 110posp = getmark(mark, false); | 111restore_buffer(&save_buf);^ | 112| 113]] , 114} 115check_trace { 116{ 'start' , 4 } , 117{ 'win' , 1000 , 1 , 0 , 6 } , 118{ 'line' , 1000 , 1 , 0 } , 119{ 'range' , 1000 , 1 , 0 , 0 , 1 , 0 } , 120{ 'line' , 1000 , 1 , 1 } , 121{ 'range' , 1000 , 1 , 1 , 0 , 2 , 0 } , 122{ 'line' , 1000 , 1 , 2 } , 123{ 'range' , 1000 , 1 , 2 , 0 , 3 , 0 } , 124{ 'line' , 1000 , 1 , 3 } , 125{ 'range' , 1000 , 1 , 3 , 0 , 4 , 0 } , 126{ 'line' , 1000 , 1 , 4 } , 127{ 'range' , 1000 , 1 , 4 , 0 , 5 , 0 } , 128{ 'line' , 1000 , 1 , 5 } , 129{ 'range' , 1000 , 1 , 5 , 0 , 6 , 0 } , 130{ 'line' , 1000 , 1 , 6 } , 131{ 'range' , 1000 , 1 , 6 , 0 , 7 , 0 } , 132{ 'end' , 4 } , 133} 134 135feed 'iü<esc>' 136screen : expect { 137grid =[[ 138// just to see if there was an accident | 139// on Mulholland Drive | 140try_start(); | 141bufref_T save_buf; | 142switch_buffer(&save_buf, buf); | 143posp = getmark(mark, false); | 144restore_buffer(&save_buf);^ü | 145| 146]] , 147} 148check_trace { 149{ 'start' , 5 } , 150{ 'buf' , 1 , 5 } , 151{ 'win' , 1000 , 1 , 0 , 6 } , 152{ 'line' , 1000 , 1 , 6 } , 153{ 'range' , 1000 , 1 , 6 , 0 , 7 , 0 } , 154{ 'end' , 5 } , 155} 156end ) 157 158it ( 'can have single provider' , function () 159insert ( mulholland ) 160setup_provider [[ 161local hl = api.nvim_get_hl_id_by_name "ErrorMsg" 162local test_ns = api.nvim_create_namespace "mulholland" 163function on_do(event, ...) 164if event == "line" then 165local win, buf, line = ... 166api.nvim_buf_set_extmark(buf, test_ns, line, line, 167{ end_line = line, end_col = line+1, 168hl_group = hl, 169ephemeral = true 170}) 171end 172end 173]] 174 175screen : expect { 176grid =[[ 177{2:/}/ just to see if there was an accident | 178/{2:/} on Mulholland Drive | 179tr{2:y}_start(); | 180buf{2:r}ef_T save_buf; | 181swit{2:c}h_buffer(&save_buf, buf); | 182posp {2:=} getmark(mark, false); | 183restor{2:e}_buffer(&save_buf);^ | 184| 185]] , 186} 187end ) 188 189it ( 'can indicate spellchecked points' , function () 190exec [[ 191set spell 192set spelloptions=noplainbuffer 193syntax off 194]] 195 196insert [[ 197I am well written text. 198i am not capitalized. 199I am a speling mistakke. 200]] 201 202setup_provider [[ 203local ns = api.nvim_create_namespace "spell" 204beamtrace = {} 205local function on_do(kind, ...) 206if kind == 'win' or kind == 'spell' then 207api.nvim_buf_set_extmark(0, ns, 0, 0, { 208end_row = 2, 209end_col = 23, 210spell = true, 211priority = 20, 212ephemeral = true 213}) 214end 215table.insert(beamtrace, {kind, ...}) 216end 217]] 218 219check_trace { 220{ 'start' , 5 } , 221{ 'win' , 1000 , 1 , 0 , 3 } , 222{ 'line' , 1000 , 1 , 0 } , 223{ 'range' , 1000 , 1 , 0 , 0 , 1 , 0 } , 224{ 'line' , 1000 , 1 , 1 } , 225{ 'range' , 1000 , 1 , 1 , 0 , 2 , 0 } , 226{ 'line' , 1000 , 1 , 2 } , 227{ 'range' , 1000 , 1 , 2 , 0 , 3 , 0 } , 228{ 'line' , 1000 , 1 , 3 } , 229{ 'range' , 1000 , 1 , 3 , 0 , 4 , 0 } , 230{ 'end' , 5 } , 231} 232 233feed 'gg0' 234 235screen : expect { 236grid =[[ 237^I am well written text. | 238{15:i} am not capitalized. | 239I am a {16:speling} {16:mistakke}. | 240| 241{1:~ }|*3 242| 243]] , 244} 245 246feed ']s' 247check_trace { 248{ 'spell' , 1000 , 1 , 1 , 0 , 1 , - 1 } , 249} 250screen : expect { 251grid =[[ 252I am well written text. | 253{15:^i} am not capitalized. | 254I am a {16:speling} {16:mistakke}. | 255| 256{1:~ }|*3 257| 258]] , 259} 260 261feed ']s' 262check_trace { 263{ 'spell' , 1000 , 1 , 2 , 7 , 2 , - 1 } , 264} 265screen : expect { 266grid =[[ 267I am well written text. | 268{15:i} am not capitalized. | 269I am a {16:^speling} {16:mistakke}. | 270| 271{1:~ }|*3 272| 273]] , 274} 275 276-- spell=false with higher priority does disable spell 277local ns =api . nvim_create_namespace 'spell' 278local id =api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { priority =30 , end_row =2 , end_col =23 , spell =false } ) 279 280screen : expect { 281grid =[[ 282I am well written text. | 283i am not capitalized. | 284I am a ^speling mistakke. | 285| 286{1:~ }|*3 287| 288]] , 289} 290 291feed ']s' 292screen : expect { 293grid =[[ 294I am well written text. | 295i am not capitalized. | 296I am a ^speling mistakke. | 297| 298{1:~ }|*3 299{17:search hit BOTTOM, continuing at TOP} | 300]] , 301} 302command ( 'echo ""' ) 303 304-- spell=false with lower priority doesn't disable spell 305api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { id =id , priority =10 , end_row =2 , end_col =23 , spell =false } ) 306 307screen : expect { 308grid =[[ 309I am well written text. | 310{15:i} am not capitalized. | 311I am a {16:^speling} {16:mistakke}. | 312| 313{1:~ }|*3 314| 315]] , 316} 317 318feed ']s' 319screen : expect { 320grid =[[ 321I am well written text. | 322{15:i} am not capitalized. | 323I am a {16:speling} {16:^mistakke}. | 324| 325{1:~ }|*3 326| 327]] , 328} 329end ) 330 331it ( 'can predefine highlights' , function () 332screen : try_resize ( 40 , 16 ) 333insert ( mulholland ) 334exec [[ 3353 336set ft=c 337syntax on 338set number cursorline 339split 340]] 341local ns1 =setup_provider () 342 343for k , v in pairs { 344LineNr ={ italic =true , bg ='Magenta' } , 345Comment ={ fg ='#FF0000' , bg =80 * 256 + 40 } , 346CursorLine ={ link ='ErrorMsg' } , 347} do 348api . nvim_set_hl ( ns1 , k , v ) 349end 350 351screen : expect { 352grid =[[ 353{3: 1 }{4:// just to see if there was an accid}| 354{3: }{4:ent} | 355{3: 2 }{4:// on Mulholland Drive} | 356{6: 3 }{7:^try_start(); }| 357{3: 4 }bufref_T save_buf; | 358{3: 5 }switch_buffer(&save_buf, buf); | 359{3: 6 }posp = getmark(mark, {5:false}); | 360{8:[No Name] [+] }| 361{3: 2 }{4:// on Mulholland Drive} | 362{6: 3 }{7:try_start(); }| 363{3: 4 }bufref_T save_buf; | 364{3: 5 }switch_buffer(&save_buf, buf); | 365{3: 6 }posp = getmark(mark, {5:false}); | 366{3: 7 }restore_buffer(&save_buf); | 367{9:[No Name] [+] }| 368| 369]] , 370} 371 372api . nvim_set_hl_ns ( ns1 ) 373screen : expect { 374grid =[[ 375{10: 1 }{11:// just to see if there was an accid}| 376{10: }{11:ent} | 377{10: 2 }{11:// on Mulholland Drive} | 378{6: 3 }{2:^try_start(); }| 379{10: 4 }bufref_T save_buf; | 380{10: 5 }switch_buffer(&save_buf, buf); | 381{10: 6 }posp = getmark(mark, {5:false}); | 382{8:[No Name] [+] }| 383{10: 2 }{11:// on Mulholland Drive} | 384{6: 3 }{2:try_start(); }| 385{10: 4 }bufref_T save_buf; | 386{10: 5 }switch_buffer(&save_buf, buf); | 387{10: 6 }posp = getmark(mark, {5:false}); | 388{10: 7 }restore_buffer(&save_buf); | 389{9:[No Name] [+] }| 390| 391]] , 392} 393 394exec_lua [[ 395local api = vim.api 396local thewin = api.nvim_get_current_win() 397local ns2 = api.nvim_create_namespace 'ns2' 398api.nvim_set_decoration_provider (ns2, { 399on_win = function (_, win, buf) 400api.nvim_set_hl_ns_fast(win == thewin and _G.ns1 or ns2) 401end; 402}) 403]] 404screen : expect { 405grid =[[ 406{10: 1 }{11:// just to see if there was an accid}| 407{10: }{11:ent} | 408{10: 2 }{11:// on Mulholland Drive} | 409{6: 3 }{2:^try_start(); }| 410{10: 4 }bufref_T save_buf; | 411{10: 5 }switch_buffer(&save_buf, buf); | 412{10: 6 }posp = getmark(mark, {5:false}); | 413{8:[No Name] [+] }| 414{3: 2 }{4:// on Mulholland Drive} | 415{6: 3 }{7:try_start(); }| 416{3: 4 }bufref_T save_buf; | 417{3: 5 }switch_buffer(&save_buf, buf); | 418{3: 6 }posp = getmark(mark, {5:false}); | 419{3: 7 }restore_buffer(&save_buf); | 420{9:[No Name] [+] }| 421| 422]] , 423} 424end ) 425 426it ( 'can break an existing link' , function () 427insert ( mulholland ) 428local ns1 =setup_provider () 429 430exec [[ 431highlight OriginalGroup guifg='#990000' 432highlight link LinkGroup OriginalGroup 433]] 434 435api . nvim_buf_set_virtual_text ( 0 , 0 , 2 , { { '- not red' , 'LinkGroup' } } , {} ) 436screen : expect { 437grid =[[ 438// just to see if there was an accident | 439// on Mulholland Drive | 440try_start(); {12:- not red} | 441bufref_T save_buf; | 442switch_buffer(&save_buf, buf); | 443posp = getmark(mark, false); | 444restore_buffer(&save_buf);^ | 445| 446]] , 447} 448 449api . nvim_set_hl ( ns1 , 'LinkGroup' , { fg ='Blue' } ) 450api . nvim_set_hl_ns ( ns1 ) 451 452screen : expect { 453grid =[[ 454// just to see if there was an accident | 455// on Mulholland Drive | 456try_start(); {4:- not red} | 457bufref_T save_buf; | 458switch_buffer(&save_buf, buf); | 459posp = getmark(mark, false); | 460restore_buffer(&save_buf);^ | 461| 462]] , 463} 464end ) 465 466it ( "with 'default': do not break an existing link" , function () 467insert ( mulholland ) 468local ns1 =setup_provider () 469 470exec [[ 471highlight OriginalGroup guifg='#990000' 472highlight link LinkGroup OriginalGroup 473]] 474 475api . nvim_buf_set_virtual_text ( 0 , 0 , 2 , { { '- not red' , 'LinkGroup' } } , {} ) 476screen : expect { 477grid =[[ 478// just to see if there was an accident | 479// on Mulholland Drive | 480try_start(); {12:- not red} | 481bufref_T save_buf; | 482switch_buffer(&save_buf, buf); | 483posp = getmark(mark, false); | 484restore_buffer(&save_buf);^ | 485| 486]] , 487} 488 489api . nvim_set_hl ( ns1 , 'LinkGroup' , { fg ='Blue' , default =true } ) 490api . nvim_set_hl_ns ( ns1 ) 491feed 'k' 492 493screen : expect { 494grid =[[ 495// just to see if there was an accident | 496// on Mulholland Drive | 497try_start(); {12:- not red} | 498bufref_T save_buf; | 499switch_buffer(&save_buf, buf); | 500posp = getmark(mark, false^); | 501restore_buffer(&save_buf); | 502| 503]] , 504} 505end ) 506 507it ( 'can have virtual text' , function () 508insert ( mulholland ) 509setup_provider [[ 510local hl = api.nvim_get_hl_id_by_name "ErrorMsg" 511local test_ns = api.nvim_create_namespace "mulholland" 512function on_do(event, ...) 513if event == "line" then 514local win, buf, line = ... 515api.nvim_buf_set_extmark(buf, test_ns, line, 0, { 516virt_text = {{'+', 'ErrorMsg'}}; 517virt_text_pos='overlay'; 518ephemeral = true; 519}) 520end 521end 522]] 523 524screen : expect { 525grid =[[ 526{2:+}/ just to see if there was an accident | 527{2:+}/ on Mulholland Drive | 528{2:+}ry_start(); | 529{2:+}ufref_T save_buf; | 530{2:+}witch_buffer(&save_buf, buf); | 531{2:+}osp = getmark(mark, false); | 532{2:+}estore_buffer(&save_buf);^ | 533| 534]] , 535} 536end ) 537 538it ( 'can have virtual text of the style: right_align' , function () 539insert ( mulholland ) 540setup_provider [[ 541local hl = api.nvim_get_hl_id_by_name "ErrorMsg" 542local test_ns = api.nvim_create_namespace "mulholland" 543function on_do(event, ...) 544if event == "line" then 545local win, buf, line = ... 546api.nvim_buf_set_extmark(buf, test_ns, line, 0, { 547virt_text = {{'+'}, {string.rep(' ', line+1), 'ErrorMsg'}}; 548virt_text_pos='right_align'; 549ephemeral = true; 550}) 551end 552end 553]] 554 555screen : expect { 556grid =[[ 557// just to see if there was an acciden+{2: }| 558// on Mulholland Drive +{2: }| 559try_start(); +{2: }| 560bufref_T save_buf; +{2: }| 561switch_buffer(&save_buf, buf); +{2: }| 562posp = getmark(mark, false); +{2: }| 563restore_buffer(&save_buf);^ +{2: }| 564| 565]] , 566} 567end ) 568 569it ( 'can have virtual text of the style: eol_right_align' , function () 570insert ( mulholland ) 571setup_provider [[ 572local hl = api.nvim_get_hl_id_by_name "ErrorMsg" 573local test_ns = api.nvim_create_namespace "mulholland" 574function on_do(event, ...) 575if event == "line" then 576local win, buf, line = ... 577api.nvim_buf_set_extmark(buf, test_ns, line, 0, { 578virt_text = {{'+'}, {'1234567890', 'ErrorMsg'}}; 579virt_text_pos='eol_right_align'; 580ephemeral = true; 581}) 582end 583end 584]] 585 586screen : expect { 587grid =[[ 588// just to see if there was an accident | 589// on Mulholland Drive +{2:1234567890}| 590try_start(); +{2:1234567890}| 591bufref_T save_buf; +{2:1234567890}| 592switch_buffer(&save_buf, buf); +{2:12345678}| 593posp = getmark(mark, false); +{2:1234567890}| 594restore_buffer(&save_buf);^ +{2:1234567890}| 595| 596]] , 597} 598end ) 599 600it ( 'multiple eol_right_align' , function () 601insert ( mulholland ) 602setup_provider [[ 603local hl = api.nvim_get_hl_id_by_name "ErrorMsg" 604local test_ns = api.nvim_create_namespace "mulholland" 605function on_do(event, ...) 606if event == "line" then 607local win, buf, line = ... 608api.nvim_buf_set_extmark(buf, test_ns, line, 0, { 609virt_text = {{'11111'}}; 610virt_text_pos='eol_right_align'; 611ephemeral = true; 612}) 613api.nvim_buf_set_extmark(0, test_ns, line, 0, { 614virt_text = {{'22222'}}; 615virt_text_pos='eol_right_align'; 616ephemeral = true; 617}) 618end 619end 620]] 621 622screen : expect { 623grid =[[ 624// just to see if there was an accident | 625// on Mulholland Drive 11111 22222| 626try_start(); 11111 22222| 627bufref_T save_buf; 11111 22222| 628switch_buffer(&save_buf, buf); 11111 222| 629posp = getmark(mark, false); 11111 22222| 630restore_buffer(&save_buf);^ 11111 22222| 631| 632]] , 633} 634end ) 635 636it ( 'eol_right_align: second text much longer than first' , function () 637insert ( 'short' ) 638setup_provider [[ 639local test_ns = api.nvim_create_namespace "test_length_diff" 640function on_do(event, ...) 641if event == "line" then 642local win, buf, line = ... 643 644api.nvim_buf_set_extmark(buf, test_ns, line, 0, { 645virt_text = {{'AA', 'Comment'}}; 646virt_text_pos = 'eol_right_align'; 647priority = 100; 648ephemeral = true; 649}) 650 651api.nvim_buf_set_extmark(buf, test_ns, line, 0, { 652virt_text = {{'BBBBBBBBBBBBBBBBBBBB', 'ErrorMsg'}}; 653virt_text_pos = 'eol_right_align'; 654priority = 200; 655ephemeral = true; 656}) 657end 658end 659]] 660 661screen : expect ( [[ 662shor^t {4:AA} {2:BBBBBBBBBBBBBBBBBBBB}| 663{1:~ }|*6 664| 665]] ) 666end ) 667 668it ( 'virtual text works with wrapped lines' , function () 669insert ( mulholland ) 670feed ( 'ggJj3JjJ' ) 671setup_provider [[ 672local hl = api.nvim_get_hl_id_by_name "ErrorMsg" 673local test_ns = api.nvim_create_namespace "mulholland" 674function on_do(event, ...) 675if event == "line" then 676local win, buf, line = ... 677api.nvim_buf_set_extmark(buf, test_ns, line, 0, { 678virt_text = {{string.rep('/', line+1), 'ErrorMsg'}}; 679virt_text_pos='eol'; 680ephemeral = true; 681}) 682api.nvim_buf_set_extmark(buf, test_ns, line, 6, { 683virt_text = {{string.rep('*', line+1), 'ErrorMsg'}}; 684virt_text_pos='overlay'; 685ephemeral = true; 686}) 687api.nvim_buf_set_extmark(buf, test_ns, line, 39, { 688virt_text = {{string.rep('!', line+1), 'ErrorMsg'}}; 689virt_text_win_col=20; 690ephemeral = true; 691}) 692api.nvim_buf_set_extmark(buf, test_ns, line, 40, { 693virt_text = {{string.rep('?', line+1), 'ErrorMsg'}}; 694virt_text_win_col=10; 695ephemeral = true; 696}) 697api.nvim_buf_set_extmark(buf, test_ns, line, 40, { 698virt_text = {{string.rep(';', line+1), 'ErrorMsg'}}; 699virt_text_pos='overlay'; 700ephemeral = true; 701}) 702api.nvim_buf_set_extmark(buf, test_ns, line, 40, { 703virt_text = {{'+'}, {string.rep(' ', line+1), 'ErrorMsg'}}; 704virt_text_pos='right_align'; 705ephemeral = true; 706}) 707end 708end 709]] 710 711screen : expect { 712grid =[[ 713// jus{2:*} to see if th{2:!}re was an accident | 714{2:;}n Mulholl{2:?}nd Drive {2:/} +{2: }| 715try_st{2:**}t(); bufref_{2:!!}save_buf; switch_b| 716{2:;;}fer(&sav{2:??}buf, buf); {2://} +{2: }| 717posp ={2:***}tmark(mark,{2:!!!}lse);^ restore_buf| 718{2:;;;}(&save_{2:???}); {2:///} +{2: }| 719{1:~ }| 720| 721]] , 722} 723command ( 'setlocal breakindent breakindentopt=shift:2' ) 724screen : expect { 725grid =[[ 726// jus{2:*} to see if th{2:!}re was an accident | 727{2:;}n Mulho{2:?}land Drive {2:/} +{2: }| 728try_st{2:**}t(); bufref_{2:!!}save_buf; switch_b| 729{2:;;}fer(&s{2:??}e_buf, buf); {2://} +{2: }| 730posp ={2:***}tmark(mark,{2:!!!}lse);^ restore_buf| 731{2:;;;}(&sav{2:???}uf); {2:///} +{2: }| 732{1:~ }| 733| 734]] , 735} 736end ) 737 738it ( 'can highlight beyond EOL' , function () 739insert ( mulholland ) 740setup_provider [[ 741local test_ns = api.nvim_create_namespace "veberod" 742function on_do(event, ...) 743if event == "line" then 744local win, buf, line = ... 745if string.find(api.nvim_buf_get_lines(buf, line, line+1, true)[1], "buf") then 746api.nvim_buf_set_extmark(buf, test_ns, line, 0, { 747end_line = line+1; 748hl_group = 'DiffAdd'; 749hl_eol = true; 750ephemeral = true; 751}) 752end 753end 754end 755]] 756 757screen : expect { 758grid =[[ 759// just to see if there was an accident | 760// on Mulholland Drive | 761try_start(); | 762{13:bufref_T save_buf; }| 763{13:switch_buffer(&save_buf, buf); }| 764posp = getmark(mark, false); | 765{13:restore_buffer(&save_buf);^ }| 766| 767]] , 768} 769end ) 770 771it ( "'hl_eol' extends into 'linebreak'/'breakindent'/'showbreak' gaps" , function () 772command ( 'set wrap linebreak breakindent breakindentopt=shift:2' ) 773api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { 774' if vim.g.colors_name == "ferricferric" then' , 775} ) 776local ns =api . nvim_create_namespace ( 'code_bg' ) 777local id =api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =1 , hl_group ='DiffAdd' , hl_eol =true } ) 778screen : expect ( [[ 779{13:^ if vim.g.colors_name == }| 780{13: "ferricferric" then }| 781{1:~ }|*5 782| 783]] ) 784 785-- Extends across the 'showbreak' character too. 786command ( 'set showbreak=>' ) 787screen : add_extra_attr_ids ( { 788[ 100 ] ={ background =Screen . colors . LightBlue } , 789[ 101 ] ={ bold =true , foreground =Screen . colors . Blue1 , background =Screen . colors . LightBlue } , 790} ) 791screen : expect ( [[ 792{100:^ if vim.g.colors_name == }| 793{100: }{101:>}{100:"ferricferric" then }| 794{1:~ }|*5 795| 796]] ) 797 798-- Without 'hl_eol' the highlight decorates characters, so it leaves the gaps alone, the same 799-- way it already leaves the cells past the end of the line alone. 800api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { id =id , end_row =1 , hl_group ='DiffAdd' } ) 801screen : expect ( [[ 802{100:^ if vim.g.colors_name == } | 803{1:>}{100:"ferricferric" then} | 804{1:~ }|*5 805| 806]] ) 807end ) 808 809it ( 'breakindent keeps the highlight after a real linebreak word-push' , function () 810-- The word pushed down by 'linebreak' resets decor_attr (see listlbr_spec.lua), which must not 811-- then leak into 'breakindent's own gap on the row the word lands on. 812screen : try_resize ( 30 , 5 ) 813screen : add_extra_attr_ids ( { [ 100 ] ={ background =Screen . colors . LightBlue } } ) 814command ( 'set wrap linebreak breakindent' ) 815local line =' This is a long indented line of plain text that will wrap nicely.' 816api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { line } ) 817local ns =api . nvim_create_namespace ( 'code_bg2' ) 818api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =1 , hl_group ='DiffAdd' , hl_eol =true } ) 819screen : expect ( [[ 820{100:^ This is a long indented }| 821{100: line of plain text that }| 822{100: will wrap nicely. }| 823{1:~ }| 824| 825]] ) 826end ) 827 828it ( 'can create and remove signs when CursorMoved autocommand validates botline #18661' , function () 829exec_lua ( [[ 830local lines = {} 831for i = 1, 200 do 832lines[i] = 'hello' .. tostring(i) 833end 834vim.api.nvim_buf_set_lines(0, 0, -1, false, lines) 835]] ) 836setup_provider ( [[ 837local function on_do(kind, winid, bufnr, topline, botline) 838if kind == 'win' then 839if topline < 100 and botline > 100 then 840api.nvim_buf_set_extmark(bufnr, ns1, 99, -1, { sign_text = 'X' }) 841else 842api.nvim_buf_clear_namespace(bufnr, ns1, 0, -1) 843end 844end 845end 846]] ) 847command ( [[autocmd CursorMoved * call line('w$')]] ) 848api . nvim_win_set_cursor ( 0 , { 100 , 0 } ) 849screen : expect ( [[ 850{14: }hello97 | 851{14: }hello98 | 852{14: }hello99 | 853{14:X }^hello100 | 854{14: }hello101 | 855{14: }hello102 | 856{14: }hello103 | 857| 858]] ) 859api . nvim_win_set_cursor ( 0 , { 1 , 0 } ) 860screen : expect ( [[ 861^hello1 | 862hello2 | 863hello3 | 864hello4 | 865hello5 | 866hello6 | 867hello7 | 868| 869]] ) 870end ) 871 872it ( 'does allow removing extmarks during on_line callbacks' , function () 873exec_lua ( [[ 874eok = true 875]] ) 876setup_provider ( [[ 877local function on_do(kind, winid, bufnr, topline, botline) 878if kind == 'line' then 879api.nvim_buf_set_extmark(bufnr, ns1, 1, -1, { sign_text = 'X' }) 880eok = pcall(api.nvim_buf_clear_namespace, bufnr, ns1, 0, -1) 881end 882end 883]] ) 884exec_lua ( [[ 885assert(eok == true) 886]] ) 887end ) 888 889it ( 'on_line is invoked only for buffer lines' , function () 890insert ( mulholland ) 891command ( 'vnew' ) 892insert ( mulholland ) 893feed ( 'dd' ) 894command ( 'windo diffthis' ) 895 896exec_lua ( [[ 897out_of_bound = false 898]] ) 899setup_provider ( [[ 900local function on_do(kind, _, bufnr, row) 901if kind == 'line' then 902if not api.nvim_buf_get_lines(bufnr, row, row + 1, false)[1] then 903out_of_bound = true 904end 905end 906end 907]] ) 908 909feed ( '<C-e>' ) 910 911exec_lua ( [[ 912assert(out_of_bound == false) 913]] ) 914end ) 915 916it ( 'on_range is invoked on all visible characters' , function () 917clear () 918screen =Screen . new ( 20 , 4 ) 919setup_screen ( screen ) 920 921local function record () 922exec_lua ( function () 923_G . p_min ={ math . huge , math . huge } 924_G . p_max ={ - math . huge , - math . huge } 925function _G . pos_gt ( a , b ) 926return a [ 1 ] > b [ 1 ] or ( a [ 1 ] == b [ 1 ] and a [ 2 ] > b [ 2 ]) 927end 928function _G . pos_lt ( a , b ) 929return a [ 1 ] < b [ 1 ] or ( a [ 1 ] == b [ 1 ] and a [ 2 ] < b [ 2 ]) 930end 931end ) 932setup_provider [[ 933local function on_do(kind, _, bufnr, br, bc, er, ec) 934if kind == 'range' then 935local b = { br, bc } 936local e = { er, ec } 937if _G.pos_gt(_G.p_min, b) then 938_G.p_min = b 939end 940if _G.pos_lt(_G.p_max, e) then 941_G.p_max = e 942end 943end 944end 945]] 946end 947local function check ( min , max ) 948local p_min =exec_lua ( 'return _G.p_min' ) 949assert ( 950p_min [ 1 ] < min [ 1 ] or ( p_min [ 1 ] == min [ 1 ] and p_min [ 2 ] <= min [ 2 ]), 951'minimum position ' .. vim . inspect ( p_min ) .. ' should be before the first char' 952) 953local p_max =exec_lua ( 'return _G.p_max' ) 954assert ( 955p_max [ 1 ] > max [ 1 ] or ( p_max [ 1 ] == max [ 1 ] and p_max [ 2 ] >= max [ 2 ]), 956'maximum position ' .. vim . inspect ( p_max ) .. ' should be on or after the last char' 957) 958end 959 960-- Multiple lines. 961exec_lua ( [[ 962local lines = { ('a'):rep(40), ('b'):rep(40), ('c'):rep(40) } 963vim.api.nvim_buf_set_lines(0, 0, -1, true, lines) 964vim.api.nvim_win_set_cursor(0, { 2, 0 }) 965]] ) 966record () 967screen : expect ( [[ 968^bbbbbbbbbbbbbbbbbbbb| 969bbbbbbbbbbbbbbbbbbbb| 970ccccccccccccccccc{1:@@@}| 971| 972]] ) 973check ( { 1 , 0 } , { 2 , 21 } ) 974 975-- One long line. 976exec_lua ( [[ 977local lines = { ('a'):rep(100) } 978vim.api.nvim_buf_set_lines(0, 0, -1, true, lines) 979vim.api.nvim_win_set_cursor(0, { 1, 70 }) 980]] ) 981record () 982screen : expect ( [[ 983{1:<<<}aaaaaaaaaaaaaaaaa| 984aaaaaaaaaaaaaaaaaaaa| 985aaaaaaaaaa^aaaaaaaaaa| 986| 987]] ) 988check ( { 0 , 20 } , { 0 , 81 } ) 989 990-- Multibyte characters. 991exec_lua ( [[ 992local lines = { ('\195\162'):rep(100) } 993vim.api.nvim_buf_set_lines(0, 0, -1, true, lines) 994vim.api.nvim_win_set_cursor(0, { 1, 70 * 2 }) 995]] ) 996record () 997screen : expect ( [[ 998{1:<<<}âââââââââââââââââ| 999ââââââââââââââââââââ| 1000ââââââââââ^ââââââââââ| 1001| 1002]] ) 1003check ( { 0 , 20 * 2 } , { 0 , 81 * 2 } ) 1004 1005-- Tabs. 1006exec_lua ( [[ 1007local lines = { 'a' .. ('\t'):rep(100) } 1008vim.api.nvim_buf_set_lines(0, 0, -1, true, lines) 1009vim.api.nvim_win_set_cursor(0, { 1, 39 }) 1010]] ) 1011record () 1012screen : expect ( [[ 1013{1:<<<} | 1014| 1015^ | 1016| 1017]] ) 1018check ( { 0 , 33 } , { 0 , 94 } ) 1019 1020-- One long line without wrapping. 1021command ( 'set nowrap' ) 1022exec_lua ( [[ 1023local lines = { ('a'):rep(50) .. ('b'):rep(50) } 1024vim.api.nvim_buf_set_lines(0, 0, -1, true, lines) 1025vim.api.nvim_win_set_cursor(0, { 1, 50 }) 1026]] ) 1027record () 1028screen : expect ( [[ 1029aaaaaaaaaa^bbbbbbbbbb| 1030{1:~ }|*2 1031| 1032]] ) 1033check ( { 0 , 40 } , { 0 , 60 } ) 1034end ) 1035 1036it ( 'can add new providers during redraw #26652' , function () 1037setup_provider [[ 1038local ns = api.nvim_create_namespace('test_no_add') 1039function on_do(...) 1040api.nvim_set_decoration_provider(ns, {}) 1041end 1042]] 1043 1044n . assert_alive () 1045end ) 1046 1047it ( 'is not invoked repeatedly in Visual mode with vim.schedule() #20235' , function () 1048exec_lua ( [[_G.cnt = 0]] ) 1049setup_provider ( [[ 1050function on_do(event, ...) 1051if event == 'win' then 1052vim.schedule(function() end) 1053_G.cnt = _G.cnt + 1 1054end 1055end 1056]] ) 1057feed ( 'v' ) 1058screen : expect ( [[ 1059{20:^ } | 1060{1:~ }|*6 1061{19:-- VISUAL --} | 1062]] ) 1063eq ( 2 , exec_lua ( [[return _G.cnt]] )) 1064end ) 1065 1066it ( 'can do large changes to the marktree' , function () 1067insert ( 'line1 with a lot of text\nline2 with a lot of text' ) 1068setup_provider ( [[ 1069function on_do(event, _, _, row) 1070if event == 'win' or (event == 'line' and row == 1) then 1071vim.api.nvim_buf_clear_namespace(0, ns1, 0, -1) 1072for i = 0,1 do 1073for j = 0,23 do 1074vim.api.nvim_buf_set_extmark(0, ns1, i, j, {hl_group='ErrorMsg', end_col = j+1}) 1075end 1076end 1077end 1078end 1079]] ) 1080 1081-- Doesn't crash when modifying the marktree between line1 and line2 1082screen : expect ( [[ 1083{2:line1 with a lot of text} | 1084{2:line2 with a lot of tex^t} | 1085{1:~ }|*5 1086| 1087]] ) 1088end ) 1089 1090it ( 'inline virt_text does not result in wrong cursor column #33153' , function () 1091insert ( 'line1 with a lot of text\nline2 with a lot of text' ) 1092setup_provider ( [[ 1093_G.do_win = false 1094vim.keymap.set('n', 'f', function() 1095_G.do_win = true 1096vim.cmd('redraw!') 1097end) 1098vim.o.concealcursor = 'n' 1099function on_do(event) 1100if event == 'win' and _G.do_win then 1101vim.api.nvim_buf_set_extmark(0, ns1, 1, 0, { 1102virt_text = { { 'virt_text ' } }, 1103virt_text_pos = 'inline' 1104}) 1105end 1106end 1107]] ) 1108feed ( 'f' ) 1109screen : expect ( [[ 1110line1 with a lot of text | 1111virt_text line2 with a lot of tex^t | 1112{1:~ }|*5 1113| 1114]] ) 1115end ) 1116 1117it ( 'decor provider is enabled again for next redraw after on_win disabled it' , function () 1118exec_lua ( function () 1119vim . api . nvim_set_decoration_provider ( vim . api . nvim_create_namespace ( '' ), { 1120on_win =function () 1121return false 1122end , 1123on_buf =function () 1124_G . did_buf =( _G . did_buf or 0 ) + 1 1125end , 1126} ) 1127end ) 1128api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { 'foo' } ) 1129screen : expect ( [[ 1130^foo | 1131{1:~ }|*6 1132| 1133]] ) 1134eq ( 1 , exec_lua ( 'return _G.did_buf' )) 1135end ) 1136end ) 1137 1138describe ( 'decoration_providers' , function () 1139it ( 'errors and logs gracefully' , function () 1140local testlog ='Xtest_decorations_log' 1141clear ( { env ={ NVIM_LOG_FILE =testlog } } ) 1142local screen =Screen . new ( 65 , 7 ) 1143setup_provider ( [[ 1144function on_do(...) 1145error "Foo" 1146end 1147]] ) 1148screen : expect ( [[ 1149{3: }| 1150{9:Decoration provider "start" (ns=ns1):} | 1151{9:Lua: [string "<nvim>"]:4: Foo} | 1152{9:stack traceback:} | 1153{9: [C]: in function 'error'} | 1154{9: [string "<nvim>"]:4: in function <[string "<nvim>"]:3>} | 1155{6:Press ENTER or type command to continue}^ | 1156]] ) 1157t . assert_log ( 'Error in decoration provider "start" %(ns=ns1%):' , testlog , 100 ) 1158t . assert_log ( 'Lua: %[string "<nvim>"%]:4: Foo' , testlog , 100 ) 1159n . check_close () 1160os . remove ( testlog ) 1161end ) 1162end ) 1163 1164local example_text =[[ 1165for _,item in ipairs(items) do 1166local text, hl_id_cell, count = unpack(item) 1167if hl_id_cell ~= nil then 1168hl_id = hl_id_cell 1169end 1170for _ = 1, (count or 1) do 1171local cell = line[colpos] 1172cell.text = text 1173cell.hl_id = hl_id 1174colpos = colpos+1 1175end 1176end]] 1177 1178describe ( 'extmark decorations' , function () 1179local screen ---@type test.functional.ui.screen 1180local ns ---@type integer 1181before_each ( function () 1182clear () 1183screen =Screen . new ( 50 , 15 ) 1184screen : set_default_attr_ids { 1185[ 1 ] ={ bold =true , foreground =Screen . colors . Blue } , 1186[ 2 ] ={ foreground =Screen . colors . Brown } , 1187[ 3 ] ={ bold =true , foreground =Screen . colors . SeaGreen } , 1188[ 4 ] ={ background =Screen . colors . Red1 , foreground =Screen . colors . Gray100 } , 1189[ 5 ] ={ foreground =Screen . colors . Brown , bold =true } , 1190[ 6 ] ={ foreground =Screen . colors . DarkCyan } , 1191[ 7 ] ={ foreground =Screen . colors . Grey0 , background =tonumber ( '0xff4c4c' ) } , 1192[ 8 ] ={ foreground =tonumber ( '0x180606' ), background =tonumber ( '0xff4c4c' ) } , 1193[ 9 ] ={ foreground =tonumber ( '0xe40c0c' ), background =tonumber ( '0xff4c4c' ), bold =true } , 1194[ 10 ] ={ foreground =tonumber ( '0xb20000' ), background =tonumber ( '0xff4c4c' ) } , 1195[ 11 ] ={ blend =30 , background =Screen . colors . Red1 } , 1196[ 12 ] ={ foreground =Screen . colors . Brown , blend =30 , background =Screen . colors . Red1 , bold =true } , 1197[ 13 ] ={ foreground =Screen . colors . Fuchsia } , 1198[ 14 ] ={ background =Screen . colors . Red1 , foreground =Screen . colors . Black } , 1199[ 15 ] ={ background =Screen . colors . Red1 , foreground =tonumber ( '0xb20000' ) } , 1200[ 16 ] ={ blend =30 , background =Screen . colors . Red1 , foreground =Screen . colors . Magenta1 } , 1201[ 17 ] ={ bold =true , foreground =Screen . colors . Brown , background =Screen . colors . LightGrey } , 1202[ 18 ] ={ background =Screen . colors . LightGrey } , 1203[ 19 ] ={ foreground =Screen . colors . DarkCyan , background =Screen . colors . LightGrey } , 1204[ 20 ] ={ foreground =tonumber ( '0x180606' ), background =tonumber ( '0xf13f3f' ) } , 1205[ 21 ] ={ foreground =Screen . colors . Gray0 , background =tonumber ( '0xf13f3f' ) } , 1206[ 22 ] ={ foreground =tonumber ( '0xb20000' ), background =tonumber ( '0xf13f3f' ) } , 1207[ 23 ] ={ foreground =Screen . colors . Magenta1 , background =Screen . colors . LightGrey } , 1208[ 24 ] ={ bold =true } , 1209[ 25 ] ={ background =Screen . colors . LightRed } , 1210[ 26 ] ={ background =Screen . colors . DarkGrey , foreground =Screen . colors . LightGrey } , 1211[ 27 ] ={ background =Screen . colors . LightGrey , foreground =Screen . colors . Black } , 1212[ 28 ] ={ underline =true , foreground =Screen . colors . SlateBlue } , 1213[ 29 ] ={ foreground =Screen . colors . SlateBlue , background =Screen . colors . LightGrey , underline =true } , 1214[ 30 ] ={ foreground =Screen . colors . DarkCyan , background =Screen . colors . LightGrey , underline =true } , 1215[ 31 ] ={ underline =true , foreground =Screen . colors . DarkCyan } , 1216[ 32 ] ={ underline =true } , 1217[ 33 ] ={ foreground =Screen . colors . DarkBlue , background =Screen . colors . LightGrey } , 1218[ 34 ] ={ background =Screen . colors . Yellow } , 1219[ 35 ] ={ background =Screen . colors . Yellow , bold =true , foreground =Screen . colors . Blue } , 1220[ 36 ] ={ foreground =Screen . colors . Blue1 , bold =true , background =Screen . colors . Red } , 1221[ 37 ] ={ background =Screen . colors . WebGray , foreground =Screen . colors . DarkBlue } , 1222[ 38 ] ={ background =Screen . colors . LightBlue } , 1223[ 39 ] ={ foreground =Screen . colors . Blue1 , background =Screen . colors . LightCyan1 , bold =true } , 1224[ 40 ] ={ reverse =true } , 1225[ 41 ] ={ bold =true , reverse =true } , 1226[ 42 ] ={ undercurl =true , special =Screen . colors . Red } , 1227[ 43 ] ={ background =Screen . colors . Yellow , undercurl =true , special =Screen . colors . Red } , 1228[ 44 ] ={ background =Screen . colors . LightMagenta } , 1229[ 45 ] ={ background =Screen . colors . Red , special =Screen . colors . Red , foreground =Screen . colors . Red } , 1230[ 46 ] ={ background =Screen . colors . Blue , foreground =Screen . colors . Blue , special =Screen . colors . Red } , 1231[ 47 ] ={ background =Screen . colors . Green , foreground =Screen . colors . Blue , special =Screen . colors . Red } , 1232} 1233 1234ns =api . nvim_create_namespace 'test' 1235end ) 1236 1237it ( 'empty virtual text at eol should not break colorcolumn #17860' , function () 1238insert ( example_text ) 1239feed ( 'gg' ) 1240command ( 'set colorcolumn=40' ) 1241screen : expect ( [[ 1242^for _,item in ipairs(items) do {25: } | 1243local text, hl_id_cell, count = unp{25:a}ck(item) | 1244if hl_id_cell ~= nil then {25: } | 1245hl_id = hl_id_cell {25: } | 1246end {25: } | 1247for _ = 1, (count or 1) do {25: } | 1248local cell = line[colpos] {25: } | 1249cell.text = text {25: } | 1250cell.hl_id = hl_id {25: } | 1251colpos = colpos+1 {25: } | 1252end {25: } | 1253end {25: } | 1254{1:~ }|*2 1255| 1256]] ) 1257api . nvim_buf_set_extmark ( 0 , ns , 4 , 0 , { virt_text ={ { '' } } , virt_text_pos ='eol' } ) 1258screen : expect_unchanged () 1259end ) 1260 1261it ( 'can have virtual text of overlay position' , function () 1262insert ( example_text ) 1263feed 'gg' 1264 1265for i =1 , 9 do 1266api . nvim_buf_set_extmark ( 0 , ns , i , 0 , { virt_text ={ { '|' , 'LineNr' } } , virt_text_pos ='overlay' } ) 1267if i == 3 or ( i >= 6 and i <= 9 ) then 1268api . nvim_buf_set_extmark ( 0 , ns , i , 4 , { virt_text ={ { '|' , 'NonText' } } , virt_text_pos ='overlay' } ) 1269end 1270end 1271api . nvim_buf_set_extmark ( 12720 , 1273ns , 12749 , 127510 , 1276{ virt_text ={ { 'foo' } , { 'bar' , 'MoreMsg' } , { '!!' , 'ErrorMsg' } } , virt_text_pos ='overlay' } 1277) 1278 1279-- can "float" beyond end of line 1280api . nvim_buf_set_extmark ( 0 , ns , 5 , 28 , { virt_text ={ { 'loopy' , 'ErrorMsg' } } , virt_text_pos ='overlay' } ) 1281-- bound check: right edge of window 1282api . nvim_buf_set_extmark ( 12830 , 1284ns , 12852 , 128626 , 1287{ virt_text ={ { 'bork bork bork' } , { ( ' bork' ): rep ( 10 ), 'ErrorMsg' } } , virt_text_pos ='overlay' } 1288) 1289-- empty virt_text should not change anything 1290api . nvim_buf_set_extmark ( 0 , ns , 6 , 16 , { virt_text ={ { '' } } , virt_text_pos ='overlay' } ) 1291 1292screen : expect { 1293grid =[[ 1294^for _,item in ipairs(items) do | 1295{2:|} local text, hl_id_cell, count = unpack(item) | 1296{2:|} if hl_id_cell ~= nil tbork bork bork{4: bork bork}| 1297{2:|} {1:|} hl_id = hl_id_cell | 1298{2:|} end | 1299{2:|} for _ = 1, (count or 1) {4:loopy} | 1300{2:|} {1:|} local cell = line[colpos] | 1301{2:|} {1:|} cell.text = text | 1302{2:|} {1:|} cell.hl_id = hl_id | 1303{2:|} {1:|} cofoo{3:bar}{4:!!}olpos+1 | 1304end | 1305end | 1306{1:~ }|*2 1307| 1308]] , 1309} 1310 1311-- handles broken lines 1312screen : try_resize ( 22 , 25 ) 1313screen : expect { 1314grid =[[ 1315^for _,item in ipairs(i| 1316tems) do | 1317{2:|} local text, hl_id_| 1318cell, count = unpack(i| 1319tem) | 1320{2:|} if hl_id_cell ~= n| 1321il tbork bork bork{4: bor}| 1322{2:|} {1:|} hl_id = hl_id_| 1323cell | 1324{2:|} end | 1325{2:|} for _ = 1, (count | 1326or 1) {4:loopy} | 1327{2:|} {1:|} local cell = l| 1328ine[colpos] | 1329{2:|} {1:|} cell.text = te| 1330xt | 1331{2:|} {1:|} cell.hl_id = h| 1332l_id | 1333{2:|} {1:|} cofoo{3:bar}{4:!!}olpo| 1334s+1 | 1335end | 1336end | 1337{1:~ }|*2 1338| 1339]] , 1340} 1341 1342-- truncating in the middle of a char leaves a space 1343api . nvim_buf_set_lines ( 0 , 0 , 1 , true , { 'for _,item in ipairs(items) do -- 古古古' } ) 1344api . nvim_buf_set_lines ( 0 , 10 , 12 , true , { ' end -- ??????????' , 'end -- ?古古古古?古古' } ) 1345api . nvim_buf_set_extmark ( 0 , ns , 0 , 35 , { virt_text ={ { 'A' , 'ErrorMsg' } , { 'AA' } } , virt_text_pos ='overlay' } ) 1346api . nvim_buf_set_extmark ( 0 , ns , 10 , 19 , { virt_text ={ { '口口口' , 'ErrorMsg' } } , virt_text_pos ='overlay' } ) 1347api . nvim_buf_set_extmark ( 0 , ns , 11 , 21 , { virt_text ={ { '口口口' , 'ErrorMsg' } } , virt_text_pos ='overlay' } ) 1348api . nvim_buf_set_extmark ( 0 , ns , 11 , 8 , { virt_text ={ { '口口' , 'ErrorMsg' } } , virt_text_pos ='overlay' } ) 1349screen : expect { 1350grid =[[ 1351^for _,item in ipairs(i| 1352tems) do -- {4:A}AA 古 | 1353{2:|} local text, hl_id_| 1354cell, count = unpack(i| 1355tem) | 1356{2:|} if hl_id_cell ~= n| 1357il tbork bork bork{4: bor}| 1358{2:|} {1:|} hl_id = hl_id_| 1359cell | 1360{2:|} end | 1361{2:|} for _ = 1, (count | 1362or 1) {4:loopy} | 1363{2:|} {1:|} local cell = l| 1364ine[colpos] | 1365{2:|} {1:|} cell.text = te| 1366xt | 1367{2:|} {1:|} cell.hl_id = h| 1368l_id | 1369{2:|} {1:|} cofoo{3:bar}{4:!!}olpo| 1370s+1 | 1371end -- ???????{4:口 }| 1372end -- {4:口口} 古古{4:口口 }| 1373{1:~ }|*2 1374| 1375]] , 1376} 1377 1378screen : try_resize ( 82 , 13 ) 1379screen : expect { 1380grid =[[ 1381^for _,item in ipairs(items) do -- {4:A}AA 古 | 1382{2:|} local text, hl_id_cell, count = unpack(item) | 1383{2:|} if hl_id_cell ~= nil tbork bork bork{4: bork bork bork bork bork bork bork bork b}| 1384{2:|} {1:|} hl_id = hl_id_cell | 1385{2:|} end | 1386{2:|} for _ = 1, (count or 1) {4:loopy} | 1387{2:|} {1:|} local cell = line[colpos] | 1388{2:|} {1:|} cell.text = text | 1389{2:|} {1:|} cell.hl_id = hl_id | 1390{2:|} {1:|} cofoo{3:bar}{4:!!}olpos+1 | 1391end -- ???????{4:口口口} | 1392end -- {4:口口} 古古{4:口口口} | 1393| 1394]] , 1395} 1396 1397api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 1398screen : expect { 1399grid =[[ 1400^for _,item in ipairs(items) do -- 古古古 | 1401local text, hl_id_cell, count = unpack(item) | 1402if hl_id_cell ~= nil then | 1403hl_id = hl_id_cell | 1404end | 1405for _ = 1, (count or 1) do | 1406local cell = line[colpos] | 1407cell.text = text | 1408cell.hl_id = hl_id | 1409colpos = colpos+1 | 1410end -- ?????????? | 1411end -- ?古古古古?古古 | 1412| 1413]] , 1414} 1415end ) 1416 1417it ( 'overlay virtual text works with wrapped lines #25158' , function () 1418screen : try_resize ( 50 , 6 ) 1419insert (( 'ab' ): rep ( 100 )) 1420for i =0 , 9 do 1421api . nvim_buf_set_extmark ( 0 , ns , 0 , 42 + i , { virt_text ={ { tostring ( i ), 'ErrorMsg' } } , virt_text_pos ='overlay' } ) 1422api . nvim_buf_set_extmark ( 14230 , 1424ns , 14250 , 142691 + i , 1427{ virt_text ={ { tostring ( i ), 'ErrorMsg' } } , virt_text_pos ='overlay' , virt_text_hide =true } 1428) 1429end 1430screen : expect { 1431grid =[[ 1432ababababababababababababababababababababab{4:01234567}| 1433{4:89}abababababababababababababababababababa{4:012345678}| 1434{4:9}babababababababababababababababababababababababab| 1435ababababababababababababababababababababababababa^b| 1436{1:~ }| 1437| 1438]] , 1439} 1440 1441command ( 'set showbreak=++' ) 1442screen : expect { 1443grid =[[ 1444ababababababababababababababababababababab{4:01234567}| 1445{1:++}{4:89}abababababababababababababababababababa{4:0123456}| 1446{1:++}{4:789}babababababababababababababababababababababab| 1447{1:++}abababababababababababababababababababababababab| 1448{1:++}ababa^b | 1449| 1450]] , 1451} 1452 1453feed ( '2gkvg0' ) 1454screen : expect { 1455grid =[[ 1456ababababababababababababababababababababab{4:01234567}| 1457{1:++}{4:89}abababababababababababababababababababa{4:0123456}| 1458{1:++}{27:^ababab}ababababababababababababababababababababab| 1459{1:++}abababababababababababababababababababababababab| 1460{1:++}ababab | 1461{24:-- VISUAL --} | 1462]] , 1463} 1464 1465feed ( 'o' ) 1466screen : expect { 1467grid =[[ 1468ababababababababababababababababababababab{4:01234567}| 1469{1:++}{4:89}abababababababababababababababababababa{4:0123456}| 1470{1:++}{27:ababa^b}ababababababababababababababababababababab| 1471{1:++}abababababababababababababababababababababababab| 1472{1:++}ababab | 1473{24:-- VISUAL --} | 1474]] , 1475} 1476 1477feed ( 'gk' ) 1478screen : expect { 1479grid =[[ 1480ababababababababababababababababababababab{4:01234567}| 1481{1:++}{4:89}aba{27:^bababababababababababababababababababababab}| 1482{1:++}{27:a}{4:89}babababababababababababababababababababababab| 1483{1:++}abababababababababababababababababababababababab| 1484{1:++}ababab | 1485{24:-- VISUAL --} | 1486]] , 1487} 1488 1489feed ( 'o' ) 1490screen : expect { 1491grid =[[ 1492ababababababababababababababababababababab{4:01234567}| 1493{1:++}{4:89}aba{27:bababababababababababababababababababababab}| 1494{1:++}{27:^a}{4:89}babababababababababababababababababababababab| 1495{1:++}abababababababababababababababababababababababab| 1496{1:++}ababab | 1497{24:-- VISUAL --} | 1498]] , 1499} 1500 1501feed ( '<Esc>$' ) 1502command ( 'set number showbreak=' ) 1503screen : expect { 1504grid =[[ 1505{2: 1 }ababababababababababababababababababababab{4:0123}| 1506{2: }{4:456789}abababababababababababababababababababa{4:0}| 1507{2: }{4:123456789}babababababababababababababababababab| 1508{2: }ababababababababababababababababababababababab| 1509{2: }abababababababa^b | 1510| 1511]] , 1512} 1513 1514command ( 'set cpoptions+=n' ) 1515screen : expect { 1516grid =[[ 1517{2: 1 }ababababababababababababababababababababab{4:0123}| 1518{4:456789}abababababababababababababababababababa{4:01234}| 1519{4:56789}babababababababababababababababababababababab| 1520ababababababababababababababababababababababababab| 1521aba^b | 1522| 1523]] , 1524} 1525 1526feed ( '0g$hi<Tab>' ) 1527screen : expect { 1528grid =[[ 1529{2: 1 }ababababababababababababababababababababab{4:01} | 1530{4:^23456789}abababababababababababababababababababa{4:0}| 1531{4:123456789}babababababababababababababababababababab| 1532ababababababababababababababababababababababababab| 1533abababab | 1534{24:-- INSERT --} | 1535]] , 1536} 1537end ) 1538 1539it ( 'virt_text_hide hides overlay virtual text when extmark is off-screen' , function () 1540screen : try_resize ( 50 , 3 ) 1541command ( 'set nowrap' ) 1542api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { '-- ' .. ( '…' ): rep ( 57 ) } ) 1543api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { '?????' , 'ErrorMsg' } } , virt_text_pos ='overlay' , virt_text_hide =true } ) 1544api . nvim_buf_set_extmark ( 0 , ns , 0 , 123 , { virt_text ={ { '!!!!!' , 'ErrorMsg' } } , virt_text_pos ='overlay' , virt_text_hide =true } ) 1545screen : expect { 1546grid =[[ 1547{4:^?????}……………………………………………………………………………………………………{4:!!!!!}……| 1548{1:~ }| 1549| 1550]] , 1551} 1552feed ( '40zl' ) 1553screen : expect { 1554grid =[[ 1555^………{4:!!!!!}……………………………… | 1556{1:~ }| 1557| 1558]] , 1559} 1560feed ( '3zl' ) 1561screen : expect { 1562grid =[[ 1563{4:^!!!!!}……………………………… | 1564{1:~ }| 1565| 1566]] , 1567} 1568feed ( '7zl' ) 1569screen : expect { 1570grid =[[ 1571^………………………… | 1572{1:~ }| 1573| 1574]] , 1575} 1576 1577command ( 'set wrap smoothscroll' ) 1578screen : expect { 1579grid =[[ 1580{4:?????}……………………………………………………………………………………………………{4:!!!!!}……| 1581^………………………… | 1582| 1583]] , 1584} 1585feed ( '<C-E>' ) 1586screen : expect { 1587grid =[[ 1588{1:<<<}………………^… | 1589{1:~ }| 1590| 1591]] , 1592} 1593screen : try_resize ( 40 , 3 ) 1594screen : expect { 1595grid =[[ 1596{1:<<<}{4:!!!!!}……………………………^… | 1597{1:~ }| 1598| 1599]] , 1600} 1601feed ( '<C-Y>' ) 1602screen : expect { 1603grid =[[ 1604{4:?????}……………………………………………………………………………………………| 1605………{4:!!!!!}……………………………^… | 1606| 1607]] , 1608} 1609end ) 1610 1611it ( 'overlay virtual text works on and after a TAB #24022' , function () 1612screen : try_resize ( 40 , 3 ) 1613api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { '\t\tline 1' } ) 1614api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'AA' , 'Search' } } , virt_text_pos ='overlay' , hl_mode ='combine' } ) 1615api . nvim_buf_set_extmark ( 0 , ns , 0 , 1 , { virt_text ={ { 'BB' , 'Search' } } , virt_text_pos ='overlay' , hl_mode ='combine' } ) 1616api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { virt_text ={ { 'CC' , 'Search' } } , virt_text_pos ='overlay' , hl_mode ='combine' } ) 1617screen : expect { 1618grid =[[ 1619{34:AA} ^ {34:BB} {34:CC}ne 1 | 1620{1:~ }| 1621| 1622]] , 1623} 1624command ( 'setlocal list listchars=tab:<->' ) 1625screen : expect { 1626grid =[[ 1627{35:^AA}{1:----->}{35:BB}{1:----->}{34:CC}ne 1 | 1628{1:~ }| 1629| 1630]] , 1631} 1632end ) 1633 1634it ( 'can have virtual text of overlay position and styling' , function () 1635insert ( example_text ) 1636feed 'gg' 1637 1638command 'set ft=lua' 1639command 'syntax on' 1640 1641screen : expect { 1642grid =[[ 1643{5:^for} _,item {5:in} {6:ipairs}(items) {5:do} | 1644{5:local} text, hl_id_cell, count {5:=} unpack(item) | 1645{5:if} hl_id_cell {5:~=} {13:nil} {5:then} | 1646hl_id {5:=} hl_id_cell | 1647{5:end} | 1648{5:for} _ {5:=} {13:1}, (count {5:or} {13:1}) {5:do} | 1649{5:local} cell {5:=} line[colpos] | 1650cell.text {5:=} text | 1651cell.hl_id {5:=} hl_id | 1652colpos {5:=} colpos{5:+}{13:1} | 1653{5:end} | 1654{5:end} | 1655{1:~ }|*2 1656| 1657]] , 1658} 1659 1660command 'hi Blendy guibg=Red blend=30' 1661command 'hi! Visual guifg=NONE guibg=LightGrey' 1662api . nvim_buf_set_extmark ( 16630 , 1664ns , 16651 , 16665 , 1667{ virt_text ={ { 'blendy text - here' , 'Blendy' } } , virt_text_pos ='overlay' , hl_mode ='blend' } 1668) 1669api . nvim_buf_set_extmark ( 16700 , 1671ns , 16722 , 16735 , 1674{ virt_text ={ { 'combining color' , 'Blendy' } } , virt_text_pos ='overlay' , hl_mode ='combine' } 1675) 1676api . nvim_buf_set_extmark ( 16770 , 1678ns , 16793 , 16805 , 1681{ virt_text ={ { 'replacing color' , 'Blendy' } } , virt_text_pos ='overlay' , hl_mode ='replace' } 1682) 1683 1684api . nvim_buf_set_extmark ( 16850 , 1686ns , 16874 , 16885 , 1689{ virt_text ={ { 'blendy text - here' , 'Blendy' } } , virt_text_pos ='overlay' , hl_mode ='blend' , virt_text_hide =true } 1690) 1691api . nvim_buf_set_extmark ( 16920 , 1693ns , 16945 , 16955 , 1696{ virt_text ={ { 'combining color' , 'Blendy' } } , virt_text_pos ='overlay' , hl_mode ='combine' , virt_text_hide =true } 1697) 1698api . nvim_buf_set_extmark ( 16990 , 1700ns , 17016 , 17025 , 1703{ virt_text ={ { 'replacing color' , 'Blendy' } } , virt_text_pos ='overlay' , hl_mode ='replace' , virt_text_hide =true } 1704) 1705 1706screen : expect { 1707grid =[[ 1708{5:^for} _,item {5:in} {6:ipairs}(items) {5:do} | 1709{5:l}{8:blen}{7:dy}{10:e}{7:text}{10:h}{7:-}{10:_}{7:here}ell, count {5:=} unpack(item) | 1710{5:i}{12:c}{11:ombining col}{12:or} {13:nil} {5:then} | 1711{11:replacing color}d_cell | 1712{5:e}{8:bl}{7:endy}{10: }{7:text}{10: }{7:-}{10: }{7:here} | 1713{5:f}{12:co}{11:mbi}{12:n}{11:i}{16:n}{11:g color}t {5:or} {13:1}) {5:do} | 1714{11:replacing color} line[colpos] | 1715cell.text {5:=} text | 1716cell.hl_id {5:=} hl_id | 1717colpos {5:=} colpos{5:+}{13:1} | 1718{5:end} | 1719{5:end} | 1720{1:~ }|*2 1721| 1722]] , 1723} 1724 1725feed 'V5G' 1726screen : expect { 1727grid =[[ 1728{17:for}{18: _,item }{17:in}{18: }{19:ipairs}{18:(items) }{17:do} | 1729{18: }{17:l}{20:blen}{21:dy}{22:e}{21:text}{22:h}{21:-}{22:_}{21:here}{18:ell, count }{17:=}{18: unpack(item)} | 1730{18: }{17:i}{12:c}{11:ombining col}{12:or}{18: }{23:nil}{18: }{17:then} | 1731{18: }{11:replacing color}{18:d_cell} | 1732{18: }{17:^end} | 1733{5:f}{12:co}{11:mbi}{12:n}{11:i}{16:n}{11:g color}t {5:or} {13:1}) {5:do} | 1734{11:replacing color} line[colpos] | 1735cell.text {5:=} text | 1736cell.hl_id {5:=} hl_id | 1737colpos {5:=} colpos{5:+}{13:1} | 1738{5:end} | 1739{5:end} | 1740{1:~ }|*2 1741{24:-- VISUAL LINE --} | 1742]] , 1743} 1744 1745feed 'jj' 1746screen : expect { 1747grid =[[ 1748{17:for}{18: _,item }{17:in}{18: }{19:ipairs}{18:(items) }{17:do} | 1749{18: }{17:l}{20:blen}{21:dy}{22:e}{21:text}{22:h}{21:-}{22:_}{21:here}{18:ell, count }{17:=}{18: unpack(item)} | 1750{18: }{17:i}{12:c}{11:ombining col}{12:or}{18: }{23:nil}{18: }{17:then} | 1751{18: }{11:replacing color}{18:d_cell} | 1752{18: }{17:end} | 1753{18: }{17:for}{18: _ }{17:=}{18: }{23:1}{18:, (count }{17:or}{18: }{23:1}{18:) }{17:do} | 1754{18: ^ }{17:local}{18: cell }{17:=}{18: line[colpos]} | 1755cell.text {5:=} text | 1756cell.hl_id {5:=} hl_id | 1757colpos {5:=} colpos{5:+}{13:1} | 1758{5:end} | 1759{5:end} | 1760{1:~ }|*2 1761{24:-- VISUAL LINE --} | 1762]] , 1763} 1764end ) 1765 1766it ( 'can have virtual text of right_align and fixed win_col position' , function () 1767insert ( example_text ) 1768feed 'gg' 1769api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { virt_text ={ { 'Very' , 'ErrorMsg' } } , virt_text_win_col =31 , hl_mode ='blend' } ) 1770api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { virt_text ={ { 'VERY' , 'ErrorMsg' } } , virt_text_pos ='right_align' , hl_mode ='blend' } ) 1771api . nvim_buf_set_extmark ( 0 , ns , 2 , 10 , { virt_text ={ { 'Much' , 'ErrorMsg' } } , virt_text_win_col =31 , hl_mode ='blend' } ) 1772api . nvim_buf_set_extmark ( 0 , ns , 2 , 10 , { virt_text ={ { 'MUCH' , 'ErrorMsg' } } , virt_text_pos ='right_align' , hl_mode ='blend' } ) 1773api . nvim_buf_set_extmark ( 0 , ns , 3 , 14 , { virt_text ={ { 'Error' , 'ErrorMsg' } } , virt_text_win_col =31 , hl_mode ='blend' } ) 1774api . nvim_buf_set_extmark ( 0 , ns , 3 , 14 , { virt_text ={ { 'ERROR' , 'ErrorMsg' } } , virt_text_pos ='right_align' , hl_mode ='blend' } ) 1775api . nvim_buf_set_extmark ( 0 , ns , 7 , 21 , { virt_text ={ { '-' , 'NonText' } } , virt_text_win_col =4 , hl_mode ='blend' } ) 1776api . nvim_buf_set_extmark ( 0 , ns , 7 , 21 , { virt_text ={ { '-' , 'NonText' } } , virt_text_pos ='right_align' , hl_mode ='blend' } ) 1777-- empty virt_text should not change anything 1778api . nvim_buf_set_extmark ( 0 , ns , 8 , 0 , { virt_text ={ { '' } } , virt_text_win_col =14 , hl_mode ='blend' } ) 1779api . nvim_buf_set_extmark ( 0 , ns , 8 , 0 , { virt_text ={ { '' } } , virt_text_pos ='right_align' , hl_mode ='blend' } ) 1780 1781screen : expect { 1782grid =[[ 1783^for _,item in ipairs(items) do | 1784local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| 1785if hl_id_cell ~= nil then {4:Much} {4:MUCH}| 1786hl_id = hl_id_cell {4:Error} {4:ERROR}| 1787end | 1788for _ = 1, (count or 1) do | 1789local cell = line[colpos] | 1790{1:-} cell.text = text {1:-}| 1791cell.hl_id = hl_id | 1792colpos = colpos+1 | 1793end | 1794end | 1795{1:~ }|*2 1796| 1797]] , 1798} 1799 1800feed '3G12|i<cr><esc>' 1801screen : expect { 1802grid =[[ 1803for _,item in ipairs(items) do | 1804local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| 1805if hl_i {4:Much} {4:MUCH}| 1806^d_cell ~= nil then | 1807hl_id = hl_id_cell {4:Error} {4:ERROR}| 1808end | 1809for _ = 1, (count or 1) do | 1810local cell = line[colpos] | 1811{1:-} cell.text = text {1:-}| 1812cell.hl_id = hl_id | 1813colpos = colpos+1 | 1814end | 1815end | 1816{1:~ }| 1817| 1818]] , 1819} 1820 1821feed 'u:<cr>' 1822screen : expect { 1823grid =[[ 1824for _,item in ipairs(items) do | 1825local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| 1826if hl_i^d_cell ~= nil then {4:Much} {4:MUCH}| 1827hl_id = hl_id_cell {4:Error} {4:ERROR}| 1828end | 1829for _ = 1, (count or 1) do | 1830local cell = line[colpos] | 1831{1:-} cell.text = text {1:-}| 1832cell.hl_id = hl_id | 1833colpos = colpos+1 | 1834end | 1835end | 1836{1:~ }|*2 1837: | 1838]] , 1839} 1840 1841feed '8|i<cr><esc>' 1842screen : expect { 1843grid =[[ 1844for _,item in ipairs(items) do | 1845local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| 1846if | 1847^hl_id_cell ~= nil then {4:Much} {4:MUCH}| 1848hl_id = hl_id_cell {4:Error} {4:ERROR}| 1849end | 1850for _ = 1, (count or 1) do | 1851local cell = line[colpos] | 1852{1:-} cell.text = text {1:-}| 1853cell.hl_id = hl_id | 1854colpos = colpos+1 | 1855end | 1856end | 1857{1:~ }| 1858| 1859]] , 1860} 1861 1862feed 'jI-- <esc>..........' 1863screen : expect { 1864grid =[[ 1865for _,item in ipairs(items) do | 1866local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| 1867if | 1868hl_id_cell ~= nil then {4:Much} {4:MUCH}| 1869--^ -- -- -- -- -- -- --{4:Error}- -- hl_i{4:ERROR}| 1870l_id_cell | 1871end | 1872for _ = 1, (count or 1) do | 1873local cell = line[colpos] | 1874{1:-} cell.text = text {1:-}| 1875cell.hl_id = hl_id | 1876colpos = colpos+1 | 1877end | 1878end | 1879| 1880]] , 1881} 1882 1883api . nvim_buf_set_extmark ( 0 , ns , 4 , 50 , { virt_text ={ { 'EOL' , 'NonText' } } } ) 1884screen : expect { 1885grid =[[ 1886for _,item in ipairs(items) do | 1887local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| 1888if | 1889hl_id_cell ~= nil then {4:Much} {4:MUCH}| 1890--^ -- -- -- -- -- -- --{4:Error}- -- hl_i{4:ERROR}| 1891l_id_cell {1:EOL} | 1892end | 1893for _ = 1, (count or 1) do | 1894local cell = line[colpos] | 1895{1:-} cell.text = text {1:-}| 1896cell.hl_id = hl_id | 1897colpos = colpos+1 | 1898end | 1899end | 1900| 1901]] , 1902} 1903 1904feed '.' 1905screen : expect { 1906grid =[[ 1907for _,item in ipairs(items) do | 1908local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| 1909if | 1910hl_id_cell ~= nil then {4:Much} {4:MUCH}| 1911--^ -- -- -- -- -- -- -- -- -- -- -- hl_id | 1912= hl_id_cell {1:EOL} {4:Error} {4:ERROR}| 1913end | 1914for _ = 1, (count or 1) do | 1915local cell = line[colpos] | 1916{1:-} cell.text = text {1:-}| 1917cell.hl_id = hl_id | 1918colpos = colpos+1 | 1919end | 1920end | 1921| 1922]] , 1923} 1924 1925command 'set number' 1926screen : expect { 1927grid =[[ 1928{2: 1 }for _,item in ipairs(items) do | 1929{2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| 1930{2: }m) | 1931{2: 3 } if | 1932{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| 1933{2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl| 1934{2: }_id = hl_id_cell {1:EOL} {4:Error} {4:ERROR}| 1935{2: 6 } end | 1936{2: 7 } for _ = 1, (count or 1) do | 1937{2: 8 } local cell = line[colpos] | 1938{2: 9 } {1:-} cell.text = text {1:-}| 1939{2: 10 } cell.hl_id = hl_id | 1940{2: 11 } colpos = colpos+1 | 1941{2: 12 } end | 1942| 1943]] , 1944} 1945 1946command 'set cpoptions+=n' 1947screen : expect { 1948grid =[[ 1949{2: 1 }for _,item in ipairs(items) do | 1950{2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| 1951m) | 1952{2: 3 } if | 1953{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| 1954{2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl| 1955_id = hl_id_cell {1:EOL} {4:Error} {4:ERROR}| 1956{2: 6 } end | 1957{2: 7 } for _ = 1, (count or 1) do | 1958{2: 8 } local cell = line[colpos] | 1959{2: 9 } {1:-} cell.text = text {1:-}| 1960{2: 10 } cell.hl_id = hl_id | 1961{2: 11 } colpos = colpos+1 | 1962{2: 12 } end | 1963| 1964]] , 1965} 1966 1967command 'set cpoptions-=n nowrap' 1968screen : expect { 1969grid =[[ 1970{2: 1 }for _,item in ipairs(items) do | 1971{2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| 1972{2: 3 } if | 1973{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| 1974{2: 5 } --^ -- -- -- -- -- -- --{4:Error}- -- {4:ERROR}| 1975{2: 6 } end | 1976{2: 7 } for _ = 1, (count or 1) do | 1977{2: 8 } local cell = line[colpos] | 1978{2: 9 } {1:-} cell.text = text {1:-}| 1979{2: 10 } cell.hl_id = hl_id | 1980{2: 11 } colpos = colpos+1 | 1981{2: 12 } end | 1982{2: 13 }end | 1983{1:~ }| 1984| 1985]] , 1986} 1987 1988feed '12zl' 1989screen : expect { 1990grid =[[ 1991{2: 1 }n ipairs(items) do | 1992{2: 2 }xt, hl_id_cell, count = unpack({4:Very}) {4:VERY}| 1993{2: 3 } | 1994{2: 4 }= nil then {4:Much} {4:MUCH}| 1995{2: 5 }^- -- -- -- -- -- -- -- -- -- --{4:Error}d = h{4:ERROR}| 1996{2: 6 } | 1997{2: 7 }1, (count or 1) do | 1998{2: 8 }l cell = line[colpos] | 1999{2: 9 }.tex{1:-} = text {1:-}| 2000{2: 10 }.hl_id = hl_id | 2001{2: 11 }os = colpos+1 | 2002{2: 12 } | 2003{2: 13 } | 2004{1:~ }| 2005| 2006]] , 2007} 2008 2009feed ( 'fhi<Tab>' ) 2010screen : expect { 2011grid =[[ 2012{2: 1 }n ipairs(items) do | 2013{2: 2 }xt, hl_id_cell, count = unpack({4:Very}) {4:VERY}| 2014{2: 3 } | 2015{2: 4 }= nil then {4:Much} {4:MUCH}| 2016{2: 5 }- -- -- -- -- -- -- -- -- -- --{4:Error}^hl_id{4:ERROR}| 2017{2: 6 } | 2018{2: 7 }1, (count or 1) do | 2019{2: 8 }l cell = line[colpos] | 2020{2: 9 }.tex{1:-} = text {1:-}| 2021{2: 10 }.hl_id = hl_id | 2022{2: 11 }os = colpos+1 | 2023{2: 12 } | 2024{2: 13 } | 2025{1:~ }| 2026{24:-- INSERT --} | 2027]] , 2028} 2029 2030feed ( '<Esc>0' ) 2031screen : expect { 2032grid =[[ 2033{2: 1 }for _,item in ipairs(items) do | 2034{2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| 2035{2: 3 } if | 2036{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| 2037{2: 5 }^ -- -- -- -- -- -- -- --{4:Error}- -- {4:ERROR}| 2038{2: 6 } end | 2039{2: 7 } for _ = 1, (count or 1) do | 2040{2: 8 } local cell = line[colpos] | 2041{2: 9 } {1:-} cell.text = text {1:-}| 2042{2: 10 } cell.hl_id = hl_id | 2043{2: 11 } colpos = colpos+1 | 2044{2: 12 } end | 2045{2: 13 }end | 2046{1:~ }| 2047| 2048]] , 2049} 2050end ) 2051 2052it ( 'virtual text win_col out of window does not break display #25645' , function () 2053screen : try_resize ( 51 , 6 ) 2054command ( 'vnew' ) 2055api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { string . rep ( 'a' , 50 ) } ) 2056screen : expect { 2057grid =[[ 2058^aaaaaaaaaaaaaaaaaaaaaaaaa│ | 2059aaaaaaaaaaaaaaaaaaaaaaaaa│{1:~ }| 2060{1:~ }│{1:~ }|*2 2061{41:[No Name] [+] }{40:[No Name] }| 2062| 2063]] , 2064} 2065local extmark_opts ={ virt_text_win_col =35 , virt_text ={ { ' ' , 'Comment' } } } 2066api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , extmark_opts ) 2067screen : expect_unchanged () 2068assert_alive () 2069end ) 2070 2071it ( 'can have virtual text on folded line' , function () 2072insert ( [[ 207311111 207422222 207533333]] ) 2076command ( '1,2fold' ) 2077screen : try_resize ( 50 , 3 ) 2078feed ( 'zb' ) 2079-- XXX: the behavior of overlay virtual text at non-zero column is strange: 2080-- 1. With 'wrap' it is never shown. 2081-- 2. With 'nowrap' it is shown only if the extmark is hidden before leftcol. 2082api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'AA' , 'Underlined' } } , hl_mode ='combine' , virt_text_pos ='overlay' } ) 2083api . nvim_buf_set_extmark ( 0 , ns , 0 , 5 , { virt_text ={ { 'BB' , 'Underlined' } } , hl_mode ='combine' , virt_text_win_col =10 } ) 2084api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { virt_text ={ { 'CC' , 'Underlined' } } , hl_mode ='combine' , virt_text_pos ='right_align' } ) 2085screen : expect { 2086grid =[[ 2087{29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| 20883333^3 | 2089| 2090]] , 2091} 2092command ( 'set nowrap' ) 2093screen : expect_unchanged () 2094feed ( 'zl' ) 2095screen : expect { 2096grid =[[ 2097{29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| 2098333^3 | 2099| 2100]] , 2101} 2102feed ( 'zl' ) 2103screen : expect { 2104grid =[[ 2105{29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| 210633^3 | 2107| 2108]] , 2109} 2110feed ( 'zl' ) 2111screen : expect { 2112grid =[[ 2113{29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| 21143^3 | 2115| 2116]] , 2117} 2118end ) 2119 2120it ( 'virtual text works below diff filler lines' , function () 2121screen : try_resize ( 53 , 8 ) 2122insert ( [[ 2123aaaaa 2124bbbbb 2125ccccc 2126ddddd 2127eeeee]] ) 2128command ( 'rightbelow vnew' ) 2129insert ( [[ 2130bbbbb 2131ccccc 2132ddddd 2133eeeee]] ) 2134command ( 'windo diffthis' ) 2135api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'AA' , 'Underlined' } } , virt_text_pos ='overlay' } ) 2136api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'BB' , 'Underlined' } } , virt_text_win_col =10 } ) 2137api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'CC' , 'Underlined' } } , virt_text_pos ='right_align' } ) 2138screen : expect { 2139grid =[[ 2140{37: }{38:aaaaa }│{37: }{39:------------------------}| 2141{37: }bbbbb │{37: }{28:AA}bbb {28:BB} {28:CC}| 2142{37: }ccccc │{37: }ccccc | 2143{37: }ddddd │{37: }ddddd | 2144{37: }eeeee │{37: }eeee^e | 2145{1:~ }│{1:~ }| 2146{40:[No Name] [+] }{41:[No Name] [+] }| 2147| 2148]] , 2149} 2150command ( 'windo set wrap' ) 2151screen : expect_unchanged () 2152end ) 2153 2154it ( 'can have virtual text which combines foreground and background groups' , function () 2155screen : try_resize ( 20 , 5 ) 2156 2157screen : set_default_attr_ids { 2158[ 1 ] ={ bold =true , foreground =Screen . colors . Blue } , 2159[ 2 ] ={ background =tonumber ( '0x123456' ), foreground =tonumber ( '0xbbbbbb' ) } , 2160[ 3 ] ={ background =tonumber ( '0x123456' ), foreground =tonumber ( '0xcccccc' ) } , 2161[ 4 ] ={ background =tonumber ( '0x234567' ), foreground =tonumber ( '0xbbbbbb' ) } , 2162[ 5 ] ={ background =tonumber ( '0x234567' ), foreground =tonumber ( '0xcccccc' ) } , 2163[ 6 ] ={ bold =true , foreground =tonumber ( '0xcccccc' ), background =tonumber ( '0x234567' ) } , 2164} 2165 2166exec [[ 2167hi BgOne guibg=#123456 2168hi BgTwo guibg=#234567 2169hi FgEin guifg=#bbbbbb 2170hi FgZwei guifg=#cccccc 2171hi VeryBold gui=bold 2172]] 2173 2174insert ( '##' ) 2175local vt ={ 2176{ 'a' , { 'BgOne' , 'FgEin' } } , 2177{ 'b' , { 'BgOne' , 'FgZwei' } } , 2178{ 'c' , { 'BgTwo' , 'FgEin' } } , 2179{ 'd' , { 'BgTwo' , 'FgZwei' } } , 2180{ 'X' , { 'BgTwo' , 'FgZwei' , 'VeryBold' } } , 2181} 2182api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text =vt , virt_text_pos ='eol' } ) 2183api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text =vt , virt_text_pos ='right_align' } ) 2184api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text =vt , virt_text_pos ='inline' } ) 2185api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines ={ vt , vt } } ) 2186screen : expect { 2187grid =[[ 2188{2:a}{3:b}{4:c}{5:d}{6:X}#^# {2:a}{3:b}{4:c}{5:d}{6:X} {2:a}{3:b}{4:c}{5:d}{6:X}| 2189{2:a}{3:b}{4:c}{5:d}{6:X} |*2 2190{1:~ }| 2191| 2192]] , 2193} 2194end ) 2195 2196it ( 'does not crash when deleting a cleared buffer #15212' , function () 2197exec_lua [[ 2198ns = vim.api.nvim_create_namespace("myplugin") 2199vim.api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_text = {{"a"}}, end_col = 0}) 2200]] 2201screen : expect { 2202grid =[[ 2203^ a | 2204{1:~ }|*13 2205| 2206]] , 2207} 2208 2209exec_lua [[ 2210vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) 2211vim.cmd("bdelete") 2212]] 2213screen : expect { 2214grid =[[ 2215^ | 2216{1:~ }|*13 2217| 2218]] , 2219} 2220assert_alive () 2221end ) 2222 2223it ( 'conceal with conceal char #19007' , function () 2224screen : try_resize ( 50 , 5 ) 2225insert ( 'foo\n' ) 2226api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =0 , end_row =2 , conceal ='X' } ) 2227command ( 'set conceallevel=2' ) 2228screen : expect ( [[ 2229{26:X} | 2230^ | 2231{1:~ }|*2 2232| 2233]] ) 2234command ( 'set conceallevel=1' ) 2235screen : expect_unchanged () 2236 2237eq ( 'conceal char must be printable' , pcall_err ( api . nvim_buf_set_extmark , 0 , ns , 0 , 0 , { end_col =0 , end_row =2 , conceal ='\255' } )) 2238end ) 2239 2240it ( 'conceal with composed conceal char' , function () 2241screen : try_resize ( 50 , 5 ) 2242insert ( 'foo\n' ) 2243api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =0 , end_row =2 , conceal ='ẍ̲' } ) 2244command ( 'set conceallevel=2' ) 2245screen : expect ( [[ 2246{26:ẍ̲} | 2247^ | 2248{1:~ }|*2 2249| 2250]] ) 2251command ( 'set conceallevel=1' ) 2252screen : expect_unchanged () 2253 2254-- this is rare, but could happen. Save at least the first codepoint 2255api . nvim__invalidate_glyph_cache () 2256screen : expect { 2257grid =[[ 2258{26:x} | 2259^ | 2260{1:~ }|*2 2261| 2262]] , 2263} 2264end ) 2265 2266it ( 'conceal without conceal char #24782' , function () 2267screen : try_resize ( 50 , 5 ) 2268insert ( 'foobar\n' ) 2269api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =3 , conceal ='' } ) 2270command ( 'set listchars=conceal:?' ) 2271command ( 'let &conceallevel=1' ) 2272screen : expect ( [[ 2273{26:?}bar | 2274^ | 2275{1:~ }|*2 2276| 2277]] ) 2278command ( 'let &conceallevel=2' ) 2279screen : expect ( [[ 2280bar | 2281^ | 2282{1:~ }|*2 2283| 2284]] ) 2285end ) 2286 2287it ( 'conceal works just before truncated double-width char #21486' , function () 2288screen : try_resize ( 40 , 4 ) 2289api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { '' , ( 'a' ): rep ( 37 ) .. '<>古' } ) 2290api . nvim_buf_set_extmark ( 0 , ns , 1 , 37 , { end_col =39 , conceal ='' } ) 2291command ( 'setlocal conceallevel=2' ) 2292screen : expect { 2293grid =[[ 2294^ | 2295aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:>} | 2296古 | 2297| 2298]] , 2299} 2300feed ( 'j' ) 2301screen : expect { 2302grid =[[ 2303| 2304^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<>{1:>}| 2305古 | 2306| 2307]] , 2308} 2309end ) 2310 2311it ( 'redraws properly when adding/removing conceal on non-current line' , function () 2312screen : try_resize ( 50 , 5 ) 2313api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'abcd' , 'efgh' , 'ijkl' , 'mnop' } ) 2314command ( 'setlocal conceallevel=2' ) 2315screen : expect { 2316grid =[[ 2317^abcd | 2318efgh | 2319ijkl | 2320mnop | 2321| 2322]] , 2323} 2324api . nvim_buf_set_extmark ( 0 , ns , 2 , 1 , { end_col =3 , conceal ='' } ) 2325screen : expect { 2326grid =[[ 2327^abcd | 2328efgh | 2329il | 2330mnop | 2331| 2332]] , 2333} 2334api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2335screen : expect { 2336grid =[[ 2337^abcd | 2338efgh | 2339ijkl | 2340mnop | 2341| 2342]] , 2343} 2344end ) 2345 2346it ( 'avoids redraw issue #20651' , function () 2347exec_lua [[ 2348vim.cmd.normal'10oXXX' 2349vim.cmd.normal'gg' 2350local ns = vim.api.nvim_create_namespace('ns') 2351 2352local bufnr = vim.api.nvim_create_buf(false, true) 2353vim.api.nvim_open_win(bufnr, false, { relative = 'win', height = 1, width = 1, row = 0, col = 0 }) 2354 2355vim.api.nvim_create_autocmd('CursorMoved', { callback = function() 2356local row = vim.api.nvim_win_get_cursor(0)[1] - 1 2357vim.api.nvim_buf_set_extmark(0, ns, row, 0, { id = 1 }) 2358vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, {}) 2359vim.schedule(function() 2360vim.api.nvim_buf_set_extmark(0, ns, row, 0, { 2361id = 1, 2362virt_text = {{'HELLO', 'Normal'}}, 2363}) 2364end) 2365end 2366}) 2367]] 2368 2369for _ =1 , 3 do 2370vim . uv . sleep ( 10 ) 2371feed 'j' 2372end 2373 2374screen : expect { 2375grid =[[ 2376{44: } | 2377XXX |*2 2378^XXX HELLO | 2379XXX |*7 2380{1:~ }|*3 2381| 2382]] , 2383} 2384end ) 2385 2386it ( 'underline attribute with higher priority takes effect #22371' , function () 2387screen : try_resize ( 50 , 3 ) 2388insert ( 'aaabbbaaa' ) 2389exec ( [[ 2390hi TestUL gui=underline guifg=Blue 2391hi TestUC gui=undercurl guisp=Red 2392hi TestBold gui=bold 2393]] ) 2394screen : set_default_attr_ids ( { 2395[ 0 ] ={ bold =true , foreground =Screen . colors . Blue } , 2396[ 1 ] ={ underline =true , foreground =Screen . colors . Blue } , 2397[ 2 ] ={ undercurl =true , special =Screen . colors . Red } , 2398[ 3 ] ={ underline =true , foreground =Screen . colors . Blue , special =Screen . colors . Red } , 2399[ 4 ] ={ undercurl =true , foreground =Screen . colors . Blue , special =Screen . colors . Red } , 2400[ 5 ] ={ bold =true , underline =true , foreground =Screen . colors . Blue } , 2401[ 6 ] ={ bold =true , undercurl =true , special =Screen . colors . Red } , 2402} ) 2403 2404api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =9 , hl_group ='TestUL' , priority =20 } ) 2405api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { end_col =6 , hl_group ='TestUC' , priority =30 } ) 2406screen : expect ( [[ 2407{1:aaa}{4:bbb}{1:aa^a} | 2408{0:~ }| 2409| 2410]] ) 2411api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2412api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =9 , hl_group ='TestUC' , priority =20 } ) 2413api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { end_col =6 , hl_group ='TestUL' , priority =30 } ) 2414screen : expect ( [[ 2415{2:aaa}{3:bbb}{2:aa^a} | 2416{0:~ }| 2417| 2418]] ) 2419api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2420api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =9 , hl_group ='TestUL' , priority =30 } ) 2421api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { end_col =6 , hl_group ='TestUC' , priority =20 } ) 2422screen : expect ( [[ 2423{1:aaa}{3:bbb}{1:aa^a} | 2424{0:~ }| 2425| 2426]] ) 2427api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2428api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =9 , hl_group ='TestUC' , priority =30 } ) 2429api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { end_col =6 , hl_group ='TestUL' , priority =20 } ) 2430screen : expect ( [[ 2431{2:aaa}{4:bbb}{2:aa^a} | 2432{0:~ }| 2433| 2434]] ) 2435 2436-- When only one highlight group has an underline attribute, it should always take effect. 2437for _ , d in ipairs ( { - 5 , 5 } ) do 2438api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2439screen : expect ( [[ 2440aaabbbaa^a | 2441{0:~ }| 2442| 2443]] ) 2444api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =9 , hl_group ='TestUL' , priority =25 + d } ) 2445api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { end_col =6 , hl_group ='TestBold' , priority =25 - d } ) 2446screen : expect ( [[ 2447{1:aaa}{5:bbb}{1:aa^a} | 2448{0:~ }| 2449| 2450]] ) 2451end 2452for _ , d in ipairs ( { - 5 , 5 } ) do 2453api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2454screen : expect ( [[ 2455aaabbbaa^a | 2456{0:~ }| 2457| 2458]] ) 2459api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =9 , hl_group ='TestUC' , priority =25 + d } ) 2460api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { end_col =6 , hl_group ='TestBold' , priority =25 - d } ) 2461screen : expect ( [[ 2462{2:aaa}{6:bbb}{2:aa^a} | 2463{0:~ }| 2464| 2465]] ) 2466end 2467end ) 2468 2469it ( 'highlight is combined with syntax and sign linehl #20004' , function () 2470screen : try_resize ( 50 , 3 ) 2471insert ( [[ 2472function Func() 2473end]] ) 2474feed ( 'gg' ) 2475command ( 'set ft=lua' ) 2476command ( 'syntax on' ) 2477command ( 'hi default MyMark guibg=LightGrey' ) 2478api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =3 , hl_mode ='combine' , hl_group ='MyMark' } ) 2479command ( 'hi default MyLine gui=underline' ) 2480command ( 'sign define CurrentLine linehl=MyLine' ) 2481fn . sign_place ( 6 , 'Test' , 'CurrentLine' , '' , { lnum =1 } ) 2482screen : expect { 2483grid =[[ 2484{30:^fun}{31:ction}{32: Func() }| 2485{6:end} | 2486| 2487]] , 2488} 2489end ) 2490 2491it ( 'highlight can combine multiple groups' , function () 2492screen : try_resize ( 50 , 3 ) 2493command ( 'hi Group1 guibg=Red guifg=Red guisp=Red' ) 2494command ( 'hi Group2 guibg=Blue guifg=Blue' ) 2495command ( 'hi Group3 guibg=Green' ) 2496insert ( [[example text]] ) 2497api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =1 , hl_group ={} } ) 2498screen : expect ( [[ 2499example tex^t | 2500{1:~ }| 2501| 2502]] ) 2503 2504api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2505api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =1 , hl_group ={ 'Group1' } } ) 2506screen : expect ( [[ 2507{45:example tex^t} | 2508{1:~ }| 2509| 2510]] ) 2511api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2512api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =1 , hl_group ={ 'Group1' , 'Group2' } } ) 2513screen : expect ( [[ 2514{46:example tex^t} | 2515{1:~ }| 2516| 2517]] ) 2518api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2519api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =1 , hl_group ={ 'Group1' , 'Group2' , 'Group3' } , hl_eol =true } ) 2520screen : expect ( [[ 2521{47:example tex^t }| 2522{1:~ }| 2523| 2524]] ) 2525 2526eq ( 2527"Invalid 'hl_group': 'hl_group item'" , 2528pcall_err ( api . nvim_buf_set_extmark , 0 , ns , 0 , 0 , { end_row =1 , hl_group ={ 'Group1' , 'Group2' , { 'fail' } } , hl_eol =true } ) 2529) 2530end ) 2531 2532it ( 'highlight works after TAB with sidescroll #14201' , function () 2533screen : try_resize ( 50 , 3 ) 2534command ( 'set nowrap' ) 2535api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { '\tword word word word' } ) 2536api . nvim_buf_set_extmark ( 0 , ns , 0 , 1 , { end_col =3 , hl_group ='ErrorMsg' } ) 2537screen : expect { 2538grid =[[ 2539^ {4:wo}rd word word word | 2540{1:~ }| 2541| 2542]] , 2543} 2544feed ( '7zl' ) 2545screen : expect { 2546grid =[[ 2547{4:^wo}rd word word word | 2548{1:~ }| 2549| 2550]] , 2551} 2552feed ( 'zl' ) 2553screen : expect { 2554grid =[[ 2555{4:^wo}rd word word word | 2556{1:~ }| 2557| 2558]] , 2559} 2560feed ( 'zl' ) 2561screen : expect { 2562grid =[[ 2563{4:^o}rd word word word | 2564{1:~ }| 2565| 2566]] , 2567} 2568end ) 2569 2570it ( 'highlights the beginning of a TAB char correctly #23734' , function () 2571screen : try_resize ( 50 , 3 ) 2572api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'this is the\ttab' } ) 2573api . nvim_buf_set_extmark ( 0 , ns , 0 , 11 , { end_col =15 , hl_group ='ErrorMsg' } ) 2574screen : expect { 2575grid =[[ 2576^this is the{4: tab} | 2577{1:~ }| 2578| 2579]] , 2580} 2581 2582api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 2583api . nvim_buf_set_extmark ( 0 , ns , 0 , 12 , { end_col =15 , hl_group ='ErrorMsg' } ) 2584screen : expect { 2585grid =[[ 2586^this is the {4:tab} | 2587{1:~ }| 2588| 2589]] , 2590} 2591end ) 2592 2593it ( 'highlight applies to a full TAB on line with matches #20885' , function () 2594screen : try_resize ( 50 , 3 ) 2595api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { '\t-- match1' , ' -- match2' } ) 2596fn . matchadd ( 'NonText' , 'match' ) 2597api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =1 , end_col =0 , hl_group ='Search' } ) 2598api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { end_row =2 , end_col =0 , hl_group ='Search' } ) 2599screen : expect { 2600grid =[[ 2601{34: ^ -- }{35:match}{34:1} | 2602{34: -- }{35:match}{34:2} | 2603| 2604]] , 2605} 2606end ) 2607 2608it ( 'highlight applies to a full TAB in visual block mode' , function () 2609screen : try_resize ( 50 , 8 ) 2610command ( 'hi! Visual guifg=NONE guibg=LightGrey' ) 2611api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'asdf' , '\tasdf' , '\tasdf' , '\tasdf' , 'asdf' } ) 2612api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =5 , end_col =0 , hl_group ='Underlined' } ) 2613screen : expect ( [[ 2614{28:^asdf} | 2615{28: asdf} |*3 2616{28:asdf} | 2617{1:~ }|*2 2618| 2619]] ) 2620feed ( '<C-V>Gll' ) 2621screen : expect ( [[ 2622{29:asd}{28:f} | 2623{29: }{28: asdf} |*3 2624{29:as^d}{28:f} | 2625{1:~ }|*2 2626{24:-- VISUAL BLOCK --} | 2627]] ) 2628end ) 2629 2630it ( 'highlight works properly with multibyte text and spell #26771' , function () 2631insert ( '口口\n' ) 2632screen : try_resize ( 50 , 3 ) 2633api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_col =3 , hl_group ='Search' } ) 2634screen : expect ( [[ 2635{34:口}口 | 2636^ | 2637| 2638]] ) 2639command ( 'setlocal spell' ) 2640screen : expect ( [[ 2641{43:口}{42:口} | 2642^ | 2643| 2644]] ) 2645end ) 2646 2647it ( 'supports multiline highlights' , function () 2648insert ( example_text ) 2649feed 'gg' 2650for _ , i in ipairs { 1 , 2 , 3 , 5 , 6 , 7 } do 2651for _ , j in ipairs { 2 , 5 , 10 , 15 } do 2652api . nvim_buf_set_extmark ( 0 , ns , i , j , { end_col =j + 2 , hl_group ='NonText' } ) 2653end 2654end 2655screen : expect { 2656grid =[[ 2657^for _,item in ipairs(items) do | 2658{1: }l{1:oc}al {1:te}xt,{1: h}l_id_cell, count = unpack(item) | 2659{1: }i{1:f }hl_{1:id}_ce{1:ll} ~= nil then | 2660{1: } {1: } hl{1:_i}d ={1: h}l_id_cell | 2661end | 2662{1: }f{1:or} _ {1:= }1, {1:(c}ount or 1) do | 2663{1: } {1: } lo{1:ca}l c{1:el}l = line[colpos] | 2664{1: } {1: } ce{1:ll}.te{1:xt} = text | 2665cell.hl_id = hl_id | 2666colpos = colpos+1 | 2667end | 2668end | 2669{1:~ }|*2 2670| 2671]] , 2672} 2673feed '5<c-e>' 2674screen : expect { 2675grid =[[ 2676^ {1: }f{1:or} _ {1:= }1, {1:(c}ount or 1) do | 2677{1: } {1: } lo{1:ca}l c{1:el}l = line[colpos] | 2678{1: } {1: } ce{1:ll}.te{1:xt} = text | 2679cell.hl_id = hl_id | 2680colpos = colpos+1 | 2681end | 2682end | 2683{1:~ }|*7 2684| 2685]] , 2686} 2687 2688api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { end_line =8 , end_col =10 , hl_group ='ErrorMsg' } ) 2689screen : expect { 2690grid =[[ 2691{4:^ }{36: }{4:f}{36:or}{4: _ }{36:= }{4:1, }{36:(c}{4:ount or 1) do} | 2692{4: }{36: }{4: }{36: }{4: lo}{36:ca}{4:l c}{36:el}{4:l = line[colpos]} | 2693{4: }{36: }{4: }{36: }{4: ce}{36:ll}{4:.te}{36:xt}{4: = text} | 2694{4: ce}ll.hl_id = hl_id | 2695colpos = colpos+1 | 2696end | 2697end | 2698{1:~ }|*7 2699| 2700]] , 2701} 2702end ) 2703 2704local function with_undo_restore ( val ) 2705screen : try_resize ( 50 , 5 ) 2706insert ( example_text ) 2707feed 'gg' 2708api . nvim_buf_set_extmark ( 0 , ns , 0 , 6 , { end_col =13 , hl_group ='NonText' , undo_restore =val } ) 2709screen : expect { 2710grid =[[ 2711^for _,{1:item in} ipairs(items) do | 2712local text, hl_id_cell, count = unpack(item) | 2713if hl_id_cell ~= nil then | 2714hl_id = hl_id_cell | 2715| 2716]] , 2717} 2718 2719api . nvim_buf_set_text ( 0 , 0 , 4 , 0 , 8 , { '' } ) 2720screen : expect { 2721grid =[[ 2722^for {1:em in} ipairs(items) do | 2723local text, hl_id_cell, count = unpack(item) | 2724if hl_id_cell ~= nil then | 2725hl_id = hl_id_cell | 2726| 2727]] , 2728} 2729end 2730 2731it ( 'highlights do reapply to restored text after delete' , function () 2732with_undo_restore ( true ) -- also default behavior 2733 2734command ( 'silent undo' ) 2735screen : expect { 2736grid =[[ 2737^for _,{1:item in} ipairs(items) do | 2738local text, hl_id_cell, count = unpack(item) | 2739if hl_id_cell ~= nil then | 2740hl_id = hl_id_cell | 2741| 2742]] , 2743} 2744end ) 2745 2746it ( "highlights don't reapply to restored text after delete with undo_restore=false" , function () 2747with_undo_restore ( false ) 2748 2749command ( 'silent undo' ) 2750screen : expect { 2751grid =[[ 2752^for _,it{1:em in} ipairs(items) do | 2753local text, hl_id_cell, count = unpack(item) | 2754if hl_id_cell ~= nil then | 2755hl_id = hl_id_cell | 2756| 2757]] , 2758} 2759 2760eq ( { 2761{ 27621 , 27630 , 27648 , 2765{ 2766end_col =13 , 2767end_right_gravity =false , 2768end_row =0 , 2769hl_eol =false , 2770hl_group ='NonText' , 2771undo_restore =false , 2772ns_id =ns , 2773priority =4096 , 2774right_gravity =true , 2775} , 2776} , 2777} , api . nvim_buf_get_extmarks ( 0 , ns , { 0 , 0 } , { 0 , - 1 } , { details =true } )) 2778end ) 2779 2780it ( 'virtual text works with rightleft' , function () 2781screen : try_resize ( 50 , 3 ) 2782insert ( 'abcdefghijklmn' ) 2783feed ( '0' ) 2784command ( 'set rightleft' ) 2785api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'EOL' , 'Underlined' } } } ) 2786api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'right_align' , 'Underlined' } } , virt_text_pos ='right_align' } ) 2787api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'win_col' , 'Underlined' } } , virt_text_win_col =20 } ) 2788api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { virt_text ={ { 'overlayed' , 'Underlined' } } , virt_text_pos ='overlay' } ) 2789screen : expect { 2790grid =[[ 2791{28:ngila_thgir} {28:loc_niw} {28:LOE} nml{28:deyalrevo}b^a| 2792{1: ~}| 2793| 2794]] , 2795} 2796 2797insert (( '#' ): rep ( 32 )) 2798feed ( '0' ) 2799screen : expect { 2800grid =[[ 2801{28:ngila_tdeyalrevo}ba#####{28:loc_niw}###################^#| 2802{1: ~}| 2803| 2804]] , 2805} 2806 2807insert (( '#' ): rep ( 16 )) 2808feed ( '0' ) 2809screen : expect { 2810grid =[[ 2811{28:ngila_thgir}############{28:loc_niw}###################^#| 2812{28:LOE} nml{28:deyalrevo}| 2813| 2814]] , 2815} 2816 2817insert ( '###' ) 2818feed ( '0' ) 2819screen : expect { 2820grid =[[ 2821#################################################^#| 2822{28:ngila_thgir} {28:loc_niw} {28:LOE} nml{28:deyalrevo}ba#| 2823| 2824]] , 2825} 2826 2827command ( 'set number' ) 2828screen : expect { 2829grid =[[ 2830#############################################^#{2: 1 }| 2831{28:ngila_thgir} {28:loc_niw} nml{28:deyalrevo}ba#####{2: }| 2832| 2833]] , 2834} 2835 2836command ( 'set cpoptions+=n' ) 2837screen : expect { 2838grid =[[ 2839#############################################^#{2: 1 }| 2840{28:ngila_thgir} {28:loc_niw} nml{28:deyalrevo}ba#####| 2841| 2842]] , 2843} 2844end ) 2845 2846it ( 'virtual text overwrites double-width char properly' , function () 2847screen : try_resize ( 50 , 3 ) 2848insert ( 'abcdefghij口klmnopqrstu口vwx口yz' ) 2849feed ( '0' ) 2850api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { '!!!!!' , 'Underlined' } } , virt_text_win_col =11 } ) 2851screen : expect { 2852grid =[[ 2853^abcdefghij {28:!!!!!}opqrstu口vwx口yz | 2854{1:~ }| 2855| 2856]] , 2857} 2858feed ( '8x' ) 2859screen : expect { 2860grid =[[ 2861^ij口klmnopq{28:!!!!!} vwx口yz | 2862{1:~ }| 2863| 2864]] , 2865} 2866feed ( '3l5x' ) 2867screen : expect { 2868grid =[[ 2869ij口^pqrstu {28:!!!!!} yz | 2870{1:~ }| 2871| 2872]] , 2873} 2874feed ( '5x' ) 2875screen : expect { 2876grid =[[ 2877ij口^u口vwx {28:!!!!!} | 2878{1:~ }| 2879| 2880]] , 2881} 2882end ) 2883 2884it ( 'virtual text blending space does not overwrite double-width char' , function () 2885screen : try_resize ( 50 , 3 ) 2886insert ( 'abcdefghij口klmnopqrstu口vwx口yz' ) 2887feed ( '0' ) 2888command ( 'hi Blendy guibg=Red blend=30' ) 2889api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { ' ! ! ' , 'Blendy' } } , virt_text_win_col =8 , hl_mode ='blend' } ) 2890screen : expect { 2891grid =[[ 2892^abcdefgh{10:i}{7:!}{10:口}{7:!}{10:l}mnopqrstu口vwx口yz | 2893{1:~ }| 2894| 2895]] , 2896} 2897feed ( 'x' ) 2898screen : expect { 2899grid =[[ 2900^bcdefghi{10:j}{7:!}{10: k}{7:!}{10:m}nopqrstu口vwx口yz | 2901{1:~ }| 2902| 2903]] , 2904} 2905feed ( 'x' ) 2906screen : expect { 2907grid =[[ 2908^cdefghij{10: }{7:!}{10:kl}{7:!}{10:n}opqrstu口vwx口yz | 2909{1:~ }| 2910| 2911]] , 2912} 2913feed ( 'x' ) 2914screen : expect { 2915grid =[[ 2916^defghij口{7:!}{10:lm}{7:!}{10:o}pqrstu口vwx口yz | 2917{1:~ }| 2918| 2919]] , 2920} 2921feed ( '7x' ) 2922screen : expect { 2923grid =[[ 2924^口klmnop{10:q}{7:!}{10:st}{7:!}{10:口}vwx口yz | 2925{1:~ }| 2926| 2927]] , 2928} 2929end ) 2930 2931it ( 'virtual text works with double-width char and rightleft' , function () 2932screen : try_resize ( 50 , 3 ) 2933insert ( 'abcdefghij口klmnopqrstu口vwx口yz' ) 2934feed ( '0' ) 2935command ( 'set rightleft' ) 2936screen : expect { 2937grid =[[ 2938zy口xwv口utsrqponmlk口jihgfedcb^a| 2939{1: ~}| 2940| 2941]] , 2942} 2943api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { virt_text ={ { 'overlayed' , 'Underlined' } } , virt_text_pos ='overlay' } ) 2944api . nvim_buf_set_extmark ( 0 , ns , 0 , 14 , { virt_text ={ { '古' , 'Underlined' } } , virt_text_pos ='overlay' } ) 2945api . nvim_buf_set_extmark ( 0 , ns , 0 , 20 , { virt_text ={ { '\t' , 'Underlined' } } , virt_text_pos ='overlay' } ) 2946api . nvim_buf_set_extmark ( 0 , ns , 0 , 29 , { virt_text ={ { '古' , 'Underlined' } } , virt_text_pos ='overlay' } ) 2947screen : expect { 2948grid =[[ 2949zy {28:古}wv {28: }qpon{28:古}k {28:deyalrevo}b^a| 2950{1: ~}| 2951| 2952]] , 2953} 2954end ) 2955 2956it ( 'virtual text is drawn correctly after delete and undo #27368' , function () 2957insert ( 'aaa\nbbb\nccc\nddd\neee' ) 2958command ( 'vsplit' ) 2959api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { virt_text ={ { 'EOL' } } } ) 2960feed ( '3gg' ) 2961screen : expect { 2962grid =[[ 2963aaa │aaa | 2964bbb │bbb | 2965^ccc EOL │ccc EOL | 2966ddd │ddd | 2967eee │eee | 2968{1:~ }│{1:~ }|*8 2969{41:[No Name] [+] }{40:[No Name] [+] }| 2970| 2971]] , 2972} 2973feed ( 'dd' ) 2974screen : expect { 2975grid =[[ 2976aaa │aaa | 2977bbb │bbb | 2978^ddd EOL │ddd EOL | 2979eee │eee | 2980{1:~ }│{1:~ }|*9 2981{41:[No Name] [+] }{40:[No Name] [+] }| 2982| 2983]] , 2984} 2985command ( 'silent undo' ) 2986screen : expect { 2987grid =[[ 2988aaa │aaa | 2989bbb │bbb | 2990^ccc EOL │ccc EOL | 2991ddd │ddd | 2992eee │eee | 2993{1:~ }│{1:~ }|*8 2994{41:[No Name] [+] }{40:[No Name] [+] }| 2995| 2996]] , 2997} 2998end ) 2999 3000it ( 'virtual text does not crash with blend, conceal and wrap #27836' , function () 3001screen : try_resize ( 50 , 3 ) 3002insert (( 'a' ): rep ( 45 ) .. '|hidden|' .. ( 'b' ): rep ( 45 )) 3003command ( 'syntax match test /|hidden|/ conceal' ) 3004command ( 'set conceallevel=2 concealcursor=n' ) 3005api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'FOO' } } , virt_text_pos ='right_align' , hl_mode ='blend' } ) 3006screen : expect { 3007grid =[[ 3008aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa FOO| 3009bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^b | 3010| 3011]] , 3012} 3013end ) 3014 3015it ( 'works with both hl_group and sign_hl_group' , function () 3016screen : try_resize ( 50 , 3 ) 3017screen : add_extra_attr_ids ( { 3018[ 100 ] ={ background =Screen . colors . WebGray , foreground =Screen . colors . Blue , bold =true } , 3019} ) 3020insert ( 'abcdefghijklmn' ) 3021api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { sign_text ='S' , sign_hl_group ='NonText' , hl_group ='Error' , end_col =14 } ) 3022screen : expect ( [[ 3023{100:S }{9:abcdefghijklm^n} | 3024{1:~ }| 3025| 3026]] ) 3027end ) 3028 3029it ( 'virt_text_repeat_linebreak repeats virtual text on wrapped lines' , function () 3030screen : try_resize ( 40 , 5 ) 3031api . nvim_set_option_value ( 'breakindent' , true , {} ) 3032insert ( example_text ) 3033api . nvim_buf_set_extmark ( 30340 , 3035ns , 30361 , 30370 , 3038{ virt_text ={ { '│' , 'NonText' } } , virt_text_pos ='overlay' , virt_text_repeat_linebreak =true } 3039) 3040api . nvim_buf_set_extmark ( 30410 , 3042ns , 30431 , 30443 , 3045{ virt_text ={ { '│' , 'NonText' } } , virt_text_pos ='overlay' , virt_text_repeat_linebreak =true } 3046) 3047command ( 'norm gg' ) 3048screen : expect { 3049grid =[[ 3050^for _,item in ipairs(items) do | 3051{1:│} {1:│}local text, hl_id_cell, count = unpa| 3052{1:│} {1:│}ck(item) | 3053if hl_id_cell ~= nil then | 3054| 3055]] , 3056} 3057api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 3058api . nvim_buf_set_extmark ( 30590 , 3060ns , 30611 , 30620 , 3063{ virt_text ={ { '│' , 'NonText' } } , virt_text_repeat_linebreak =true , virt_text_win_col =0 } 3064) 3065api . nvim_buf_set_extmark ( 30660 , 3067ns , 30681 , 30690 , 3070{ virt_text ={ { '│' , 'NonText' } } , virt_text_repeat_linebreak =true , virt_text_win_col =2 } 3071) 3072screen : expect { 3073grid =[[ 3074^for _,item in ipairs(items) do | 3075{1:│} {1:│} local text, hl_id_cell, count = unpa| 3076{1:│} {1:│} ck(item) | 3077if hl_id_cell ~= nil then | 3078| 3079]] , 3080} 3081end ) 3082 3083it ( 'supports URLs' , function () 3084insert ( example_text ) 3085 3086local url1 ='https://example.com' 3087local url2 ='http://127.0.0.1' 3088 3089screen : add_extra_attr_ids { 3090u ={ url =url1 } , 3091uh ={ url =url2 , background =Screen . colors . Yellow } , 3092} 3093 3094api . nvim_buf_set_extmark ( 0 , ns , 1 , 4 , { 3095end_col =14 , 3096url =url1 , 3097} ) 3098api . nvim_buf_set_extmark ( 0 , ns , 2 , 4 , { 3099end_col =17 , 3100hl_group ='Search' , 3101url =url2 , 3102} ) 3103 3104screen : expect ( [[ 3105for _,item in ipairs(items) do | 3106{u:local text}, hl_id_cell, count = unpack(item) | 3107{uh:if hl_id_cell} ~= nil then | 3108hl_id = hl_id_cell | 3109end | 3110for _ = 1, (count or 1) do | 3111local cell = line[colpos] | 3112cell.text = text | 3113cell.hl_id = hl_id | 3114colpos = colpos+1 | 3115end | 3116en^d | 3117{1:~ }|*2 3118| 3119]] ) 3120end ) 3121 3122it ( 'can replace marks in place with different decorations #27211' , function () 3123local mark =api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines ={ { { 'foo' , 'ErrorMsg' } } } } ) 3124screen : expect { 3125grid =[[ 3126^ | 3127{4:foo} | 3128{1:~ }|*12 3129| 3130]] , 3131} 3132 3133api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 3134id =mark , 3135virt_text ={ { 'testing' , 'NonText' } } , 3136virt_text_pos ='inline' , 3137} ) 3138screen : expect { 3139grid =[[ 3140{1:^testing} | 3141{1:~ }|*13 3142| 3143]] , 3144} 3145 3146api . nvim_buf_del_extmark ( 0 , ns , mark ) 3147screen : expect { 3148grid =[[ 3149^ | 3150{1:~ }|*13 3151| 3152]] , 3153} 3154 3155n . assert_alive () 3156end ) 3157 3158it ( 'priority ordering of overlay or win_col virtual text at same position' , function () 3159api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'A' } } , virt_text_pos ='overlay' , priority =100 } ) 3160api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'A' } } , virt_text_win_col =30 , priority =100 } ) 3161api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'BB' } } , virt_text_pos ='overlay' , priority =90 } ) 3162api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'BB' } } , virt_text_win_col =30 , priority =90 } ) 3163api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'CCC' } } , virt_text_pos ='overlay' , priority =80 } ) 3164api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'CCC' } } , virt_text_win_col =30 , priority =80 } ) 3165screen : expect ( [[ 3166^ABC ABC | 3167{1:~ }|*13 3168| 3169]] ) 3170end ) 3171 3172it ( 'priority ordering of inline and non-inline virtual text at same char' , function () 3173insert (( '?' ): rep ( 40 ) .. ( '!' ): rep ( 30 )) 3174api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'A' } } , virt_text_pos ='overlay' , priority =10 } ) 3175api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'a' } } , virt_text_win_col =15 , priority =10 } ) 3176api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'BBBB' } } , virt_text_pos ='inline' , priority =15 } ) 3177api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'C' } } , virt_text_pos ='overlay' , priority =20 } ) 3178api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'c' } } , virt_text_win_col =17 , priority =20 } ) 3179api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'DDDD' } } , virt_text_pos ='inline' , priority =25 } ) 3180api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'E' } } , virt_text_pos ='overlay' , priority =30 } ) 3181api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'e' } } , virt_text_win_col =19 , priority =30 } ) 3182api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'FFFF' } } , virt_text_pos ='inline' , priority =35 } ) 3183api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'G' } } , virt_text_pos ='overlay' , priority =40 } ) 3184api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'g' } } , virt_text_win_col =21 , priority =40 } ) 3185api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'HHHH' } } , virt_text_pos ='inline' , priority =45 } ) 3186api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'I' } } , virt_text_pos ='overlay' , priority =50 } ) 3187api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'i' } } , virt_text_win_col =23 , priority =50 } ) 3188api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'JJJJ' } } , virt_text_pos ='inline' , priority =55 } ) 3189api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'K' } } , virt_text_pos ='overlay' , priority =60 } ) 3190api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { 'k' } } , virt_text_win_col =25 , priority =60 } ) 3191screen : expect ( [[ 3192???????????????a?c?e????????????????????ABBBCDDDEF| 3193FFGHHHIJJJK!!!!!!!!!!g!i!k!!!!!!!!!!!!!^! | 3194{1:~ }|*12 3195| 3196]] ) 3197feed ( '02x$' ) 3198screen : expect ( [[ 3199???????????????a?c?e??????????????????ABBBCDDDEFFF| 3200GHHHIJJJK!!!!!!!!!!!!g!i!k!!!!!!!!!!!^! | 3201{1:~ }|*12 3202| 3203]] ) 3204feed ( '02x$' ) 3205screen : expect ( [[ 3206???????????????a?c?e?g??????????????ABBBCDDDEFFFGH| 3207HHIJJJK!!!!!!!!!!!!!!!!i!k!!!!!!!!!^! | 3208{1:~ }|*12 3209| 3210]] ) 3211feed ( '02x$' ) 3212screen : expect ( [[ 3213???????????????a?c?e?g????????????ABBBCDDDEFFFGHHH| 3214IJJJK!!!!!!!!!!!!!!!!!!i!k!!!!!!!^! | 3215{1:~ }|*12 3216| 3217]] ) 3218command ( 'set nowrap' ) 3219feed ( '0' ) 3220screen : expect ( [[ 3221^???????????????a?c?e?g?i?k????????ABBBCDDDEFFFGHHH| 3222{1:~ }|*13 3223| 3224]] ) 3225feed ( '2x' ) 3226screen : expect ( [[ 3227^???????????????a?c?e?g?i?k??????ABBBCDDDEFFFGHHHIJ| 3228{1:~ }|*13 3229| 3230]] ) 3231feed ( '2x' ) 3232screen : expect ( [[ 3233^???????????????a?c?e?g?i?k????ABBBCDDDEFFFGHHHIJJJ| 3234{1:~ }|*13 3235| 3236]] ) 3237feed ( '2x' ) 3238screen : expect ( [[ 3239^???????????????a?c?e?g?i?k??ABBBCDDDEFFFGHHHIJJJK!| 3240{1:~ }|*13 3241| 3242]] ) 3243end ) 3244 3245it ( 'conceal_lines' , function () 3246insert ( example_text ) 3247exec ( 'set number conceallevel=3' ) 3248feed ( 'ggj' ) 3249local not_concealed ={ 3250grid =[[ 3251{2: 1 }for _,item in ipairs(items) do | 3252{2: 2 }^ local text, hl_id_cell, count = unpack(ite| 3253{2: }m) | 3254{2: 3 } if hl_id_cell ~= nil then | 3255{2: 4 } hl_id = hl_id_cell | 3256{2: 5 } end | 3257{2: 6 } for _ = 1, (count or 1) do | 3258{2: 7 } local cell = line[colpos] | 3259{2: 8 } cell.text = text | 3260{2: 9 } cell.hl_id = hl_id | 3261{2: 10 } colpos = colpos+1 | 3262{2: 11 } end | 3263{2: 12 }end | 3264{1:~ }| 3265| 3266]] , 3267} 3268screen : expect ( not_concealed ) 3269api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { conceal_lines ='' } ) 3270screen : expect_unchanged () 3271feed ( 'j' ) 3272local concealed ={ 3273grid =[[ 3274{2: 1 }for _,item in ipairs(items) do | 3275{2: 3 }^ if hl_id_cell ~= nil then | 3276{2: 4 } hl_id = hl_id_cell | 3277{2: 5 } end | 3278{2: 6 } for _ = 1, (count or 1) do | 3279{2: 7 } local cell = line[colpos] | 3280{2: 8 } cell.text = text | 3281{2: 9 } cell.hl_id = hl_id | 3282{2: 10 } colpos = colpos+1 | 3283{2: 11 } end | 3284{2: 12 }end | 3285{1:~ }|*3 3286| 3287]] , 3288} 3289screen : expect ( concealed ) 3290feed ( 'k' ) 3291screen : expect ( not_concealed ) 3292exec ( 'set concealcursor=n' ) 3293screen : expect ( concealed ) 3294api . nvim_buf_set_extmark ( 0 , ns , 3 , 0 , { conceal_lines ='' } ) 3295screen : expect ( { 3296grid =[[ 3297{2: 1 }for _,item in ipairs(items) do | 3298{2: 3 }^ if hl_id_cell ~= nil then | 3299{2: 5 } end | 3300{2: 6 } for _ = 1, (count or 1) do | 3301{2: 7 } local cell = line[colpos] | 3302{2: 8 } cell.text = text | 3303{2: 9 } cell.hl_id = hl_id | 3304{2: 10 } colpos = colpos+1 | 3305{2: 11 } end | 3306{2: 12 }end | 3307{1:~ }|*4 3308| 3309]] , 3310} ) 3311feed ( 'kjj' ) 3312screen : expect_unchanged () 3313api . nvim_buf_set_extmark ( 0 , ns , 4 , 0 , { conceal_lines ='' } ) 3314feed ( 'kjjjC' ) 3315screen : expect ( { 3316grid =[[ 3317{2: 1 }for _,item in ipairs(items) do | 3318{2: 3 } if hl_id_cell ~= nil then | 3319{2: 5 }^ | 3320{2: 6 } for _ = 1, (count or 1) do | 3321{2: 7 } local cell = line[colpos] | 3322{2: 8 } cell.text = text | 3323{2: 9 } cell.hl_id = hl_id | 3324{2: 10 } colpos = colpos+1 | 3325{2: 11 } end | 3326{2: 12 }end | 3327{1:~ }|*4 3328{24:-- INSERT --} | 3329]] , 3330} ) 3331feed ( '<esc>' ) 3332screen : expect ( { 3333grid =[[ 3334{2: 1 }for _,item in ipairs(items) do | 3335{2: 3 } if hl_id_cell ~= nil then | 3336{2: 6 }^ for _ = 1, (count or 1) do | 3337{2: 7 } local cell = line[colpos] | 3338{2: 8 } cell.text = text | 3339{2: 9 } cell.hl_id = hl_id | 3340{2: 10 } colpos = colpos+1 | 3341{2: 11 } end | 3342{2: 12 }end | 3343{1:~ }|*5 3344| 3345]] , 3346} ) 3347feed ( 'kji' ) 3348screen : expect ( { 3349grid =[[ 3350{2: 1 }for _,item in ipairs(items) do | 3351{2: 3 } if hl_id_cell ~= nil then | 3352{2: 5 }^ | 3353{2: 6 } for _ = 1, (count or 1) do | 3354{2: 7 } local cell = line[colpos] | 3355{2: 8 } cell.text = text | 3356{2: 9 } cell.hl_id = hl_id | 3357{2: 10 } colpos = colpos+1 | 3358{2: 11 } end | 3359{2: 12 }end | 3360{1:~ }|*4 3361{24:-- INSERT --} | 3362]] , 3363} ) 3364feed ( 'conceal text' ) 3365screen : expect ( { 3366grid =[[ 3367{2: 1 }for _,item in ipairs(items) do | 3368{2: 3 } if hl_id_cell ~= nil then | 3369{2: 5 }conceal text^ | 3370{2: 6 } for _ = 1, (count or 1) do | 3371{2: 7 } local cell = line[colpos] | 3372{2: 8 } cell.text = text | 3373{2: 9 } cell.hl_id = hl_id | 3374{2: 10 } colpos = colpos+1 | 3375{2: 11 } end | 3376{2: 12 }end | 3377{1:~ }|*4 3378{24:-- INSERT --} | 3379]] , 3380} ) 3381feed ( '<esc>' ) 3382screen : expect ( { 3383grid =[[ 3384{2: 1 }for _,item in ipairs(items) do | 3385{2: 3 } if hl_id_cell ~= nil then | 3386{2: 6 } for _ =^ 1, (count or 1) do | 3387{2: 7 } local cell = line[colpos] | 3388{2: 8 } cell.text = text | 3389{2: 9 } cell.hl_id = hl_id | 3390{2: 10 } colpos = colpos+1 | 3391{2: 11 } end | 3392{2: 12 }end | 3393{1:~ }|*5 3394| 3395]] , 3396} ) 3397feed ( 'ggzfj' ) 3398screen : expect ( { 3399grid =[[ 3400{2: 1 }{33:^+-- 2 lines: for _,item in ipairs(items) do··}| 3401{2: 3 } if hl_id_cell ~= nil then | 3402{2: 6 } for _ = 1, (count or 1) do | 3403{2: 7 } local cell = line[colpos] | 3404{2: 8 } cell.text = text | 3405{2: 9 } cell.hl_id = hl_id | 3406{2: 10 } colpos = colpos+1 | 3407{2: 11 } end | 3408{2: 12 }end | 3409{1:~ }|*5 3410| 3411]] , 3412} ) 3413feed ( 'j' ) 3414screen : expect ( { 3415grid =[[ 3416{2: 1 }{33:+-- 2 lines: for _,item in ipairs(items) do··}| 3417{2: 3 }^ if hl_id_cell ~= nil then | 3418{2: 6 } for _ = 1, (count or 1) do | 3419{2: 7 } local cell = line[colpos] | 3420{2: 8 } cell.text = text | 3421{2: 9 } cell.hl_id = hl_id | 3422{2: 10 } colpos = colpos+1 | 3423{2: 11 } end | 3424{2: 12 }end | 3425{1:~ }|*5 3426| 3427]] , 3428} ) 3429feed ( 'ggzdjzfj' ) 3430screen : expect ( { 3431grid =[[ 3432{2: 1 }for _,item in ipairs(items) do | 3433{2: 6 }^ for _ = 1, (count or 1) do | 3434{2: 7 } local cell = line[colpos] | 3435{2: 8 } cell.text = text | 3436{2: 9 } cell.hl_id = hl_id | 3437{2: 10 } colpos = colpos+1 | 3438{2: 11 } end | 3439{2: 12 }end | 3440{1:~ }|*6 3441| 3442]] , 3443} ) 3444feed ( 'jj' ) 3445screen : expect ( { 3446grid =[[ 3447{2: 1 }^for _,item in ipairs(items) do | 3448{2: 6 } for _ = 1, (count or 1) do | 3449{2: 7 } local cell = line[colpos] | 3450{2: 8 } cell.text = text | 3451{2: 9 } cell.hl_id = hl_id | 3452{2: 10 } colpos = colpos+1 | 3453{2: 11 } end | 3454{2: 12 }end | 3455{1:~ }|*6 3456| 3457]] , 3458} ) 3459-- Below virtual line belonging to line above concealed line is drawn. 3460api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines ={ { { 'line 1 below' } } } } ) 3461-- Above virtual line belonging to concealed line isn't. 3462api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { 3463virt_lines ={ { { 'line 2 above' } } } , 3464virt_lines_above =true , 3465} ) 3466screen : expect ( [[ 3467{2: 1 }for _,item in ipairs(items) do | 3468{2: }line 1 below | 3469{2: 6 }^ for _ = 1, (count or 1) do | 3470{2: 7 } local cell = line[colpos] | 3471{2: 8 } cell.text = text | 3472{2: 9 } cell.hl_id = hl_id | 3473{2: 10 } colpos = colpos+1 | 3474{2: 11 } end | 3475{2: 12 }end | 3476{1:~ }|*5 3477| 3478]] ) 3479-- w_lines.wl_lastlnum values are valid 3480command ( 'set relativenumber concealcursor=' ) 3481api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 3482api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { conceal_lines ='' } ) 3483api . nvim_buf_set_extmark ( 0 , ns , 4 , 0 , { conceal_lines ='' } ) 3484feed ( 'zE' ) 3485screen : expect ( [[ 3486{2: 4 }for _,item in ipairs(items) do | 3487{2: 2 } if hl_id_cell ~= nil then | 3488{2: 1 } hl_id = hl_id_cell | 3489{2:5 }^conceal text | 3490{2: 1 } for _ = 1, (count or 1) do | 3491{2: 2 } local cell = line[colpos] | 3492{2: 3 } cell.text = text | 3493{2: 4 } cell.hl_id = hl_id | 3494{2: 5 } colpos = colpos+1 | 3495{2: 6 } end | 3496{2: 7 }end | 3497{1:~ }|*3 3498| 3499]] ) 3500feed ( 'jj' ) 3501screen : expect ( [[ 3502{2: 6 }for _,item in ipairs(items) do | 3503{2: 4 } if hl_id_cell ~= nil then | 3504{2: 3 } hl_id = hl_id_cell | 3505{2: 1 } for _ = 1, (count or 1) do | 3506{2:7 }^ local cell = line[colpos] | 3507{2: 1 } cell.text = text | 3508{2: 2 } cell.hl_id = hl_id | 3509{2: 3 } colpos = colpos+1 | 3510{2: 4 } end | 3511{2: 5 }end | 3512{1:~ }|*4 3513| 3514]] ) 3515-- Correct relativenumber for line below concealed line #33694 3516feed ( '4Gk' ) 3517screen : expect ( [[ 3518{2: 2 }for _,item in ipairs(items) do | 3519{2:3 } if h^l_id_cell ~= nil then | 3520{2: 1 } hl_id = hl_id_cell | 3521{2: 3 } for _ = 1, (count or 1) do | 3522{2: 4 } local cell = line[colpos] | 3523{2: 5 } cell.text = text | 3524{2: 6 } cell.hl_id = hl_id | 3525{2: 7 } colpos = colpos+1 | 3526{2: 8 } end | 3527{2: 9 }end | 3528{1:~ }|*4 3529| 3530]] ) 3531-- Also with above virtual line #32744 3532command ( 'set nornu' ) 3533api . nvim_buf_set_extmark ( 0 , ns , 3 , 0 , { virt_lines ={ { { 'virt_below 4' } } } } ) 3534feed ( '6G' ) 3535screen : expect ( [[ 3536{2: 1 }for _,item in ipairs(items) do | 3537{2: 3 } if hl_id_cell ~= nil then | 3538{2: 4 } hl_id = hl_id_cell | 3539{2: }virt_below 4 | 3540{2: 6 } ^for _ = 1, (count or 1) do | 3541{2: 7 } local cell = line[colpos] | 3542{2: 8 } cell.text = text | 3543{2: 9 } cell.hl_id = hl_id | 3544{2: 10 } colpos = colpos+1 | 3545{2: 11 } end | 3546{2: 12 }end | 3547{1:~ }|*3 3548| 3549]] ) 3550feed ( 'j' ) 3551screen : expect ( [[ 3552{2: 1 }for _,item in ipairs(items) do | 3553{2: 3 } if hl_id_cell ~= nil then | 3554{2: 4 } hl_id = hl_id_cell | 3555{2: }virt_below 4 | 3556{2: 6 } for _ = 1, (count or 1) do | 3557{2: 7 } ^ local cell = line[colpos] | 3558{2: 8 } cell.text = text | 3559{2: 9 } cell.hl_id = hl_id | 3560{2: 10 } colpos = colpos+1 | 3561{2: 11 } end | 3562{2: 12 }end | 3563{1:~ }|*3 3564| 3565]] ) 3566-- Even when virtual line is added as line is concealed #32762 3567feed ( '5G' ) 3568api . nvim_buf_clear_namespace ( 0 , ns , 3 , 4 ) 3569feed ( 'j' ) 3570api . nvim_buf_set_extmark ( 0 , ns , 3 , 0 , { virt_lines ={ { { 'virt_below 4' } } } } ) 3571screen : expect ( [[ 3572{2: 1 }for _,item in ipairs(items) do | 3573{2: 3 } if hl_id_cell ~= nil then | 3574{2: 4 } hl_id = hl_id_cell | 3575{2: }virt_below 4 | 3576{2: 6 }^ for _ = 1, (count or 1) do | 3577{2: 7 } local cell = line[colpos] | 3578{2: 8 } cell.text = text | 3579{2: 9 } cell.hl_id = hl_id | 3580{2: 10 } colpos = colpos+1 | 3581{2: 11 } end | 3582{2: 12 }end | 3583{1:~ }|*3 3584| 3585]] ) 3586-- No scrolling for concealed topline #33033 3587api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 3588api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { virt_lines_above =true , virt_lines ={ { { 'virt_above 2' } } } } ) 3589api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { conceal_lines ='' } ) 3590feed ( 'ggjj' ) 3591screen : expect ( [[ 3592{2: }virt_above 2 | 3593{2: 2 } local text, hl_id_cell, count = unpack(ite| 3594{2: }m) | 3595{2: 3 }^ if hl_id_cell ~= nil then | 3596{2: 4 } hl_id = hl_id_cell | 3597{2: 5 }conceal text | 3598{2: 6 } for _ = 1, (count or 1) do | 3599{2: 7 } local cell = line[colpos] | 3600{2: 8 } cell.text = text | 3601{2: 9 } cell.hl_id = hl_id | 3602{2: 10 } colpos = colpos+1 | 3603{2: 11 } end | 3604{2: 12 }end | 3605{1:~ }| 3606| 3607]] ) 3608-- No asymmetric topline for <C-E><C-Y> #33182 3609feed ( '4<C-E>' ) 3610exec ( 'set concealcursor=n' ) 3611api . nvim_buf_set_extmark ( 0 , ns , 4 , 0 , { conceal_lines ='' } ) 3612eq ( 5 , n . fn . line ( 'w0' )) 3613feed ( '<C-E><C-Y>' ) 3614eq ( 5 , n . fn . line ( 'w0' )) 3615end ) 3616 3617it ( 'conceal_lines not checking on invalid row #36057' , function () 3618exec_lua ( function () 3619vim . fn . setline ( 1 , { 'foo' , 'bar' , 'baz' } ) 3620vim . api . nvim_command ( 'set conceallevel=3 scrolloff=3' ) 3621vim . api . nvim_open_win ( 0 , true , { width =1 , height =1 , relative ='editor' , row =0 , col =0 } ) 3622vim . api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { conceal_lines ='' } ) 3623vim . api . nvim__redraw ( { flush =true } ) 3624end ) 3625n . assert_alive () 3626end ) 3627 3628it ( 'redraws the line from which a left gravity mark has moved #27369' , function () 3629fn . setline ( 1 , { 'aaa' , 'bbb' , 'ccc' , 'ddd' } ) 3630api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { virt_text ={ { 'foo' } } , right_gravity =false } ) 3631feed ( 'yyp' ) 3632screen : expect ( [[ 3633aaa | 3634^aaa foo | 3635bbb | 3636ccc | 3637ddd | 3638{1:~ }|*9 3639| 3640]] ) 3641end ) 3642 3643it ( 'redraws extmark that starts and ends outside the screen' , function () 3644local lines =vim . split (( '1' ): rep ( 20 ), '' , { plain =true } ) 3645api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , lines ) 3646api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { hl_group ='ErrorMsg' , end_row =19 , end_col =0 } ) 3647screen : expect ( { 3648grid =[[ 3649{4:^1} | 3650{4:1} |*13 3651| 3652]] , 3653} ) 3654feed ( '<C-e>' ) 3655-- Newly visible line should also have the highlight. 3656screen : expect ( { 3657grid =[[ 3658{4:^1} | 3659{4:1} |*13 3660| 3661]] , 3662} ) 3663end ) 3664 3665it ( 'line("w$", win) considers conceal_lines' , function () 3666api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'line 1' , 'line 2' , 'line 3' } ) 3667api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { conceal_lines ='' } ) -- conceal line 1 3668 3669local win =exec_lua ( function () 3670local provider_ns =vim . api . nvim_create_namespace ( 'test_f_line' ) 3671_G . line_w_dollar ={} 3672vim . api . nvim_set_decoration_provider ( provider_ns , { 3673on_start =function () 3674for _ , win in ipairs ( vim . api . nvim_tabpage_list_wins ( 0 )) do 3675table . insert ( _G . line_w_dollar , { win , vim . fn . line ( 'w$' , win ) } ) 3676end 3677end , 3678} ) 3679 3680local win =vim . api . nvim_open_win ( 0 , false , { 3681relative ='editor' , 3682width =20 , 3683height =1 , 3684row =0 , 3685col =0 , 3686border ='single' , 3687} ) 3688vim . api . nvim_set_option_value ( 'conceallevel' , 2 , { scope ='local' , win =win } ) 3689 3690return win 3691end ) 3692 3693local line_w_dollar =exec_lua ( 'return _G.line_w_dollar' ) 3694for _ , win_line in ipairs ( line_w_dollar ) do 3695if win_line [ 1 ] == win then 3696eq ( 2 , win_line [ 2 ]) 3697end 3698end 3699end ) 3700end ) 3701 3702describe ( 'decorations: inline virtual text' , function () 3703local screen ---@type test.functional.ui.screen 3704local ns ---@type integer 3705before_each ( function () 3706clear () 3707screen =Screen . new ( 50 , 3 ) 3708screen : set_default_attr_ids { 3709[ 1 ] ={ bold =true , foreground =Screen . colors . Blue } , 3710[ 2 ] ={ foreground =Screen . colors . Brown } , 3711[ 3 ] ={ bold =true , foreground =Screen . colors . SeaGreen } , 3712[ 4 ] ={ background =Screen . colors . Red1 , foreground =Screen . colors . Gray100 } , 3713[ 5 ] ={ background =Screen . colors . Red1 , bold =true } , 3714[ 6 ] ={ foreground =Screen . colors . DarkCyan } , 3715[ 7 ] ={ background =Screen . colors . LightGrey , foreground =Screen . colors . Black } , 3716[ 8 ] ={ bold =true } , 3717[ 9 ] ={ background =Screen . colors . Plum1 } , 3718[ 10 ] ={ foreground =Screen . colors . SlateBlue } , 3719[ 11 ] ={ blend =30 , background =Screen . colors . Red1 } , 3720[ 12 ] ={ background =Screen . colors . Yellow } , 3721[ 13 ] ={ reverse =true } , 3722[ 14 ] ={ foreground =Screen . colors . SlateBlue , background =Screen . colors . LightMagenta } , 3723[ 15 ] ={ bold =true , reverse =true } , 3724[ 16 ] ={ foreground =Screen . colors . Red } , 3725[ 17 ] ={ background =Screen . colors . LightGrey , foreground =Screen . colors . DarkBlue } , 3726[ 18 ] ={ background =Screen . colors . LightGrey , foreground =Screen . colors . Red } , 3727[ 19 ] ={ background =Screen . colors . Yellow , foreground =Screen . colors . SlateBlue } , 3728[ 20 ] ={ background =Screen . colors . LightGrey , foreground =Screen . colors . SlateBlue } , 3729[ 21 ] ={ reverse =true , foreground =Screen . colors . SlateBlue } , 3730[ 22 ] ={ background =Screen . colors . Gray90 } , 3731[ 23 ] ={ background =Screen . colors . Gray90 , foreground =Screen . colors . Blue , bold =true } , 3732[ 24 ] ={ foreground =Screen . colors . Blue } , 3733} 3734 3735ns =api . nvim_create_namespace 'test' 3736end ) 3737 3738it ( 'works' , function () 3739screen : try_resize ( 50 , 10 ) 3740insert ( example_text ) 3741feed 'gg' 3742screen : expect { 3743grid =[[ 3744^for _,item in ipairs(items) do | 3745local text, hl_id_cell, count = unpack(item) | 3746if hl_id_cell ~= nil then | 3747hl_id = hl_id_cell | 3748end | 3749for _ = 1, (count or 1) do | 3750local cell = line[colpos] | 3751cell.text = text | 3752cell.hl_id = hl_id | 3753| 3754]] , 3755} 3756 3757api . nvim_buf_set_extmark ( 0 , ns , 1 , 14 , { virt_text ={ { ': ' , 'Special' } , { 'string' , 'Type' } } , virt_text_pos ='inline' } ) 3758screen : expect { 3759grid =[[ 3760^for _,item in ipairs(items) do | 3761local text{10:: }{3:string}, hl_id_cell, count = unpack| 3762(item) | 3763if hl_id_cell ~= nil then | 3764hl_id = hl_id_cell | 3765end | 3766for _ = 1, (count or 1) do | 3767local cell = line[colpos] | 3768cell.text = text | 3769| 3770]] , 3771} 3772 3773screen : try_resize ( 55 , 10 ) 3774screen : expect { 3775grid =[[ 3776^for _,item in ipairs(items) do | 3777local text{10:: }{3:string}, hl_id_cell, count = unpack(item| 3778) | 3779if hl_id_cell ~= nil then | 3780hl_id = hl_id_cell | 3781end | 3782for _ = 1, (count or 1) do | 3783local cell = line[colpos] | 3784cell.text = text | 3785| 3786]] , 3787} 3788 3789screen : try_resize ( 56 , 10 ) 3790screen : expect { 3791grid =[[ 3792^for _,item in ipairs(items) do | 3793local text{10:: }{3:string}, hl_id_cell, count = unpack(item)| 3794if hl_id_cell ~= nil then | 3795hl_id = hl_id_cell | 3796end | 3797for _ = 1, (count or 1) do | 3798local cell = line[colpos] | 3799cell.text = text | 3800cell.hl_id = hl_id | 3801| 3802]] , 3803} 3804end ) 3805 3806it ( 'works with 0-width chunk' , function () 3807screen : try_resize ( 50 , 10 ) 3808insert ( example_text ) 3809feed 'gg' 3810screen : expect { 3811grid =[[ 3812^for _,item in ipairs(items) do | 3813local text, hl_id_cell, count = unpack(item) | 3814if hl_id_cell ~= nil then | 3815hl_id = hl_id_cell | 3816end | 3817for _ = 1, (count or 1) do | 3818local cell = line[colpos] | 3819cell.text = text | 3820cell.hl_id = hl_id | 3821| 3822]] , 3823} 3824 3825api . nvim_buf_set_extmark ( 0 , ns , 0 , 5 , { virt_text ={ { '' } , { '' } } , virt_text_pos ='inline' } ) 3826api . nvim_buf_set_extmark ( 0 , ns , 1 , 14 , { virt_text ={ { '' } , { ': ' , 'Special' } } , virt_text_pos ='inline' } ) 3827api . nvim_buf_set_extmark ( 0 , ns , 1 , 48 , { virt_text ={ { '' } , { '' } } , virt_text_pos ='inline' } ) 3828screen : expect { 3829grid =[[ 3830^for _,item in ipairs(items) do | 3831local text{10:: }, hl_id_cell, count = unpack(item)| 3832if hl_id_cell ~= nil then | 3833hl_id = hl_id_cell | 3834end | 3835for _ = 1, (count or 1) do | 3836local cell = line[colpos] | 3837cell.text = text | 3838cell.hl_id = hl_id | 3839| 3840]] , 3841} 3842 3843api . nvim_buf_set_extmark ( 0 , ns , 1 , 14 , { virt_text ={ { '' } , { 'string' , 'Type' } } , virt_text_pos ='inline' } ) 3844feed ( 'V' ) 3845screen : expect { 3846grid =[[ 3847{7:^for _,item in ipairs(items) do} | 3848local text{10:: }{3:string}, hl_id_cell, count = unpack| 3849(item) | 3850if hl_id_cell ~= nil then | 3851hl_id = hl_id_cell | 3852end | 3853for _ = 1, (count or 1) do | 3854local cell = line[colpos] | 3855cell.text = text | 3856{8:-- VISUAL LINE --} | 3857]] , 3858} 3859 3860feed ( '<Esc>jf,' ) 3861screen : expect { 3862grid =[[ 3863for _,item in ipairs(items) do | 3864local text{10:: }{3:string}^, hl_id_cell, count = unpack| 3865(item) | 3866if hl_id_cell ~= nil then | 3867hl_id = hl_id_cell | 3868end | 3869for _ = 1, (count or 1) do | 3870local cell = line[colpos] | 3871cell.text = text | 3872| 3873]] , 3874} 3875end ) 3876 3877it ( 'Normal mode "gM" command works properly' , function () 3878command ( [[call setline(1, '123456789')]] ) 3879api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { virt_text ={ { 'bbb' , 'Special' } } , virt_text_pos ='inline' } ) 3880api . nvim_buf_set_extmark ( 0 , ns , 0 , 7 , { virt_text ={ { 'bbb' , 'Special' } } , virt_text_pos ='inline' } ) 3881feed ( 'gM' ) 3882screen : expect { 3883grid =[[ 388412{10:bbb}34^567{10:bbb}89 | 3885{1:~ }| 3886| 3887]] , 3888} 3889end ) 3890 3891local function test_normal_gj_gk () 3892screen : try_resize ( 60 , 6 ) 3893command ( [[call setline(1, repeat([repeat('a', 55)], 2))]] ) 3894api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { ( 'b' ): rep ( 10 ), 'Special' } } , virt_text_pos ='inline' } ) 3895api . nvim_buf_set_extmark ( 0 , ns , 1 , 40 , { virt_text ={ { ( 'b' ): rep ( 10 ), 'Special' } } , virt_text_pos ='inline' } ) 3896screen : expect { 3897grid =[[ 3898^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3899aaaaa | 3900aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3901aaaaa | 3902{1:~ }| 3903| 3904]] , 3905} 3906feed ( 'gj' ) 3907screen : expect { 3908grid =[[ 3909aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3910^aaaaa | 3911aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3912aaaaa | 3913{1:~ }| 3914| 3915]] , 3916} 3917feed ( 'gj' ) 3918screen : expect { 3919grid =[[ 3920aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3921aaaaa | 3922^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3923aaaaa | 3924{1:~ }| 3925| 3926]] , 3927} 3928feed ( 'gj' ) 3929screen : expect { 3930grid =[[ 3931aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3932aaaaa | 3933aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3934^aaaaa | 3935{1:~ }| 3936| 3937]] , 3938} 3939feed ( 'gk' ) 3940screen : expect { 3941grid =[[ 3942aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3943aaaaa | 3944^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3945aaaaa | 3946{1:~ }| 3947| 3948]] , 3949} 3950feed ( 'gk' ) 3951screen : expect { 3952grid =[[ 3953aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3954^aaaaa | 3955aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3956aaaaa | 3957{1:~ }| 3958| 3959]] , 3960} 3961feed ( 'gk' ) 3962screen : expect { 3963grid =[[ 3964^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3965aaaaa | 3966aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| 3967aaaaa | 3968{1:~ }| 3969| 3970]] , 3971} 3972end 3973 3974describe ( 'Normal mode "gj" "gk" commands work properly' , function () 3975it ( 'with virtualedit=' , function () 3976test_normal_gj_gk () 3977end ) 3978 3979it ( 'with virtualedit=all' , function () 3980command ( 'set virtualedit=all' ) 3981test_normal_gj_gk () 3982end ) 3983end ) 3984 3985it ( 'cursor positions are correct with multiple inline virtual text' , function () 3986insert ( '12345678' ) 3987api . nvim_buf_set_extmark ( 0 , ns , 0 , 4 , { virt_text ={ { ' virtual text ' , 'Special' } } , virt_text_pos ='inline' } ) 3988api . nvim_buf_set_extmark ( 0 , ns , 0 , 4 , { virt_text ={ { ' virtual text ' , 'Special' } } , virt_text_pos ='inline' } ) 3989feed '^' 3990feed '4l' 3991screen : expect { 3992grid =[[ 39931234{10: virtual text virtual text }^5678 | 3994{1:~ }| 3995| 3996]] , 3997} 3998end ) 3999 4000it ( 'adjusts cursor location correctly when inserting around inline virtual text' , function () 4001insert ( '12345678' ) 4002feed '$' 4003api . nvim_buf_set_extmark ( 0 , ns , 0 , 4 , { virt_text ={ { ' virtual text ' , 'Special' } } , virt_text_pos ='inline' } ) 4004 4005screen : expect { 4006grid =[[ 40071234{10: virtual text }567^8 | 4008{1:~ }| 4009| 4010]] , 4011} 4012end ) 4013 4014it ( 'has correct highlighting with multi-byte characters' , function () 4015insert ( '12345678' ) 4016api . nvim_buf_set_extmark ( 0 , ns , 0 , 4 , { virt_text ={ { 'múlti-byté chñröcters 修补' , 'Special' } } , virt_text_pos ='inline' } ) 4017 4018screen : expect { 4019grid =[[ 40201234{10:múlti-byté chñröcters 修补}567^8 | 4021{1:~ }| 4022| 4023]] , 4024} 4025end ) 4026 4027it ( 'has correct cursor position when inserting around virtual text' , function () 4028insert ( '12345678' ) 4029api . nvim_buf_set_extmark ( 0 , ns , 0 , 4 , { virt_text ={ { 'virtual text' , 'Special' } } , virt_text_pos ='inline' } ) 4030feed '^' 4031feed '3l' 4032feed 'a' 4033screen : expect { 4034grid =[[ 40351234{10:^virtual text}5678 | 4036{1:~ }| 4037{8:-- INSERT --} | 4038]] , 4039} 4040feed '<ESC>' 4041screen : expect { 4042grid =[[ 4043123^4{10:virtual text}5678 | 4044{1:~ }| 4045| 4046]] , 4047} 4048feed '^' 4049feed '4l' 4050feed 'i' 4051screen : expect { 4052grid =[[ 40531234{10:^virtual text}5678 | 4054{1:~ }| 4055{8:-- INSERT --} | 4056]] , 4057} 4058end ) 4059 4060it ( 'has correct cursor position with virtual text on an empty line' , function () 4061api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'virtual text' , 'Special' } } , virt_text_pos ='inline' } ) 4062screen : expect { 4063grid =[[ 4064{10:^virtual text} | 4065{1:~ }| 4066| 4067]] , 4068} 4069end ) 4070 4071it ( 'text is drawn correctly with a wrapping virtual text' , function () 4072screen : try_resize ( 60 , 8 ) 4073exec ( [[ 4074call setline(1, ['', 'aaa', '', 'bbbbbb']) 4075normal gg0 4076]] ) 4077api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { string . rep ( 'X' , 60 ), 'Special' } } , virt_text_pos ='inline' } ) 4078api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { virt_text ={ { string . rep ( 'X' , 61 ), 'Special' } } , virt_text_pos ='inline' } ) 4079feed ( '$' ) 4080screen : expect { 4081grid =[[ 4082{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4083aaa | 4084{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4085{10:X} | 4086bbbbbb | 4087{1:~ }|*2 4088| 4089]] , 4090} 4091feed ( 'j' ) 4092screen : expect { 4093grid =[[ 4094{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4095aa^a | 4096{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4097{10:X} | 4098bbbbbb | 4099{1:~ }|*2 4100| 4101]] , 4102} 4103feed ( 'j' ) 4104screen : expect { 4105grid =[[ 4106{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4107aaa | 4108{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4109{10:X} | 4110bbbbbb | 4111{1:~ }|*2 4112| 4113]] , 4114} 4115feed ( 'j' ) 4116screen : expect { 4117grid =[[ 4118{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4119aaa | 4120{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4121{10:X} | 4122bbbbb^b | 4123{1:~ }|*2 4124| 4125]] , 4126} 4127feed ( '0<C-V>2l2k' ) 4128screen : expect { 4129grid =[[ 4130{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4131{7:aa^a} | 4132{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4133{10:X} | 4134{7:bbb}bbb | 4135{1:~ }|*2 4136{8:-- VISUAL BLOCK --} | 4137]] , 4138} 4139feed ( [[<Esc>/aaa\n\%V<CR>]] ) 4140screen : expect { 4141grid =[[ 4142{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4143{12:^aaa } | 4144{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4145{10:X} | 4146bbbbbb | 4147{1:~ }|*2 4148{16:search hit BOTTOM, continuing at TOP} | 4149]] , 4150} 4151feed ( '3ggic' ) 4152screen : expect { 4153grid =[[ 4154{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4155{12:aaa } | 4156c{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4157{10:XX} | 4158bbbbbb | 4159{1:~ }|*2 4160{8:-- INSERT --} | 4161]] , 4162} 4163feed ( [[<Esc>/aaa\nc\%V<CR>]] ) 4164screen : expect { 4165grid =[[ 4166{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4167{12:^aaa } | 4168{12:c}{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4169{10:XX} | 4170bbbbbb | 4171{1:~ }|*2 4172{16:search hit BOTTOM, continuing at TOP} | 4173]] , 4174} 4175end ) 4176 4177it ( 'cursor position is correct with virtual text attached to hard TABs' , function () 4178command ( 'set noexpandtab' ) 4179feed ( 'i' ) 4180feed ( '<TAB>' ) 4181feed ( '<TAB>' ) 4182feed ( 'test' ) 4183feed ( '<ESC>' ) 4184api . nvim_buf_set_extmark ( 0 , ns , 0 , 1 , { virt_text ={ { 'virtual text' , 'Special' } } , virt_text_pos ='inline' } ) 4185feed ( '0' ) 4186screen : expect { 4187grid =[[ 4188^ {10:virtual text} test | 4189{1:~ }| 4190| 4191]] , 4192} 4193 4194feed ( 'l' ) 4195screen : expect { 4196grid =[[ 4197{10:virtual text} ^ test | 4198{1:~ }| 4199| 4200]] , 4201} 4202 4203feed ( 'l' ) 4204screen : expect { 4205grid =[[ 4206{10:virtual text} ^test | 4207{1:~ }| 4208| 4209]] , 4210} 4211 4212feed ( 'l' ) 4213screen : expect { 4214grid =[[ 4215{10:virtual text} t^est | 4216{1:~ }| 4217| 4218]] , 4219} 4220 4221feed ( 'l' ) 4222screen : expect { 4223grid =[[ 4224{10:virtual text} te^st | 4225{1:~ }| 4226| 4227]] , 4228} 4229end ) 4230 4231it ( 'cursor position is correct with virtual text on an empty line' , function () 4232command ( 'set linebreak' ) 4233insert ( 'one twoword' ) 4234feed ( '0' ) 4235api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { virt_text ={ { ': virtual text' , 'Special' } } , virt_text_pos ='inline' } ) 4236screen : expect { 4237grid =[[ 4238^one{10:: virtual text} twoword | 4239{1:~ }| 4240| 4241]] , 4242} 4243end ) 4244 4245it ( 'search highlight is correct' , function () 4246insert ( 'foo foo foo bar\nfoo foo foo bar' ) 4247feed ( 'gg0' ) 4248api . nvim_buf_set_extmark ( 0 , ns , 0 , 9 , { virt_text ={ { 'AAA' , 'Special' } } , virt_text_pos ='inline' } ) 4249api . nvim_buf_set_extmark ( 0 , ns , 0 , 9 , { virt_text ={ { 'BBB' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4250api . nvim_buf_set_extmark ( 0 , ns , 1 , 9 , { virt_text ={ { 'CCC' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4251api . nvim_buf_set_extmark ( 0 , ns , 1 , 9 , { virt_text ={ { 'DDD' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='replace' } ) 4252screen : expect { 4253grid =[[ 4254^foo foo f{10:AAABBB}oo bar | 4255foo foo f{10:CCCDDD}oo bar | 4256| 4257]] , 4258} 4259 4260feed ( '/foo' ) 4261screen : expect { 4262grid =[[ 4263{12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} bar | 4264{12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | 4265/foo^ | 4266]] , 4267} 4268 4269api . nvim_buf_set_extmark ( 0 , ns , 0 , 13 , { virt_text ={ { 'EEE' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4270feed ( '<C-G>' ) 4271screen : expect { 4272grid =[[ 4273{12:foo} {12:foo} {13:f}{10:AAA}{21:BBB}{13:oo} b{10:EEE}ar | 4274{12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | 4275/foo^ | 4276]] , 4277} 4278end ) 4279 4280it ( 'Visual select highlight is correct' , function () 4281insert ( 'foo foo foo bar\nfoo foo foo bar' ) 4282feed ( 'gg0' ) 4283api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { 'AAA' , 'Special' } } , virt_text_pos ='inline' } ) 4284api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { 'BBB' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4285api . nvim_buf_set_extmark ( 0 , ns , 1 , 8 , { virt_text ={ { 'CCC' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4286api . nvim_buf_set_extmark ( 0 , ns , 1 , 8 , { virt_text ={ { 'DDD' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='replace' } ) 4287feed ( '8l' ) 4288screen : expect { 4289grid =[[ 4290foo foo {10:AAABBB}^foo bar | 4291foo foo {10:CCCDDD}foo bar | 4292| 4293]] , 4294} 4295 4296feed ( '<C-V>' ) 4297feed ( '2hj' ) 4298screen : expect { 4299grid =[[ 4300foo fo{7:o }{10:AAA}{20:BBB}{7:f}oo bar | 4301foo fo{7:^o }{20:CCC}{10:DDD}{7:f}oo bar | 4302{8:-- VISUAL BLOCK --} | 4303]] , 4304} 4305 4306api . nvim_buf_set_extmark ( 0 , ns , 0 , 10 , { virt_text ={ { 'EEE' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4307screen : expect { 4308grid =[[ 4309foo fo{7:o }{10:AAA}{20:BBB}{7:f}o{10:EEE}o bar | 4310foo fo{7:^o }{20:CCC}{10:DDD}{7:f}oo bar | 4311{8:-- VISUAL BLOCK --} | 4312]] , 4313} 4314end ) 4315 4316it ( 'inside highlight range of another extmark' , function () 4317insert ( 'foo foo foo bar\nfoo foo foo bar' ) 4318api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { 'AAA' , 'Special' } } , virt_text_pos ='inline' } ) 4319api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { 'BBB' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4320api . nvim_buf_set_extmark ( 0 , ns , 1 , 8 , { virt_text ={ { 'CCC' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4321api . nvim_buf_set_extmark ( 0 , ns , 1 , 8 , { virt_text ={ { 'DDD' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='replace' } ) 4322api . nvim_buf_set_extmark ( 0 , ns , 0 , 4 , { end_col =11 , hl_group ='Search' } ) 4323api . nvim_buf_set_extmark ( 0 , ns , 1 , 4 , { end_col =11 , hl_group ='Search' } ) 4324screen : expect { 4325grid =[[ 4326foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | 4327foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | 4328| 4329]] , 4330} 4331end ) 4332 4333it ( 'inside highlight range of syntax' , function () 4334insert ( 'foo foo foo bar\nfoo foo foo bar' ) 4335api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { 'AAA' , 'Special' } } , virt_text_pos ='inline' } ) 4336api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { 'BBB' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4337api . nvim_buf_set_extmark ( 0 , ns , 1 , 8 , { virt_text ={ { 'CCC' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 4338api . nvim_buf_set_extmark ( 0 , ns , 1 , 8 , { virt_text ={ { 'DDD' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='replace' } ) 4339command ( [[syntax match Search 'foo \zsfoo foo\ze bar']] ) 4340screen : expect { 4341grid =[[ 4342foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | 4343foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | 4344| 4345]] , 4346} 4347end ) 4348 4349it ( 'cursor position is correct when inserting around a virtual text with left gravity' , function () 4350screen : try_resize ( 27 , 4 ) 4351insert (( 'a' ): rep ( 15 )) 4352api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { ( '>' ): rep ( 43 ), 'Special' } } , virt_text_pos ='inline' , right_gravity =false } ) 4353command ( 'setlocal showbreak=+ breakindent breakindentopt=shift:2' ) 4354feed ( '08l' ) 4355screen : expect { 4356grid =[[ 4357aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| 4358{1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| 4359{1:+}^aaaaaaa | 4360| 4361]] , 4362} 4363feed ( 'i' ) 4364screen : expect { 4365grid =[[ 4366aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| 4367{1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| 4368{1:+}^aaaaaaa | 4369{8:-- INSERT --} | 4370]] , 4371} 4372feed ( [[<C-\><C-O>]] ) 4373screen : expect { 4374grid =[[ 4375aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| 4376{1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| 4377{1:+}^aaaaaaa | 4378{8:-- (insert) --} | 4379]] , 4380} 4381feed ( 'D' ) 4382screen : expect { 4383grid =[[ 4384aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| 4385{1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| 4386{1:^~ }| 4387{8:-- INSERT --} | 4388]] , 4389} 4390command ( 'setlocal list listchars=eol:$' ) 4391screen : expect { 4392grid =[[ 4393aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| 4394{1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| 4395{1:+^$} | 4396{8:-- INSERT --} | 4397]] , 4398} 4399feed ( '<C-U>' ) 4400screen : expect { 4401grid =[[ 4402{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4403{1:+}{10:>>>>>>>>>>>>>>>>}{1:^$} | 4404{1:~ }| 4405{8:-- INSERT --} | 4406]] , 4407} 4408feed ( 'a' ) 4409screen : expect { 4410grid =[[ 4411{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4412{1:+}{10:>>>>>>>>>>>>>>>>}a{1:^$} | 4413{1:~ }| 4414{8:-- INSERT --} | 4415]] , 4416} 4417feed ( '<Esc>' ) 4418screen : expect { 4419grid =[[ 4420{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4421{1:+}{10:>>>>>>>>>>>>>>>>}^a{1:$} | 4422{1:~ }| 4423| 4424]] , 4425} 4426feed ( 'x' ) 4427screen : expect { 4428grid =[[ 4429{10:^>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4430{1:+}{10:>>>>>>>>>>>>>>>>}{1:$} | 4431{1:~ }| 4432| 4433]] , 4434} 4435end ) 4436 4437it ( 'cursor position is correct when inserting around virtual texts with both left and right gravity' , function () 4438screen : try_resize ( 30 , 4 ) 4439command ( 'setlocal showbreak=+ breakindent breakindentopt=shift:2' ) 4440insert (( 'a' ): rep ( 15 )) 4441api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { ( '>' ): rep ( 32 ), 'Special' } } , virt_text_pos ='inline' , right_gravity =false } ) 4442api . nvim_buf_set_extmark ( 0 , ns , 0 , 8 , { virt_text ={ { ( '<' ): rep ( 32 ), 'Special' } } , virt_text_pos ='inline' , right_gravity =true } ) 4443feed ( '08l' ) 4444screen : expect { 4445grid =[[ 4446aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| 4447{1:+}{10:>>>>>>>>>><<<<<<<<<<<<<<<<<}| 4448{1:+}{10:<<<<<<<<<<<<<<<}^aaaaaaa | 4449| 4450]] , 4451} 4452feed ( 'i' ) 4453screen : expect { 4454grid =[[ 4455aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| 4456{1:+}{10:>>>>>>>>>>^<<<<<<<<<<<<<<<<<}| 4457{1:+}{10:<<<<<<<<<<<<<<<}aaaaaaa | 4458{8:-- INSERT --} | 4459]] , 4460} 4461feed ( 'a' ) 4462screen : expect { 4463grid =[[ 4464aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| 4465{1:+}{10:>>>>>>>>>>}a{10:^<<<<<<<<<<<<<<<<}| 4466{1:+}{10:<<<<<<<<<<<<<<<<}aaaaaaa | 4467{8:-- INSERT --} | 4468]] , 4469} 4470feed ( [[<C-\><C-O>]] ) 4471screen : expect { 4472grid =[[ 4473aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| 4474{1:+}{10:>>>>>>>>>>}a{10:<<<<<<<<<<<<<<<<}| 4475{1:+}{10:<<<<<<<<<<<<<<<<}^aaaaaaa | 4476{8:-- (insert) --} | 4477]] , 4478} 4479feed ( 'D' ) 4480screen : expect { 4481grid =[[ 4482aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| 4483{1:+}{10:>>>>>>>>>>}a{10:^<<<<<<<<<<<<<<<<}| 4484{1:+}{10:<<<<<<<<<<<<<<<<} | 4485{8:-- INSERT --} | 4486]] , 4487} 4488feed ( '<BS>' ) 4489screen : expect { 4490grid =[[ 4491aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| 4492{1:+}{10:>>>>>>>>>>^<<<<<<<<<<<<<<<<<}| 4493{1:+}{10:<<<<<<<<<<<<<<<} | 4494{8:-- INSERT --} | 4495]] , 4496} 4497feed ( '<C-U>' ) 4498screen : expect { 4499grid =[[ 4500{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4501{1:+}{10:>>^<<<<<<<<<<<<<<<<<<<<<<<<<}| 4502{1:+}{10:<<<<<<<} | 4503{8:-- INSERT --} | 4504]] , 4505} 4506feed ( 'a' ) 4507screen : expect { 4508grid =[[ 4509{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4510{1:+}{10:>>}a{10:^<<<<<<<<<<<<<<<<<<<<<<<<}| 4511{1:+}{10:<<<<<<<<} | 4512{8:-- INSERT --} | 4513]] , 4514} 4515feed ( '<Esc>' ) 4516screen : expect { 4517grid =[[ 4518{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4519{1:+}{10:>>}^a{10:<<<<<<<<<<<<<<<<<<<<<<<<}| 4520{1:+}{10:<<<<<<<<} | 4521| 4522]] , 4523} 4524feed ( 'x' ) 4525screen : expect { 4526grid =[[ 4527{10:^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4528{1:+}{10:>><<<<<<<<<<<<<<<<<<<<<<<<<}| 4529{1:+}{10:<<<<<<<} | 4530| 4531]] , 4532} 4533feed ( 'i' ) 4534screen : expect { 4535grid =[[ 4536{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4537{1:+}{10:>>^<<<<<<<<<<<<<<<<<<<<<<<<<}| 4538{1:+}{10:<<<<<<<} | 4539{8:-- INSERT --} | 4540]] , 4541} 4542screen : try_resize ( 32 , 4 ) 4543screen : expect { 4544grid =[[ 4545{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4546{1:+}{10:^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}| 4547{1:+}{10:<<<} | 4548{8:-- INSERT --} | 4549]] , 4550} 4551command ( 'setlocal nobreakindent' ) 4552screen : expect { 4553grid =[[ 4554{10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| 4555{1:+}{10:^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}| 4556{1:+}{10:<} | 4557{8:-- INSERT --} | 4558]] , 4559} 4560end ) 4561 4562it ( 'draws correctly with no wrap multiple virtual text, where one is hidden' , function () 4563insert ( 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' ) 4564command ( 'set nowrap' ) 4565api . nvim_buf_set_extmark ( 0 , ns , 0 , 50 , { virt_text ={ { 'virtual text' , 'Special' } } , virt_text_pos ='inline' } ) 4566api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { virt_text ={ { 'virtual text' , 'Special' } } , virt_text_pos ='inline' } ) 4567feed ( '$' ) 4568screen : expect { 4569grid =[[ 4570opqrstuvwxyzabcdefghijklmnopqrstuvwx{10:virtual text}y^z| 4571{1:~ }| 4572| 4573]] , 4574} 4575end ) 4576 4577it ( 'draws correctly with no wrap and a long virtual text' , function () 4578insert ( 'abcdefghi' ) 4579command ( 'set nowrap' ) 4580api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { virt_text ={ { string . rep ( 'X' , 55 ), 'Special' } } , virt_text_pos ='inline' } ) 4581feed ( '$' ) 4582screen : expect ( [[ 4583{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| 4584{1:~ }| 4585| 4586]] ) 4587command ( 'set list listchars+=precedes:!' ) 4588screen : expect ( [[ 4589{1:!}{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| 4590{1:~ }| 4591| 4592]] ) 4593end ) 4594 4595it ( 'draws correctly with no wrap and multibyte virtual text' , function () 4596insert ( '12345678' ) 4597command ( 'set nowrap' ) 4598api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { 4599hl_mode ='replace' , 4600virt_text ={ { 'α口β̳γ̲=' , 'Special' } , { '❤️' , 'Special' } } , 4601virt_text_pos ='inline' , 4602} ) 4603screen : expect ( [[ 460412{10:α口β̳γ̲=❤️}34567^8 | 4605{1:~ }| 4606| 4607]] ) 4608feed ( 'zl' ) 4609screen : expect ( [[ 46102{10:α口β̳γ̲=❤️}34567^8 | 4611{1:~ }| 4612| 4613]] ) 4614feed ( 'zl' ) 4615screen : expect ( [[ 4616{10:α口β̳γ̲=❤️}34567^8 | 4617{1:~ }| 4618| 4619]] ) 4620feed ( 'zl' ) 4621screen : expect ( [[ 4622{10:口β̳γ̲=❤️}34567^8 | 4623{1:~ }| 4624| 4625]] ) 4626feed ( 'V' ) 4627screen : expect ( [[ 4628{10:口β̳γ̲=❤️}{7:34567^8} | 4629{1:~ }| 4630{8:-- VISUAL LINE --} | 4631]] ) 4632command ( 'set list listchars+=precedes:!' ) 4633screen : expect ( [[ 4634{1:!<}{10:β̳γ̲=❤️}{7:34567^8} | 4635{1:~ }| 4636{8:-- VISUAL LINE --} | 4637]] ) 4638feed ( 'zl' ) 4639screen : expect ( [[ 4640{1:!}{10:β̳γ̲=❤️}{7:34567^8} | 4641{1:~ }| 4642{8:-- VISUAL LINE --} | 4643]] ) 4644command ( 'set nolist' ) 4645screen : expect ( [[ 4646{1:<}{10:β̳γ̲=❤️}{7:34567^8} | 4647{1:~ }| 4648{8:-- VISUAL LINE --} | 4649]] ) 4650feed ( '<Esc>' ) 4651screen : expect ( [[ 4652{1:<}{10:β̳γ̲=❤️}34567^8 | 4653{1:~ }| 4654| 4655]] ) 4656feed ( 'zl' ) 4657screen : expect ( [[ 4658{10:β̳γ̲=❤️}34567^8 | 4659{1:~ }| 4660| 4661]] ) 4662feed ( 'zl' ) 4663screen : expect ( [[ 4664{10:γ̲=❤️}34567^8 | 4665{1:~ }| 4666| 4667]] ) 4668feed ( 'zl' ) 4669screen : expect ( [[ 4670{10:=❤️}34567^8 | 4671{1:~ }| 4672| 4673]] ) 4674feed ( 'zl' ) 4675screen : expect ( [[ 4676{10:❤️}34567^8 | 4677{1:~ }| 4678| 4679]] ) 4680command ( 'set list' ) 4681screen : expect ( [[ 4682{1:!<}34567^8 | 4683{1:~ }| 4684| 4685]] ) 4686feed ( 'zl' ) 4687screen : expect ( [[ 4688{1:!}34567^8 | 4689{1:~ }| 4690| 4691]] ) 4692command ( 'set nolist' ) 4693screen : expect ( [[ 4694{1:<}34567^8 | 4695{1:~ }| 4696| 4697]] ) 4698feed ( 'zl' ) 4699screen : expect ( [[ 470034567^8 | 4701{1:~ }| 4702| 4703]] ) 4704feed ( 'zl' ) 4705screen : expect ( [[ 47064567^8 | 4707{1:~ }| 4708| 4709]] ) 4710end ) 4711 4712it ( 'tabs are the correct length with no wrap following virtual text' , function () 4713command ( 'set nowrap' ) 4714feed ( 'itest<TAB>a<ESC>' ) 4715api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { string . rep ( 'a' , 55 ), 'Special' } } , virt_text_pos ='inline' } ) 4716feed ( 'gg$' ) 4717screen : expect { 4718grid =[[ 4719{10:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | 4720{1:~ }| 4721| 4722]] , 4723} 4724end ) 4725 4726it ( 'highlighting does not extend with no wrap and a long virtual text' , function () 4727insert ( 'abcdef' ) 4728command ( 'set nowrap' ) 4729api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { virt_text ={ { string . rep ( 'X' , 50 ), 'Special' } } , virt_text_pos ='inline' } ) 4730feed ( '$' ) 4731screen : expect { 4732grid =[[ 4733{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| 4734{1:~ }| 4735| 4736]] , 4737} 4738end ) 4739 4740it ( 'hidden virtual text does not interfere with Visual highlight' , function () 4741insert ( 'abcdef' ) 4742command ( 'set nowrap' ) 4743api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'XXX' , 'Special' } } , virt_text_pos ='inline' } ) 4744feed ( 'V2zl' ) 4745screen : expect { 4746grid =[[ 4747{10:X}{7:abcde^f} | 4748{1:~ }| 4749{8:-- VISUAL LINE --} | 4750]] , 4751} 4752feed ( 'zl' ) 4753screen : expect { 4754grid =[[ 4755{7:abcde^f} | 4756{1:~ }| 4757{8:-- VISUAL LINE --} | 4758]] , 4759} 4760feed ( 'zl' ) 4761screen : expect { 4762grid =[[ 4763{7:bcde^f} | 4764{1:~ }| 4765{8:-- VISUAL LINE --} | 4766]] , 4767} 4768end ) 4769 4770it ( 'highlighting is correct when virtual text wraps with number' , function () 4771screen : try_resize ( 50 , 5 ) 4772insert ( [[ 4773test 4774test]] ) 4775command ( 'set number' ) 4776api . nvim_buf_set_extmark ( 0 , ns , 0 , 1 , { virt_text ={ { string . rep ( 'X' , 55 ), 'Special' } } , virt_text_pos ='inline' } ) 4777feed ( 'gg0' ) 4778screen : expect { 4779grid =[[ 4780{2: 1 }^t{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4781{2: }{10:XXXXXXXXXX}est | 4782{2: 2 }test | 4783{1:~ }| 4784| 4785]] , 4786} 4787end ) 4788 4789it ( 'highlighting is correct when virtual text is proceeded with a match' , function () 4790insert ( [[test]] ) 4791api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { virt_text ={ { 'virtual text' , 'Special' } } , virt_text_pos ='inline' } ) 4792feed ( 'gg0' ) 4793command ( 'match ErrorMsg /e/' ) 4794screen : expect { 4795grid =[[ 4796^t{4:e}{10:virtual text}st | 4797{1:~ }| 4798| 4799]] , 4800} 4801command ( 'match ErrorMsg /s/' ) 4802screen : expect { 4803grid =[[ 4804^te{10:virtual text}{4:s}t | 4805{1:~ }| 4806| 4807]] , 4808} 4809end ) 4810 4811it ( 'smoothscroll works correctly when virtual text wraps' , function () 4812insert ( 'foobar' ) 4813api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { virt_text ={ { string . rep ( 'X' , 55 ), 'Special' } } , virt_text_pos ='inline' } ) 4814command ( 'setlocal smoothscroll' ) 4815screen : expect { 4816grid =[[ 4817foo{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| 4818{10:XXXXXXXX}ba^r | 4819| 4820]] , 4821} 4822feed ( '<C-E>' ) 4823screen : expect { 4824grid =[[ 4825{1:<<<}{10:XXXXX}ba^r | 4826{1:~ }| 4827| 4828]] , 4829} 4830end ) 4831 4832it ( 'in diff mode is highlighted correct' , function () 4833screen : try_resize ( 50 , 10 ) 4834insert ( [[ 48359000 48360009 48370009 48389000 48390009 4840]] ) 4841insert ( 'aaa\tbbb' ) 4842command ( 'set diff' ) 4843api . nvim_buf_set_extmark ( 0 , ns , 0 , 1 , { virt_text ={ { 'test' , 'Special' } } , virt_text_pos ='inline' , right_gravity =false } ) 4844api . nvim_buf_set_extmark ( 0 , ns , 5 , 0 , { virt_text ={ { '!' , 'Special' } } , virt_text_pos ='inline' } ) 4845api . nvim_buf_set_extmark ( 0 , ns , 5 , 3 , { virt_text ={ { '' } } , virt_text_pos ='inline' } ) 4846command ( 'vnew' ) 4847insert ( [[ 4848000 4849000 4850000 4851000 4852000 4853]] ) 4854insert ( 'aaabbb' ) 4855command ( 'set diff' ) 4856feed ( 'gg0' ) 4857screen : expect { 4858grid =[[ 4859{9:^000 }│{5:9}{14:test}{9:000 }| 4860{9:000 }│{9:000}{5:9}{9: }|*2 4861{9:000 }│{5:9}{9:000 }| 4862{9:000 }│{9:000}{5:9}{9: }| 4863{9:aaabbb }│{14:!}{9:aaa}{5: }{9:bbb }| 4864{1:~ }│{1:~ }|*2 4865{15:[No Name] [+] }{13:[No Name] [+] }| 4866| 4867]] , 4868} 4869command ( 'wincmd w | set nowrap' ) 4870feed ( 'zl' ) 4871screen : expect { 4872grid =[[ 4873{9:000 }│{14:test}{9:000 }| 4874{9:000 }│{9:00}{5:9}{9: }|*2 4875{9:000 }│{9:000 }| 4876{9:000 }│{9:00}{5:9}{9: }| 4877{9:aaabbb }│{9:aaa}{5: }{9:bb^b }| 4878{1:~ }│{1:~ }|*2 4879{13:[No Name] [+] }{15:[No Name] [+] }| 4880| 4881]] , 4882} 4883end ) 4884 4885it ( 'correctly draws when there are multiple overlapping virtual texts on the same line with nowrap' , function () 4886command ( 'set nowrap' ) 4887insert ( 'a' ) 4888api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { string . rep ( 'a' , 55 ), 'Special' } } , virt_text_pos ='inline' } ) 4889api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { string . rep ( 'b' , 55 ), 'Special' } } , virt_text_pos ='inline' } ) 4890feed ( '$' ) 4891screen : expect { 4892grid =[[ 4893{10:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | 4894{1:~ }| 4895| 4896]] , 4897} 4898end ) 4899 4900it ( 'correctly draws when overflowing virtual text is followed by TAB with no wrap' , function () 4901command ( 'set nowrap' ) 4902feed ( 'i<TAB>test<ESC>' ) 4903api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { string . rep ( 'a' , 60 ), 'Special' } } , virt_text_pos ='inline' } ) 4904feed ( '0' ) 4905screen : expect ( { 4906grid =[[ 4907{10:aaaaaaaaaaaaaaaaaaaaaa} ^ test | 4908{1:~ }| 4909| 4910]] , 4911} ) 4912end ) 4913 4914it ( 'does not crash at column 0 when folded in a wide window' , function () 4915screen : try_resize ( 82 , 5 ) 4916command ( 'hi! CursorLine guibg=NONE guifg=Red gui=NONE' ) 4917command ( 'set cursorline' ) 4918insert ( [[ 4919aaaaa 4920bbbbb 4921 4922ccccc]] ) 4923api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'foo' } } , virt_text_pos ='inline' } ) 4924api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { virt_text ={ { 'bar' } } , virt_text_pos ='inline' } ) 4925screen : expect { 4926grid =[[ 4927fooaaaaa | 4928bbbbb | 4929bar | 4930{16:cccc^c }| 4931| 4932]] , 4933} 4934command ( '1,2fold' ) 4935screen : expect { 4936grid =[[ 4937{17:+-- 2 lines: aaaaa·······························································}| 4938bar | 4939{16:cccc^c }| 4940{1:~ }| 4941| 4942]] , 4943} 4944feed ( '2k' ) 4945screen : expect { 4946grid =[[ 4947{18:^+-- 2 lines: aaaaa·······························································}| 4948bar | 4949ccccc | 4950{1:~ }| 4951| 4952]] , 4953} 4954command ( '3,4fold' ) 4955screen : expect { 4956grid =[[ 4957{18:^+-- 2 lines: aaaaa·······························································}| 4958{17:+-- 2 lines: ccccc·······························································}| 4959{1:~ }|*2 4960| 4961]] , 4962} 4963feed ( 'j' ) 4964screen : expect { 4965grid =[[ 4966{17:+-- 2 lines: aaaaa·······························································}| 4967{18:^+-- 2 lines: ccccc·······························································}| 4968{1:~ }|*2 4969| 4970]] , 4971} 4972end ) 4973 4974it ( 'does not crash at right edge of wide window #23848' , function () 4975screen : try_resize ( 82 , 5 ) 4976api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { ( 'a' ): rep ( 82 ) } , { 'b' } } , virt_text_pos ='inline' } ) 4977screen : expect { 4978grid =[[ 4979^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 4980b | 4981{1:~ }|*2 4982| 4983]] , 4984} 4985command ( 'set nowrap' ) 4986screen : expect { 4987grid =[[ 4988^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 4989{1:~ }|*3 4990| 4991]] , 4992} 4993feed ( '82i0<Esc>0' ) 4994screen : expect { 4995grid =[[ 4996^0000000000000000000000000000000000000000000000000000000000000000000000000000000000| 4997{1:~ }|*3 4998| 4999]] , 5000} 5001command ( 'set wrap' ) 5002screen : expect { 5003grid =[[ 5004^0000000000000000000000000000000000000000000000000000000000000000000000000000000000| 5005aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 5006b | 5007{1:~ }| 5008| 5009]] , 5010} 5011end ) 5012 5013it ( 'lcs-extends is drawn with inline virtual text at end of screen line' , function () 5014exec ( [[ 5015setlocal nowrap list listchars=extends:! 5016call setline(1, repeat('a', 51)) 5017]] ) 5018api . nvim_buf_set_extmark ( 0 , ns , 0 , 50 , { virt_text ={ { 'bbb' , 'Special' } } , virt_text_pos ='inline' } ) 5019feed ( '20l' ) 5020screen : expect { 5021grid =[[ 5022aaaaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:!}| 5023{1:~ }| 5024| 5025]] , 5026} 5027feed ( 'zl' ) 5028screen : expect { 5029grid =[[ 5030aaaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:!}| 5031{1:~ }| 5032| 5033]] , 5034} 5035feed ( 'zl' ) 5036screen : expect { 5037grid =[[ 5038aaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:b}{1:!}| 5039{1:~ }| 5040| 5041]] , 5042} 5043feed ( 'zl' ) 5044screen : expect { 5045grid =[[ 5046aaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bb}{1:!}| 5047{1:~ }| 5048| 5049]] , 5050} 5051feed ( 'zl' ) 5052screen : expect { 5053grid =[[ 5054aaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbb}a| 5055{1:~ }| 5056| 5057]] , 5058} 5059end ) 5060 5061it ( 'lcs-extends is drawn with only inline virtual text offscreen' , function () 5062command ( 'set nowrap' ) 5063command ( 'set list' ) 5064command ( 'set listchars+=extends:c' ) 5065api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text ={ { 'test' , 'Special' } } , virt_text_pos ='inline' } ) 5066insert ( string . rep ( 'a' , 50 )) 5067feed ( 'gg0' ) 5068screen : expect { 5069grid =[[ 5070^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:c}| 5071{1:~ }| 5072| 5073]] , 5074} 5075end ) 5076 5077it ( 'blockwise Visual highlight with double-width virtual text (replace)' , function () 5078screen : try_resize ( 60 , 6 ) 5079insert ( '123456789\n123456789\n123456789\n123456789' ) 5080api . nvim_buf_set_extmark ( 0 , ns , 1 , 1 , { virt_text ={ { '-口-' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='replace' } ) 5081api . nvim_buf_set_extmark ( 0 , ns , 2 , 2 , { virt_text ={ { '口' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='replace' } ) 5082feed ( 'gg0' ) 5083screen : expect { 5084grid =[[ 5085^123456789 | 50861{10:-口-}23456789 | 508712{10:口}3456789 | 5088123456789 | 5089{1:~ }| 5090| 5091]] , 5092} 5093feed ( '<C-V>3jl' ) 5094screen : expect { 5095grid =[[ 5096{7:12}3456789 | 5097{7:1}{10:-口-}23456789 | 5098{7:12}{10:口}3456789 | 5099{7:1^2}3456789 | 5100{1:~ }| 5101{8:-- VISUAL BLOCK --} | 5102]] , 5103} 5104feed ( 'l' ) 5105screen : expect { 5106grid =[[ 5107{7:123}456789 | 5108{7:1}{10:-口-}23456789 | 5109{7:12}{10:口}3456789 | 5110{7:12^3}456789 | 5111{1:~ }| 5112{8:-- VISUAL BLOCK --} | 5113]] , 5114} 5115feed ( '4l' ) 5116screen : expect { 5117grid =[[ 5118{7:1234567}89 | 5119{7:1}{10:-口-}{7:23}456789 | 5120{7:12}{10:口}{7:345}6789 | 5121{7:123456^7}89 | 5122{1:~ }| 5123{8:-- VISUAL BLOCK --} | 5124]] , 5125} 5126feed ( 'Ol' ) 5127screen : expect { 5128grid =[[ 51291{7:234567}89 | 51301{10:-口-}{7:23}456789 | 51311{7:2}{10:口}{7:345}6789 | 51321{7:^234567}89 | 5133{1:~ }| 5134{8:-- VISUAL BLOCK --} | 5135]] , 5136} 5137feed ( 'l' ) 5138screen : expect { 5139grid =[[ 514012{7:34567}89 | 51411{10:-口-}{7:23}456789 | 514212{10:口}{7:345}6789 | 514312{7:^34567}89 | 5144{1:~ }| 5145{8:-- VISUAL BLOCK --} | 5146]] , 5147} 5148feed ( 'l' ) 5149screen : expect { 5150grid =[[ 5151123{7:4567}89 | 51521{10:-口-}{7:23}456789 | 515312{10:口}{7:345}6789 | 5154123{7:^4567}89 | 5155{1:~ }| 5156{8:-- VISUAL BLOCK --} | 5157]] , 5158} 5159end ) 5160 5161it ( 'blockwise Visual highlight with double-width virtual text (combine)' , function () 5162screen : try_resize ( 60 , 6 ) 5163insert ( '123456789\n123456789\n123456789\n123456789' ) 5164api . nvim_buf_set_extmark ( 0 , ns , 1 , 1 , { virt_text ={ { '-口-' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 5165api . nvim_buf_set_extmark ( 0 , ns , 2 , 2 , { virt_text ={ { '口' , 'Special' } } , virt_text_pos ='inline' , hl_mode ='combine' } ) 5166feed ( 'gg0' ) 5167screen : expect { 5168grid =[[ 5169^123456789 | 51701{10:-口-}23456789 | 517112{10:口}3456789 | 5172123456789 | 5173{1:~ }| 5174| 5175]] , 5176} 5177feed ( '<C-V>3jl' ) 5178screen : expect { 5179grid =[[ 5180{7:12}3456789 | 5181{7:1}{20:-}{10:口-}23456789 | 5182{7:12}{10:口}3456789 | 5183{7:1^2}3456789 | 5184{1:~ }| 5185{8:-- VISUAL BLOCK --} | 5186]] , 5187} 5188feed ( 'l' ) 5189screen : expect { 5190grid =[[ 5191{7:123}456789 | 5192{7:1}{20:-口}{10:-}23456789 | 5193{7:12}{20:口}3456789 | 5194{7:12^3}456789 | 5195{1:~ }| 5196{8:-- VISUAL BLOCK --} | 5197]] , 5198} 5199feed ( '4l' ) 5200screen : expect { 5201grid =[[ 5202{7:1234567}89 | 5203{7:1}{20:-口-}{7:23}456789 | 5204{7:12}{20:口}{7:345}6789 | 5205{7:123456^7}89 | 5206{1:~ }| 5207{8:-- VISUAL BLOCK --} | 5208]] , 5209} 5210feed ( 'Ol' ) 5211screen : expect { 5212grid =[[ 52131{7:234567}89 | 52141{20:-口-}{7:23}456789 | 52151{7:2}{20:口}{7:345}6789 | 52161{7:^234567}89 | 5217{1:~ }| 5218{8:-- VISUAL BLOCK --} | 5219]] , 5220} 5221feed ( 'l' ) 5222screen : expect { 5223grid =[[ 522412{7:34567}89 | 52251{10:-}{20:口-}{7:23}456789 | 522612{20:口}{7:345}6789 | 522712{7:^34567}89 | 5228{1:~ }| 5229{8:-- VISUAL BLOCK --} | 5230]] , 5231} 5232feed ( 'l' ) 5233screen : expect { 5234grid =[[ 5235123{7:4567}89 | 52361{10:-}{20:口-}{7:23}456789 | 523712{20:口}{7:345}6789 | 5238123{7:^4567}89 | 5239{1:~ }| 5240{8:-- VISUAL BLOCK --} | 5241]] , 5242} 5243end ) 5244 5245local function test_virt_inline_showbreak_smoothscroll () 5246screen : try_resize ( 30 , 6 ) 5247exec ( [[ 5248highlight! link LineNr Normal 5249setlocal number showbreak=+ breakindent breakindentopt=shift:2 5250setlocal scrolloff=0 smoothscroll 5251call setline(1, repeat('a', 28)) 5252normal! $ 5253]] ) 5254api . nvim_buf_set_extmark ( 0 , ns , 0 , 27 , { virt_text ={ { ( '123' ): rep ( 23 ) } } , virt_text_pos ='inline' } ) 5255feed ( ':<CR>' ) -- Have a screen line that doesn't start with spaces 5256screen : expect { 5257grid =[[ 52581 aaaaaaaaaaaaaaaaaaaaaaaaaa| 5259{1:+}a1231231231231231231231| 5260{1:+}23123123123123123123123| 5261{1:+}12312312312312312312312| 5262{1:+}3^a | 5263: | 5264]] , 5265} 5266feed ( '<C-E>' ) 5267screen : expect { 5268grid =[[ 5269{1:+}a1231231231231231231231| 5270{1:+}23123123123123123123123| 5271{1:+}12312312312312312312312| 5272{1:+}3^a | 5273{1:~ }| 5274: | 5275]] , 5276} 5277feed ( '<C-E>' ) 5278screen : expect { 5279grid =[[ 5280{1:+}23123123123123123123123| 5281{1:+}12312312312312312312312| 5282{1:+}3^a | 5283{1:~ }|*2 5284: | 5285]] , 5286} 5287feed ( '<C-E>' ) 5288screen : expect { 5289grid =[[ 5290{1:+}12312312312312312312312| 5291{1:+}3^a | 5292{1:~ }|*3 5293: | 5294]] , 5295} 5296feed ( '<C-E>' ) 5297screen : expect { 5298grid =[[ 5299{1:+}3^a | 5300{1:~ }|*4 5301: | 5302]] , 5303} 5304feed ( 'zbi' ) 5305screen : expect { 5306grid =[[ 53071 aaaaaaaaaaaaaaaaaaaaaaaaaa| 5308{1:+}a^1231231231231231231231| 5309{1:+}23123123123123123123123| 5310{1:+}12312312312312312312312| 5311{1:+}3a | 5312{8:-- INSERT --} | 5313]] , 5314} 5315feed ( '<BS>' ) 5316screen : expect { 5317grid =[[ 53181 aaaaaaaaaaaaaaaaaaaaaaaaaa| 5319{1:+}^12312312312312312312312| 5320{1:+}31231231231231231231231| 5321{1:+}23123123123123123123123| 5322{1:+}a | 5323{8:-- INSERT --} | 5324]] , 5325} 5326feed ( '<Esc>l' ) 5327feed ( ':<CR>' ) -- Have a screen line that doesn't start with spaces 5328screen : expect { 5329grid =[[ 53301 aaaaaaaaaaaaaaaaaaaaaaaaaa| 5331{1:+}12312312312312312312312| 5332{1:+}31231231231231231231231| 5333{1:+}23123123123123123123123| 5334{1:+}^a | 5335: | 5336]] , 5337} 5338feed ( '<C-E>' ) 5339screen : expect { 5340grid =[[ 5341{1:+}12312312312312312312312| 5342{1:+}31231231231231231231231| 5343{1:+}23123123123123123123123| 5344{1:+}^a | 5345{1:~ }| 5346: | 5347]] , 5348} 5349feed ( '<C-E>' ) 5350screen : expect { 5351grid =[[ 5352{1:+}31231231231231231231231| 5353{1:+}23123123123123123123123| 5354{1:+}^a | 5355{1:~ }|*2 5356: | 5357]] , 5358} 5359feed ( '<C-E>' ) 5360screen : expect { 5361grid =[[ 5362{1:+}23123123123123123123123| 5363{1:+}^a | 5364{1:~ }|*3 5365: | 5366]] , 5367} 5368feed ( '<C-E>' ) 5369screen : expect { 5370grid =[[ 5371{1:+}^a | 5372{1:~ }|*4 5373: | 5374]] , 5375} 5376feed ( '023x$' ) 5377screen : expect { 5378grid =[[ 53791 aaa12312312312312312312312| 5380{1:+}31231231231231231231231| 5381{1:+}23123123123123123123123| 5382{1:+}^a | 5383{1:~ }| 5384: | 5385]] , 5386} 5387feed ( '<C-E>' ) 5388screen : expect { 5389grid =[[ 5390{1:+}31231231231231231231231| 5391{1:+}23123123123123123123123| 5392{1:+}^a | 5393{1:~ }|*2 5394: | 5395]] , 5396} 5397feed ( '<C-E>' ) 5398screen : expect { 5399grid =[[ 5400{1:+}23123123123123123123123| 5401{1:+}^a | 5402{1:~ }|*3 5403: | 5404]] , 5405} 5406feed ( '<C-E>' ) 5407screen : expect { 5408grid =[[ 5409{1:+}^a | 5410{1:~ }|*4 5411: | 5412]] , 5413} 5414feed ( 'zbi' ) 5415screen : expect { 5416grid =[[ 54171 aaa^12312312312312312312312| 5418{1:+}31231231231231231231231| 5419{1:+}23123123123123123123123| 5420{1:+}a | 5421{1:~ }| 5422{8:-- INSERT --} | 5423]] , 5424} 5425feed ( '<C-U>' ) 5426screen : expect { 5427grid =[[ 54281 ^12312312312312312312312312| 5429{1:+}31231231231231231231231| 5430{1:+}23123123123123123123a | 5431{1:~ }|*2 5432{8:-- INSERT --} | 5433]] , 5434} 5435feed ( '<Esc>' ) 5436screen : expect { 5437grid =[[ 54381 12312312312312312312312312| 5439{1:+}31231231231231231231231| 5440{1:+}23123123123123123123^a | 5441{1:~ }|*2 5442| 5443]] , 5444} 5445feed ( '<C-E>' ) 5446screen : expect { 5447grid =[[ 5448{1:+}31231231231231231231231| 5449{1:+}23123123123123123123^a | 5450{1:~ }|*3 5451| 5452]] , 5453} 5454feed ( '<C-E>' ) 5455screen : expect { 5456grid =[[ 5457{1:+}23123123123123123123^a | 5458{1:~ }|*4 5459| 5460]] , 5461} 5462feed ( 'zbx' ) 5463screen : expect { 5464grid =[[ 54651 ^12312312312312312312312312| 5466{1:+}31231231231231231231231| 5467{1:+}23123123123123123123 | 5468{1:~ }|*2 5469| 5470]] , 5471} 5472feed ( '26ia<Esc>a' ) 5473screen : expect { 5474grid =[[ 54751 aaaaaaaaaaaaaaaaaaaaaaaaaa| 5476{1:+}^12312312312312312312312| 5477{1:+}31231231231231231231231| 5478{1:+}23123123123123123123123| 5479{1:~ }| 5480{8:-- INSERT --} | 5481]] , 5482} 5483feed ( [[<C-\><C-O>:setlocal breakindentopt=<CR>]] ) 5484screen : expect { 5485grid =[[ 54861 aaaaaaaaaaaaaaaaaaaaaaaaaa| 5487{1:+}^1231231231231231231231231| 5488{1:+}2312312312312312312312312| 5489{1:+}3123123123123123123 | 5490{1:~ }| 5491{8:-- INSERT --} | 5492]] , 5493} 5494end 5495 5496describe ( 'with showbreak, smoothscroll' , function () 5497it ( 'and cpoptions-=n' , function () 5498test_virt_inline_showbreak_smoothscroll () 5499end ) 5500 5501it ( 'and cpoptions+=n' , function () 5502command ( 'set cpoptions+=n' ) 5503-- because of 'breakindent' the screen states are the same 5504test_virt_inline_showbreak_smoothscroll () 5505end ) 5506end ) 5507 5508it ( 'before TABs with smoothscroll' , function () 5509screen : try_resize ( 30 , 6 ) 5510exec ( [[ 5511setlocal list listchars=tab:<-> scrolloff=0 smoothscroll 5512call setline(1, repeat("\t", 4) .. 'a') 5513normal! $ 5514]] ) 5515api . nvim_buf_set_extmark ( 0 , ns , 0 , 3 , { virt_text ={ { ( '12' ): rep ( 32 ) } } , virt_text_pos ='inline' } ) 5516screen : expect { 5517grid =[[ 5518{1:<------><------><------>}121212| 5519121212121212121212121212121212| 55201212121212121212121212121212{1:<-}| 5521{1:----->}^a | 5522{1:~ }| 5523| 5524]] , 5525} 5526feed ( '<C-E>' ) 5527screen : expect { 5528grid =[[ 5529{1:<<<}212121212121212121212121212| 55301212121212121212121212121212{1:<-}| 5531{1:----->}^a | 5532{1:~ }|*2 5533| 5534]] , 5535} 5536feed ( '<C-E>' ) 5537screen : expect { 5538grid =[[ 5539{1:<<<}2121212121212121212121212{1:<-}| 5540{1:----->}^a | 5541{1:~ }|*3 5542| 5543]] , 5544} 5545feed ( '<C-E>' ) 5546screen : expect { 5547grid =[[ 5548{1:<<<-->}^a | 5549{1:~ }|*4 5550| 5551]] , 5552} 5553feed ( 'zbh' ) 5554screen : expect { 5555grid =[[ 5556{1:<------><------><------>}121212| 5557121212121212121212121212121212| 55581212121212121212121212121212{1:^<-}| 5559{1:----->}a | 5560{1:~ }| 5561| 5562]] , 5563} 5564feed ( 'i' ) 5565screen : expect { 5566grid =[[ 5567{1:<------><------><------>}^121212| 5568121212121212121212121212121212| 55691212121212121212121212121212{1:<-}| 5570{1:----->}a | 5571{1:~ }| 5572{8:-- INSERT --} | 5573]] , 5574} 5575feed ( '<C-O>:setlocal nolist<CR>' ) 5576screen : expect { 5577grid =[[ 5578^121212| 5579121212121212121212121212121212| 55801212121212121212121212121212 | 5581a | 5582{1:~ }| 5583{8:-- INSERT --} | 5584]] , 5585} 5586feed ( '<Esc>l' ) 5587screen : expect { 5588grid =[[ 5589121212| 5590121212121212121212121212121212| 55911212121212121212121212121212 | 5592^ a | 5593{1:~ }| 5594| 5595]] , 5596} 5597feed ( '<C-E>' ) 5598screen : expect { 5599grid =[[ 5600{1:<<<}212121212121212121212121212| 56011212121212121212121212121212 | 5602^ a | 5603{1:~ }|*2 5604| 5605]] , 5606} 5607feed ( '<C-E>' ) 5608screen : expect { 5609grid =[[ 5610{1:<<<}2121212121212121212121212 | 5611^ a | 5612{1:~ }|*3 5613| 5614]] , 5615} 5616feed ( '<C-E>' ) 5617screen : expect { 5618grid =[[ 5619{1:<<<} ^ a | 5620{1:~ }|*4 5621| 5622]] , 5623} 5624end ) 5625 5626it ( 'before a space with linebreak' , function () 5627screen : try_resize ( 50 , 6 ) 5628exec ( [[ 5629setlocal linebreak showbreak=+ breakindent breakindentopt=shift:2 5630call setline(1, repeat('a', 50) .. ' ' .. repeat('c', 45)) 5631normal! $ 5632]] ) 5633api . nvim_buf_set_extmark ( 0 , ns , 0 , 50 , { virt_text ={ { ( 'b' ): rep ( 10 ) } } , virt_text_pos ='inline' } ) 5634screen : expect { 5635grid =[[ 5636aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 5637{1:+}bbbbbbbbbb | 5638{1:+}cccccccccccccccccccccccccccccccccccccccccccc^c | 5639{1:~ }|*2 5640| 5641]] , 5642} 5643feed ( '05x$' ) 5644screen : expect { 5645grid =[[ 5646aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb| 5647{1:+}bbbbb | 5648{1:+}cccccccccccccccccccccccccccccccccccccccccccc^c | 5649{1:~ }|*2 5650| 5651]] , 5652} 5653end ) 5654 5655it ( 'is counted when linebreak decides if a word fits' , function () 5656screen : try_resize ( 20 , 4 ) 5657exec ( [[ 5658setlocal linebreak 5659call setline(1, repeat('a', 12) .. ' bbcc dd') 5660]] ) 5661api . nvim_buf_set_extmark ( 0 , ns , 0 , 19 , { virt_text ={ { '[hint]' } } , virt_text_pos ='inline' } ) 5662-- "dd" plus the virtual text does not fit in the 2 remaining cells, so the whole word moves 5663-- down instead of the virtual text being split across the boundary. 5664screen : expect ( [[ 5665^aaaaaaaaaaaa bbcc | 5666d[hint]d | 5667{1:~ }| 5668| 5669]] ) 5670end ) 5671 5672it ( 'before a TAB affects its width in linebreak lookahead' , function () 5673screen : try_resize ( 20 , 4 ) 5674exec ( [[ 5675setlocal linebreak tabstop=8 5676let &l:breakat = ' ' 5677call setline(1, 'aaaa ' .. "\t" .. repeat('b', 11)) 5678]] ) 5679api . nvim_buf_set_extmark ( 0 , ns , 0 , 5 , { 5680virt_text ={ { 'VV' } } , 5681virt_text_pos ='inline' , 5682} ) 5683screen : expect ( [[ 5684^aaaa VV bbbbbbbbbbb | 5685{1:~ }|*2 5686| 5687]] ) 5688end ) 5689 5690it ( 'before double-width char that wraps' , function () 5691exec ( [[ 5692call setline(1, repeat('a', 40) .. '口' .. '12345') 5693normal! $ 5694]] ) 5695api . nvim_buf_set_extmark ( 0 , ns , 0 , 40 , { virt_text ={ { ( 'b' ): rep ( 9 ) } } , virt_text_pos ='inline' } ) 5696screen : expect ( [[ 5697aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}| 5698口1234^5 | 5699| 5700]] ) 5701feed ( 'g0' ) 5702screen : expect ( [[ 5703aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}| 5704^口12345 | 5705| 5706]] ) 5707command ( 'set showbreak=+++' ) 5708screen : expect ( [[ 5709aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}| 5710{1:+++}^口12345 | 5711| 5712]] ) 5713end ) 5714 5715it ( 'cursor position is correct if end_row or end_col is specified' , function () 5716screen : try_resize ( 50 , 8 ) 5717api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { ( 'a' ): rep ( 48 ), ( 'b' ): rep ( 48 ), ( 'c' ): rep ( 48 ), ( 'd' ): rep ( 48 ) } ) 5718api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =2 , virt_text_pos ='inline' , virt_text ={ { 'I1' , 'NonText' } } } ) 5719api . nvim_buf_set_extmark ( 0 , ns , 3 , 0 , { end_col =2 , virt_text_pos ='inline' , virt_text ={ { 'I2' , 'NonText' } } } ) 5720feed ( '$' ) 5721screen : expect ( [[ 5722{1:I1}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^a| 5723bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 5724cccccccccccccccccccccccccccccccccccccccccccccccc | 5725{1:I2}dddddddddddddddddddddddddddddddddddddddddddddddd| 5726{1:~ }|*3 5727| 5728]] ) 5729feed ( 'j' ) 5730screen : expect ( [[ 5731{1:I1}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 5732bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^b | 5733cccccccccccccccccccccccccccccccccccccccccccccccc | 5734{1:I2}dddddddddddddddddddddddddddddddddddddddddddddddd| 5735{1:~ }|*3 5736| 5737]] ) 5738feed ( 'j' ) 5739screen : expect ( [[ 5740{1:I1}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 5741bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 5742ccccccccccccccccccccccccccccccccccccccccccccccc^c | 5743{1:I2}dddddddddddddddddddddddddddddddddddddddddddddddd| 5744{1:~ }|*3 5745| 5746]] ) 5747feed ( 'j' ) 5748screen : expect ( [[ 5749{1:I1}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 5750bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 5751cccccccccccccccccccccccccccccccccccccccccccccccc | 5752{1:I2}ddddddddddddddddddddddddddddddddddddddddddddddd^d| 5753{1:~ }|*3 5754| 5755]] ) 5756end ) 5757 5758it ( 'is redrawn correctly after delete or redo #27370' , function () 5759screen : try_resize ( 50 , 12 ) 5760exec ( [[ 5761call setline(1, ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff']) 5762call setline(3, repeat('c', winwidth(0) - 1)) 5763]] ) 5764api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { virt_text ={ { '!!!' } } , virt_text_pos ='inline' } ) 5765feed ( 'j' ) 5766local before_delete =[[ 5767aaa | 5768!!!^bbb | 5769ccccccccccccccccccccccccccccccccccccccccccccccccc | 5770ddd | 5771eee | 5772fff | 5773{1:~ }|*5 5774| 5775]] 5776screen : expect ( before_delete ) 5777feed ( 'dd' ) 5778local after_delete =[[ 5779aaa | 5780!!!^ccccccccccccccccccccccccccccccccccccccccccccccc| 5781cc | 5782ddd | 5783eee | 5784fff | 5785{1:~ }|*5 5786| 5787]] 5788screen : expect ( after_delete ) 5789command ( 'silent undo' ) 5790screen : expect ( before_delete ) 5791command ( 'silent redo' ) 5792screen : expect ( after_delete ) 5793command ( 'silent undo' ) 5794screen : expect ( before_delete ) 5795command ( 'set report=100' ) 5796feed ( 'yypk2P' ) 5797before_delete =[[ 5798aaa | 5799^bbb | 5800bbb | 5801!!!bbb | 5802bbb | 5803ccccccccccccccccccccccccccccccccccccccccccccccccc | 5804ddd | 5805eee | 5806fff | 5807{1:~ }|*2 5808| 5809]] 5810screen : expect ( before_delete ) 5811feed ( '4dd' ) 5812screen : expect ( after_delete ) 5813command ( 'silent undo' ) 5814screen : expect ( before_delete ) 5815command ( 'silent redo' ) 5816screen : expect ( after_delete ) 5817end ) 5818 5819it ( 'cursor position is correct with invalidated inline virt text' , function () 5820screen : try_resize ( 50 , 8 ) 5821api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { ( 'a' ): rep ( 48 ), ( 'b' ): rep ( 48 ) } ) 5822api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_text_pos ='inline' , virt_text ={ { 'INLINE' , 'NonText' } } , invalidate =true } ) 5823screen : expect ( [[ 5824{1:INLINE}^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 5825aaaa | 5826bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 5827{1:~ }|*4 5828| 5829]] ) 5830feed ( 'dd$' ) 5831screen : expect ( [[ 5832bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^b | 5833{1:~ }|*6 5834| 5835]] ) 5836end ) 5837 5838it ( 'line size is correct with inline virt text at EOL and showbreak' , function () 5839screen : try_resize ( 50 , 8 ) 5840insert (( '0123456789' ): rep ( 5 ) .. '\nfoo\nbar' ) 5841api . nvim_buf_set_extmark ( 0 , ns , 0 , 50 , { virt_text ={ { ( 'x' ): rep ( 145 ), 'ErrorMsg' } } , virt_text_pos ='inline' } ) 5842 5843command ( [[set cursorline scrolloff=0 showbreak=>\ smoothscroll]] ) 5844screen : expect ( [[ 584501234567890123456789012345678901234567890123456789| 5846{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3 5847{1:> }{4:x} | 5848foo | 5849{22:ba^r }| 5850| 5851]] ) 5852eq ( 5 , api . nvim_win_text_height ( 0 , { start_row =0 , end_row =0 } ). all ) 5853feed ( '<C-E>' ) 5854screen : expect ( [[ 5855{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3 5856{1:> }{4:x} | 5857foo | 5858{22:ba^r }| 5859{1:~ }| 5860| 5861]] ) 5862feed ( '<C-E>' ) 5863screen : expect ( [[ 5864{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2 5865{1:> }{4:x} | 5866foo | 5867{22:ba^r }| 5868{1:~ }|*2 5869| 5870]] ) 5871feed ( '<C-E>' ) 5872screen : expect ( [[ 5873{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}| 5874{1:> }{4:x} | 5875foo | 5876{22:ba^r }| 5877{1:~ }|*3 5878| 5879]] ) 5880feed ( '<C-E>' ) 5881screen : expect ( [[ 5882{1:> }{4:x} | 5883foo | 5884{22:ba^r }| 5885{1:~ }|*4 5886| 5887]] ) 5888feed ( '<C-E>' ) 5889screen : expect ( [[ 5890foo | 5891{22:ba^r }| 5892{1:~ }|*5 5893| 5894]] ) 5895 5896feed ( 'gg$xG$' ) 5897screen : expect ( [[ 58980123456789012345678901234567890123456789012345678{4:x}| 5899{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3 5900foo | 5901{22:ba^r }| 5902{1:~ }| 5903| 5904]] ) 5905eq ( 4 , api . nvim_win_text_height ( 0 , { start_row =0 , end_row =0 } ). all ) 5906feed ( '<C-E>' ) 5907screen : expect ( [[ 5908{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3 5909foo | 5910{22:ba^r }| 5911{1:~ }|*2 5912| 5913]] ) 5914feed ( '<C-E>' ) 5915screen : expect ( [[ 5916{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2 5917foo | 5918{22:ba^r }| 5919{1:~ }|*3 5920| 5921]] ) 5922feed ( '<C-E>' ) 5923screen : expect ( [[ 5924{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}| 5925foo | 5926{22:ba^r }| 5927{1:~ }|*4 5928| 5929]] ) 5930feed ( '<C-E>' ) 5931screen : expect ( [[ 5932foo | 5933{22:ba^r }| 5934{1:~ }|*5 5935| 5936]] ) 5937 5938feed ( 'zb' ) 5939command ( 'set list listchars=eol:$' ) 5940screen : expect ( [[ 59410123456789012345678901234567890123456789012345678{4:x}| 5942{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3 5943{1:> $} | 5944foo{1:$} | 5945{22:ba^r}{23:$}{22: }| 5946| 5947]] ) 5948eq ( 5 , api . nvim_win_text_height ( 0 , { start_row =0 , end_row =0 } ). all ) 5949feed ( '<C-E>' ) 5950screen : expect ( [[ 5951{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3 5952{1:> $} | 5953foo{1:$} | 5954{22:ba^r}{23:$}{22: }| 5955{1:~ }| 5956| 5957]] ) 5958feed ( '<C-E>' ) 5959screen : expect ( [[ 5960{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2 5961{1:> $} | 5962foo{1:$} | 5963{22:ba^r}{23:$}{22: }| 5964{1:~ }|*2 5965| 5966]] ) 5967feed ( '<C-E>' ) 5968screen : expect ( [[ 5969{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}| 5970{1:> $} | 5971foo{1:$} | 5972{22:ba^r}{23:$}{22: }| 5973{1:~ }|*3 5974| 5975]] ) 5976feed ( '<C-E>' ) 5977screen : expect ( [[ 5978{1:> $} | 5979foo{1:$} | 5980{22:ba^r}{23:$}{22: }| 5981{1:~ }|*4 5982| 5983]] ) 5984feed ( '<C-E>' ) 5985screen : expect ( [[ 5986foo{1:$} | 5987{22:ba^r}{23:$}{22: }| 5988{1:~ }|*5 5989| 5990]] ) 5991 5992feed ( 'gg$xG$' ) 5993screen : expect ( [[ 5994012345678901234567890123456789012345678901234567{4:xx}| 5995{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2 5996{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}| 5997foo{1:$} | 5998{22:ba^r}{23:$}{22: }| 5999{1:~ }| 6000| 6001]] ) 6002eq ( 4 , api . nvim_win_text_height ( 0 , { start_row =0 , end_row =0 } ). all ) 6003feed ( '<C-E>' ) 6004screen : expect ( [[ 6005{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2 6006{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}| 6007foo{1:$} | 6008{22:ba^r}{23:$}{22: }| 6009{1:~ }|*2 6010| 6011]] ) 6012feed ( '<C-E>' ) 6013screen : expect ( [[ 6014{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}| 6015{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}| 6016foo{1:$} | 6017{22:ba^r}{23:$}{22: }| 6018{1:~ }|*3 6019| 6020]] ) 6021feed ( '<C-E>' ) 6022screen : expect ( [[ 6023{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}| 6024foo{1:$} | 6025{22:ba^r}{23:$}{22: }| 6026{1:~ }|*4 6027| 6028]] ) 6029feed ( '<C-E>' ) 6030screen : expect ( [[ 6031foo{1:$} | 6032{22:ba^r}{23:$}{22: }| 6033{1:~ }|*5 6034| 6035]] ) 6036end ) 6037 6038it ( "virtcol('$') is correct with inline virt text at EOL" , function () 6039insert (( '1234567890\n' ): rep ( 6 )) 6040for _ , v in ipairs ( { { 2 , 'a' } , { 3 , 'ab' } , { 4 , 'abc' } , { 5 , 'abcd' } , { 6 , 'αβγ口' } } ) do 6041local ln , tx =unpack ( v ) 6042local co =fn . col ( { ln , '$' } ) 6043eq ( 11 , fn . virtcol ( { ln , '$' } )) 6044api . nvim_buf_set_extmark ( 0 , ns , ln - 1 , co - 1 , { virt_text ={ { tx } } , virt_text_pos ='inline' } ) 6045eq ( 11 + fn . strwidth ( tx ), fn . virtcol ( { ln , '$' } )) 6046end 6047end ) 6048end ) 6049 6050describe ( 'decorations: virtual lines' , function () 6051local screen ---@type test.functional.ui.screen 6052local ns ---@type integer 6053 6054before_each ( function () 6055clear () 6056screen =Screen . new ( 50 , 12 ) 6057screen : add_extra_attr_ids { 6058[ 100 ] ={ foreground =Screen . colors . Blue , background =Screen . colors . Yellow } , 6059} 6060 6061ns =api . nvim_create_namespace 'test' 6062end ) 6063 6064local example_text2 =[[ 6065if (h->n_buckets < new_n_buckets) { // expand 6066khkey_t *new_keys = (khkey_t *)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); 6067h->keys = new_keys; 6068if (kh_is_map && val_size) { 6069char *new_vals = krealloc( h->vals_buf, new_n_buckets * val_size); 6070h->vals_buf = new_vals; 6071} 6072}]] 6073 6074it ( 'works with one line' , function () 6075insert ( example_text2 ) 6076feed '2gg' 6077screen : expect { 6078grid =[[ 6079if (h->n_buckets < new_n_buckets) { // expand | 6080^khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6081h->keys, new_n_buckets * sizeof(khkey_t)); | 6082h->keys = new_keys; | 6083if (kh_is_map && val_size) { | 6084char *new_vals = krealloc( h->vals_buf, new_n_| 6085buckets * val_size); | 6086h->vals_buf = new_vals; | 6087} | 6088} | 6089{1:~ }| 6090| 6091]] , 6092} 6093 6094api . nvim_buf_set_extmark ( 0 , ns , 1 , 33 , { 6095virt_lines ={ { { '>> ' , 'NonText' } , { 'krealloc' , 'Identifier' } , { ': change the size of an allocation' } } } , 6096virt_lines_above =true , 6097} ) 6098 6099screen : expect { 6100grid =[[ 6101if (h->n_buckets < new_n_buckets) { // expand | 6102{1:>> }{25:krealloc}: change the size of an allocation | 6103^khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6104h->keys, new_n_buckets * sizeof(khkey_t)); | 6105h->keys = new_keys; | 6106if (kh_is_map && val_size) { | 6107char *new_vals = krealloc( h->vals_buf, new_n_| 6108buckets * val_size); | 6109h->vals_buf = new_vals; | 6110} | 6111} | 6112| 6113]] , 6114} 6115 6116feed '/krealloc<cr>' 6117screen : expect { 6118grid =[[ 6119if (h->n_buckets < new_n_buckets) { // expand | 6120{1:>> }{25:krealloc}: change the size of an allocation | 6121khkey_t *new_keys = (khkey_t *){10:^krealloc}((void *)| 6122h->keys, new_n_buckets * sizeof(khkey_t)); | 6123h->keys = new_keys; | 6124if (kh_is_map && val_size) { | 6125char *new_vals = {10:krealloc}( h->vals_buf, new_n_| 6126buckets * val_size); | 6127h->vals_buf = new_vals; | 6128} | 6129} | 6130/krealloc | 6131]] , 6132} 6133 6134-- virtual line remains anchored to the extmark 6135feed 'i<cr>' 6136screen : expect { 6137grid =[[ 6138if (h->n_buckets < new_n_buckets) { // expand | 6139khkey_t *new_keys = (khkey_t *) | 6140{1:>> }{25:krealloc}: change the size of an allocation | 6141{10:^krealloc}((void *)h->keys, new_n_buckets * sizeof(k| 6142hkey_t)); | 6143h->keys = new_keys; | 6144if (kh_is_map && val_size) { | 6145char *new_vals = {10:krealloc}( h->vals_buf, new_n_| 6146buckets * val_size); | 6147h->vals_buf = new_vals; | 6148} | 6149{5:-- INSERT --} | 6150]] , 6151} 6152 6153feed '<esc>3+' 6154screen : expect { 6155grid =[[ 6156if (h->n_buckets < new_n_buckets) { // expand | 6157khkey_t *new_keys = (khkey_t *) | 6158{1:>> }{25:krealloc}: change the size of an allocation | 6159{10:krealloc}((void *)h->keys, new_n_buckets * sizeof(k| 6160hkey_t)); | 6161h->keys = new_keys; | 6162if (kh_is_map && val_size) { | 6163^char *new_vals = {10:krealloc}( h->vals_buf, new_n_| 6164buckets * val_size); | 6165h->vals_buf = new_vals; | 6166} | 6167| 6168]] , 6169} 6170 6171api . nvim_buf_set_extmark ( 0 , ns , 5 , 0 , { 6172virt_lines ={ { { '^^ REVIEW:' , 'Todo' } , { ' new_vals variable seems unnecessary?' , 'Comment' } } } , 6173} ) 6174screen : expect { 6175grid =[[ 6176if (h->n_buckets < new_n_buckets) { // expand | 6177khkey_t *new_keys = (khkey_t *) | 6178{1:>> }{25:krealloc}: change the size of an allocation | 6179{10:krealloc}((void *)h->keys, new_n_buckets * sizeof(k| 6180hkey_t)); | 6181h->keys = new_keys; | 6182if (kh_is_map && val_size) { | 6183^char *new_vals = {10:krealloc}( h->vals_buf, new_n_| 6184buckets * val_size); | 6185{100:^^ REVIEW:}{18: new_vals variable seems unnecessary?} | 6186h->vals_buf = new_vals; | 6187| 6188]] , 6189} 6190 6191api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 6192screen : expect { 6193grid =[[ 6194if (h->n_buckets < new_n_buckets) { // expand | 6195khkey_t *new_keys = (khkey_t *) | 6196{10:krealloc}((void *)h->keys, new_n_buckets * sizeof(k| 6197hkey_t)); | 6198h->keys = new_keys; | 6199if (kh_is_map && val_size) { | 6200^char *new_vals = {10:krealloc}( h->vals_buf, new_n_| 6201buckets * val_size); | 6202h->vals_buf = new_vals; | 6203} | 6204} | 6205| 6206]] , 6207} 6208end ) 6209 6210it ( 'works with text at the beginning of the buffer' , function () 6211insert ( example_text2 ) 6212feed 'gg' 6213 6214screen : expect { 6215grid =[[ 6216^if (h->n_buckets < new_n_buckets) { // expand | 6217khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6218h->keys, new_n_buckets * sizeof(khkey_t)); | 6219h->keys = new_keys; | 6220if (kh_is_map && val_size) { | 6221char *new_vals = krealloc( h->vals_buf, new_n_| 6222buckets * val_size); | 6223h->vals_buf = new_vals; | 6224} | 6225} | 6226{1:~ }| 6227| 6228]] , 6229} 6230 6231api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 6232virt_lines ={ 6233{ { 'refactor(khash): ' , 'Special' } , { 'take size of values as parameter' } } , 6234{ { 'Author: Dev Devsson, ' } , { 'Tue Aug 31 10:13:37 2021' , 'Comment' } } , 6235} , 6236virt_lines_above =true , 6237right_gravity =false , 6238} ) 6239 6240-- placing virt_text on topline does not automatically cause a scroll 6241screen : expect { 6242grid =[[ 6243^if (h->n_buckets < new_n_buckets) { // expand | 6244khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6245h->keys, new_n_buckets * sizeof(khkey_t)); | 6246h->keys = new_keys; | 6247if (kh_is_map && val_size) { | 6248char *new_vals = krealloc( h->vals_buf, new_n_| 6249buckets * val_size); | 6250h->vals_buf = new_vals; | 6251} | 6252} | 6253{1:~ }| 6254| 6255]] , 6256unchanged =true , 6257} 6258 6259feed '<c-b>' 6260screen : expect { 6261grid =[[ 6262{16:refactor(khash): }take size of values as parameter | 6263Author: Dev Devsson, {18:Tue Aug 31 10:13:37 2021} | 6264if (h->n_buckets < new_n_buckets) { // expand | 6265khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6266h->keys, new_n_buckets * sizeof(khkey_t)); | 6267h->keys = new_keys; | 6268if (kh_is_map && val_size) { | 6269char *new_vals = krealloc( h->vals_buf, new_n_| 6270buckets * val_size); | 6271h->vals_buf = new_vals; | 6272^} | 6273| 6274]] , 6275} 6276end ) 6277 6278it ( 'works with text at the end of the buffer' , function () 6279insert ( example_text2 ) 6280feed 'G' 6281 6282screen : expect { 6283grid =[[ 6284if (h->n_buckets < new_n_buckets) { // expand | 6285khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6286h->keys, new_n_buckets * sizeof(khkey_t)); | 6287h->keys = new_keys; | 6288if (kh_is_map && val_size) { | 6289char *new_vals = krealloc( h->vals_buf, new_n_| 6290buckets * val_size); | 6291h->vals_buf = new_vals; | 6292} | 6293^} | 6294{1:~ }| 6295| 6296]] , 6297} 6298 6299local id =api . nvim_buf_set_extmark ( 0 , ns , 7 , 0 , { 6300virt_lines ={ { { 'Grugg' } } } , 6301right_gravity =false , 6302} ) 6303 6304screen : expect { 6305grid =[[ 6306if (h->n_buckets < new_n_buckets) { // expand | 6307khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6308h->keys, new_n_buckets * sizeof(khkey_t)); | 6309h->keys = new_keys; | 6310if (kh_is_map && val_size) { | 6311char *new_vals = krealloc( h->vals_buf, new_n_| 6312buckets * val_size); | 6313h->vals_buf = new_vals; | 6314} | 6315^} | 6316Grugg | 6317| 6318]] , 6319} 6320 6321screen : try_resize ( 50 , 11 ) 6322feed ( 'gg' ) 6323screen : expect { 6324grid =[[ 6325^if (h->n_buckets < new_n_buckets) { // expand | 6326khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6327h->keys, new_n_buckets * sizeof(khkey_t)); | 6328h->keys = new_keys; | 6329if (kh_is_map && val_size) { | 6330char *new_vals = krealloc( h->vals_buf, new_n_| 6331buckets * val_size); | 6332h->vals_buf = new_vals; | 6333} | 6334} | 6335| 6336]] , 6337} 6338 6339feed ( 'G<C-E>' ) 6340screen : expect { 6341grid =[[ 6342khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6343h->keys, new_n_buckets * sizeof(khkey_t)); | 6344h->keys = new_keys; | 6345if (kh_is_map && val_size) { | 6346char *new_vals = krealloc( h->vals_buf, new_n_| 6347buckets * val_size); | 6348h->vals_buf = new_vals; | 6349} | 6350^} | 6351Grugg | 6352| 6353]] , 6354} 6355 6356feed ( 'gg' ) 6357screen : expect { 6358grid =[[ 6359^if (h->n_buckets < new_n_buckets) { // expand | 6360khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6361h->keys, new_n_buckets * sizeof(khkey_t)); | 6362h->keys = new_keys; | 6363if (kh_is_map && val_size) { | 6364char *new_vals = krealloc( h->vals_buf, new_n_| 6365buckets * val_size); | 6366h->vals_buf = new_vals; | 6367} | 6368} | 6369| 6370]] , 6371} 6372 6373screen : try_resize ( 50 , 12 ) 6374feed ( 'G' ) 6375screen : expect { 6376grid =[[ 6377if (h->n_buckets < new_n_buckets) { // expand | 6378khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6379h->keys, new_n_buckets * sizeof(khkey_t)); | 6380h->keys = new_keys; | 6381if (kh_is_map && val_size) { | 6382char *new_vals = krealloc( h->vals_buf, new_n_| 6383buckets * val_size); | 6384h->vals_buf = new_vals; | 6385} | 6386^} | 6387Grugg | 6388| 6389]] , 6390} 6391 6392api . nvim_buf_del_extmark ( 0 , ns , id ) 6393screen : expect { 6394grid =[[ 6395if (h->n_buckets < new_n_buckets) { // expand | 6396khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6397h->keys, new_n_buckets * sizeof(khkey_t)); | 6398h->keys = new_keys; | 6399if (kh_is_map && val_size) { | 6400char *new_vals = krealloc( h->vals_buf, new_n_| 6401buckets * val_size); | 6402h->vals_buf = new_vals; | 6403} | 6404^} | 6405{1:~ }| 6406| 6407]] , 6408} 6409end ) 6410 6411it ( 'works beyond end of the buffer with virt_lines_above' , function () 6412insert ( example_text2 ) 6413feed 'G' 6414 6415screen : expect { 6416grid =[[ 6417if (h->n_buckets < new_n_buckets) { // expand | 6418khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6419h->keys, new_n_buckets * sizeof(khkey_t)); | 6420h->keys = new_keys; | 6421if (kh_is_map && val_size) { | 6422char *new_vals = krealloc( h->vals_buf, new_n_| 6423buckets * val_size); | 6424h->vals_buf = new_vals; | 6425} | 6426^} | 6427{1:~ }| 6428| 6429]] , 6430} 6431 6432local id =api . nvim_buf_set_extmark ( 0 , ns , 8 , 0 , { 6433virt_lines ={ { { 'Grugg' } } } , 6434virt_lines_above =true , 6435} ) 6436 6437screen : expect { 6438grid =[[ 6439if (h->n_buckets < new_n_buckets) { // expand | 6440khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6441h->keys, new_n_buckets * sizeof(khkey_t)); | 6442h->keys = new_keys; | 6443if (kh_is_map && val_size) { | 6444char *new_vals = krealloc( h->vals_buf, new_n_| 6445buckets * val_size); | 6446h->vals_buf = new_vals; | 6447} | 6448^} | 6449Grugg | 6450| 6451]] , 6452} 6453 6454feed ( 'dd' ) 6455screen : expect { 6456grid =[[ 6457if (h->n_buckets < new_n_buckets) { // expand | 6458khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6459h->keys, new_n_buckets * sizeof(khkey_t)); | 6460h->keys = new_keys; | 6461if (kh_is_map && val_size) { | 6462char *new_vals = krealloc( h->vals_buf, new_n_| 6463buckets * val_size); | 6464h->vals_buf = new_vals; | 6465^} | 6466Grugg | 6467{1:~ }| 6468| 6469]] , 6470} 6471 6472feed ( 'dk' ) 6473screen : expect { 6474grid =[[ 6475if (h->n_buckets < new_n_buckets) { // expand | 6476khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6477h->keys, new_n_buckets * sizeof(khkey_t)); | 6478h->keys = new_keys; | 6479if (kh_is_map && val_size) { | 6480^char *new_vals = krealloc( h->vals_buf, new_n_| 6481buckets * val_size); | 6482Grugg | 6483{1:~ }|*3 6484| 6485]] , 6486} 6487 6488feed ( 'dgg' ) 6489screen : expect { 6490grid =[[ 6491^ | 6492Grugg | 6493{1:~ }|*9 6494--No lines in buffer-- | 6495]] , 6496} 6497 6498api . nvim_buf_del_extmark ( 0 , ns , id ) 6499screen : expect { 6500grid =[[ 6501^ | 6502{1:~ }|*10 6503--No lines in buffer-- | 6504]] , 6505} 6506end ) 6507 6508it ( 'does not cause syntax ml_get error at the end of a buffer #17816' , function () 6509command ( [[syntax region foo keepend start='^foo' end='^$']] ) 6510command ( 'syntax sync minlines=100' ) 6511insert ( 'foo' ) 6512api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines ={ { { 'bar' , 'Comment' } } } } ) 6513screen : expect ( [[ 6514fo^o | 6515{18:bar} | 6516{1:~ }|*9 6517| 6518]] ) 6519end ) 6520 6521it ( 'works with a block scrolling up' , function () 6522screen : try_resize ( 30 , 7 ) 6523insert ( 'aa\nbb\ncc\ndd\nee\nff\ngg\nhh' ) 6524feed 'gg' 6525 6526api . nvim_buf_set_extmark ( 0 , ns , 6 , 0 , { 6527virt_lines ={ 6528{ { 'they see me' } } , 6529{ { 'scrolling' , 'Special' } } , 6530{ { 'they' } } , 6531{ { "hatin'" , 'Special' } } , 6532} , 6533} ) 6534 6535screen : expect { 6536grid =[[ 6537^aa | 6538bb | 6539cc | 6540dd | 6541ee | 6542ff | 6543| 6544]] , 6545} 6546 6547feed '<c-e>' 6548screen : expect { 6549grid =[[ 6550^bb | 6551cc | 6552dd | 6553ee | 6554ff | 6555gg | 6556| 6557]] , 6558} 6559 6560feed '<c-e>' 6561screen : expect { 6562grid =[[ 6563^cc | 6564dd | 6565ee | 6566ff | 6567gg | 6568they see me | 6569| 6570]] , 6571} 6572 6573feed '<c-e>' 6574screen : expect { 6575grid =[[ 6576^dd | 6577ee | 6578ff | 6579gg | 6580they see me | 6581{16:scrolling} | 6582| 6583]] , 6584} 6585 6586feed '<c-e>' 6587screen : expect { 6588grid =[[ 6589^ee | 6590ff | 6591gg | 6592they see me | 6593{16:scrolling} | 6594they | 6595| 6596]] , 6597} 6598 6599feed '<c-e>' 6600screen : expect { 6601grid =[[ 6602^ff | 6603gg | 6604they see me | 6605{16:scrolling} | 6606they | 6607{16:hatin'} | 6608| 6609]] , 6610} 6611 6612feed '<c-e>' 6613screen : expect { 6614grid =[[ 6615^gg | 6616they see me | 6617{16:scrolling} | 6618they | 6619{16:hatin'} | 6620hh | 6621| 6622]] , 6623} 6624 6625feed '<c-e>' 6626screen : expect { 6627grid =[[ 6628they see me | 6629{16:scrolling} | 6630they | 6631{16:hatin'} | 6632^hh | 6633{1:~ }| 6634| 6635]] , 6636} 6637 6638feed '<c-e>' 6639screen : expect { 6640grid =[[ 6641{16:scrolling} | 6642they | 6643{16:hatin'} | 6644^hh | 6645{1:~ }|*2 6646| 6647]] , 6648} 6649 6650feed '<c-e>' 6651screen : expect { 6652grid =[[ 6653they | 6654{16:hatin'} | 6655^hh | 6656{1:~ }|*3 6657| 6658]] , 6659} 6660 6661feed '<c-e>' 6662screen : expect { 6663grid =[[ 6664{16:hatin'} | 6665^hh | 6666{1:~ }|*4 6667| 6668]] , 6669} 6670 6671feed '<c-e>' 6672screen : expect { 6673grid =[[ 6674^hh | 6675{1:~ }|*5 6676| 6677]] , 6678} 6679end ) 6680 6681it ( 'works with sign and numbercolumns' , function () 6682insert ( example_text2 ) 6683feed 'gg' 6684command 'set number signcolumn=yes' 6685screen : expect ( [[ 6686{7: }{8: 1 }^if (h->n_buckets < new_n_buckets) { // expan| 6687{7: }{8: }d | 6688{7: }{8: 2 } khkey_t *new_keys = (khkey_t *)krealloc((v| 6689{7: }{8: }oid *)h->keys, new_n_buckets * sizeof(khkey_| 6690{7: }{8: }t)); | 6691{7: }{8: 3 } h->keys = new_keys; | 6692{7: }{8: 4 } if (kh_is_map && val_size) { | 6693{7: }{8: 5 } char *new_vals = krealloc( h->vals_buf, | 6694{7: }{8: }new_n_buckets * val_size); | 6695{7: }{8: 6 } h->vals_buf = new_vals; | 6696{7: }{8: 7 } } | 6697| 6698]] ) 6699 6700local markid =api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { 6701virt_lines ={ 6702{ { 'Some special' , 'Special' } } , 6703{ { 'remark about codes' , 'Comment' } } , 6704} , 6705} ) 6706 6707screen : expect ( [[ 6708{7: }{8: 1 }^if (h->n_buckets < new_n_buckets) { // expan| 6709{7: }{8: }d | 6710{7: }{8: 2 } khkey_t *new_keys = (khkey_t *)krealloc((v| 6711{7: }{8: }oid *)h->keys, new_n_buckets * sizeof(khkey_| 6712{7: }{8: }t)); | 6713{7: }{8: 3 } h->keys = new_keys; | 6714{7: }{8: }{16:Some special} | 6715{7: }{8: }{18:remark about codes} | 6716{7: }{8: 4 } if (kh_is_map && val_size) { | 6717{7: }{8: 5 } char *new_vals = krealloc( h->vals_buf, | 6718{7: }{8: }new_n_buckets * val_size); | 6719| 6720]] ) 6721 6722api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { 6723virt_lines ={ 6724{ { 'Some special' , 'Special' } } , 6725{ { 'remark about codes' , 'Comment' } } , 6726} , 6727virt_lines_leftcol =true , 6728id =markid , 6729} ) 6730screen : expect ( [[ 6731{7: }{8: 1 }^if (h->n_buckets < new_n_buckets) { // expan| 6732{7: }{8: }d | 6733{7: }{8: 2 } khkey_t *new_keys = (khkey_t *)krealloc((v| 6734{7: }{8: }oid *)h->keys, new_n_buckets * sizeof(khkey_| 6735{7: }{8: }t)); | 6736{7: }{8: 3 } h->keys = new_keys; | 6737{16:Some special} | 6738{18:remark about codes} | 6739{7: }{8: 4 } if (kh_is_map && val_size) { | 6740{7: }{8: 5 } char *new_vals = krealloc( h->vals_buf, | 6741{7: }{8: }new_n_buckets * val_size); | 6742| 6743]] ) 6744 6745command ( 'set nonumber relativenumber' ) 6746screen : expect ( [[ 6747{7: }{8: 0 }^if (h->n_buckets < new_n_buckets) { // expan| 6748{7: }{8: }d | 6749{7: }{8: 1 } khkey_t *new_keys = (khkey_t *)krealloc((v| 6750{7: }{8: }oid *)h->keys, new_n_buckets * sizeof(khkey_| 6751{7: }{8: }t)); | 6752{7: }{8: 2 } h->keys = new_keys; | 6753{16:Some special} | 6754{18:remark about codes} | 6755{7: }{8: 3 } if (kh_is_map && val_size) { | 6756{7: }{8: 4 } char *new_vals = krealloc( h->vals_buf, | 6757{7: }{8: }new_n_buckets * val_size); | 6758| 6759]] ) 6760 6761-- 'relativenumber' is redrawn with virt_lines_leftcol #34649 6762feed ( 'j' ) 6763screen : expect ( [[ 6764{7: }{8: 1 }if (h->n_buckets < new_n_buckets) { // expan| 6765{7: }{8: }d | 6766{7: }{8: 0 }^ khkey_t *new_keys = (khkey_t *)krealloc((v| 6767{7: }{8: }oid *)h->keys, new_n_buckets * sizeof(khkey_| 6768{7: }{8: }t)); | 6769{7: }{8: 1 } h->keys = new_keys; | 6770{16:Some special} | 6771{18:remark about codes} | 6772{7: }{8: 2 } if (kh_is_map && val_size) { | 6773{7: }{8: 3 } char *new_vals = krealloc( h->vals_buf, | 6774{7: }{8: }new_n_buckets * val_size); | 6775| 6776]] ) 6777end ) 6778 6779it ( 'works with hard TABs' , function () 6780insert ( example_text2 ) 6781feed 'gg' 6782api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { 6783virt_lines ={ { { '>>' , 'NonText' } , { '\tvery\ttabby' , 'Identifier' } , { 'text\twith\ttabs' } } } , 6784} ) 6785screen : expect { 6786grid =[[ 6787^if (h->n_buckets < new_n_buckets) { // expand | 6788khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6789h->keys, new_n_buckets * sizeof(khkey_t)); | 6790{1:>>}{25: very tabby}text with tabs | 6791h->keys = new_keys; | 6792if (kh_is_map && val_size) { | 6793char *new_vals = krealloc( h->vals_buf, new_n_| 6794buckets * val_size); | 6795h->vals_buf = new_vals; | 6796} | 6797} | 6798| 6799]] , 6800} 6801 6802command 'set tabstop=4' 6803screen : expect { 6804grid =[[ 6805^if (h->n_buckets < new_n_buckets) { // expand | 6806khkey_t *new_keys = (khkey_t *)krealloc((void *)| 6807h->keys, new_n_buckets * sizeof(khkey_t)); | 6808{1:>>}{25: very tabby}text with tabs | 6809h->keys = new_keys; | 6810if (kh_is_map && val_size) { | 6811char *new_vals = krealloc( h->vals_buf, new_n_| 6812buckets * val_size); | 6813h->vals_buf = new_vals; | 6814} | 6815} | 6816| 6817]] , 6818} 6819 6820command 'set number' 6821screen : expect { 6822grid =[[ 6823{8: 1 }^if (h->n_buckets < new_n_buckets) { // expand | 6824{8: 2 } khkey_t *new_keys = (khkey_t *)krealloc((voi| 6825{8: }d *)h->keys, new_n_buckets * sizeof(khkey_t));| 6826{8: }{1:>>}{25: very tabby}text with tabs | 6827{8: 3 } h->keys = new_keys; | 6828{8: 4 } if (kh_is_map && val_size) { | 6829{8: 5 } char *new_vals = krealloc( h->vals_buf, ne| 6830{8: }w_n_buckets * val_size); | 6831{8: 6 } h->vals_buf = new_vals; | 6832{8: 7 } } | 6833{8: 8 }} | 6834| 6835]] , 6836} 6837 6838command 'set tabstop&' 6839screen : expect { 6840grid =[[ 6841{8: 1 }^if (h->n_buckets < new_n_buckets) { // expand | 6842{8: 2 } khkey_t *new_keys = (khkey_t *)krealloc((voi| 6843{8: }d *)h->keys, new_n_buckets * sizeof(khkey_t));| 6844{8: }{1:>>}{25: very tabby}text with tabs | 6845{8: 3 } h->keys = new_keys; | 6846{8: 4 } if (kh_is_map && val_size) { | 6847{8: 5 } char *new_vals = krealloc( h->vals_buf, ne| 6848{8: }w_n_buckets * val_size); | 6849{8: 6 } h->vals_buf = new_vals; | 6850{8: 7 } } | 6851{8: 8 }} | 6852| 6853]] , 6854} 6855end ) 6856 6857it ( 'scrolls horizontally with virt_lines_overflow=scroll #31000' , function () 6858command ( 'set nowrap signcolumn=yes' ) 6859insert ( 'abcdefghijklmnopqrstuvwxyz' ) 6860api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 6861virt_lines ={ 6862{ { '12α口β̳γ̲=' , 'Special' } , { '❤️345678' , 'Special' } } , 6863{ { '123\t45\t678' , 'NonText' } } , 6864} , 6865virt_lines_overflow ='scroll' , 6866} ) 6867screen : expect ( [[ 6868{7: }abcdefghijklmnopqrstuvwxy^z | 6869{7: }{16:12α口β̳γ̲=❤️345678} | 6870{7: }{1:123 45 678} | 6871{1:~ }|*8 6872| 6873]] ) 6874feed ( 'zl' ) 6875screen : expect ( [[ 6876{7: }bcdefghijklmnopqrstuvwxy^z | 6877{7: }{16:2α口β̳γ̲=❤️345678} | 6878{7: }{1:23 45 678} | 6879{1:~ }|*8 6880| 6881]] ) 6882feed ( 'zl' ) 6883screen : expect ( [[ 6884{7: }cdefghijklmnopqrstuvwxy^z | 6885{7: }{16:α口β̳γ̲=❤️345678} | 6886{7: }{1:3 45 678} | 6887{1:~ }|*8 6888| 6889]] ) 6890feed ( 'zl' ) 6891screen : expect ( [[ 6892{7: }defghijklmnopqrstuvwxy^z | 6893{7: }{16:口β̳γ̲=❤️345678} | 6894{7: }{1: 45 678} | 6895{1:~ }|*8 6896| 6897]] ) 6898feed ( 'zl' ) 6899screen : expect ( [[ 6900{7: }efghijklmnopqrstuvwxy^z | 6901{7: }{16: β̳γ̲=❤️345678} | 6902{7: }{1: 45 678} | 6903{1:~ }|*8 6904| 6905]] ) 6906feed ( 'zl' ) 6907screen : expect ( [[ 6908{7: }fghijklmnopqrstuvwxy^z | 6909{7: }{16:β̳γ̲=❤️345678} | 6910{7: }{1: 45 678} | 6911{1:~ }|*8 6912| 6913]] ) 6914feed ( 'zl' ) 6915screen : expect ( [[ 6916{7: }ghijklmnopqrstuvwxy^z | 6917{7: }{16:γ̲=❤️345678} | 6918{7: }{1: 45 678} | 6919{1:~ }|*8 6920| 6921]] ) 6922feed ( 'zl' ) 6923screen : expect ( [[ 6924{7: }hijklmnopqrstuvwxy^z | 6925{7: }{16:=❤️345678} | 6926{7: }{1: 45 678} | 6927{1:~ }|*8 6928| 6929]] ) 6930feed ( 'zl' ) 6931screen : expect ( [[ 6932{7: }ijklmnopqrstuvwxy^z | 6933{7: }{16:❤️345678} | 6934{7: }{1:45 678} | 6935{1:~ }|*8 6936| 6937]] ) 6938feed ( 'zl' ) 6939screen : expect ( [[ 6940{7: }jklmnopqrstuvwxy^z | 6941{7: }{16: 345678} | 6942{7: }{1:5 678} | 6943{1:~ }|*8 6944| 6945]] ) 6946feed ( 'zl' ) 6947screen : expect ( [[ 6948{7: }klmnopqrstuvwxy^z | 6949{7: }{16:345678} | 6950{7: }{1: 678} | 6951{1:~ }|*8 6952| 6953]] ) 6954feed ( 'zl' ) 6955screen : expect ( [[ 6956{7: }lmnopqrstuvwxy^z | 6957{7: }{16:45678} | 6958{7: }{1: 678} | 6959{1:~ }|*8 6960| 6961]] ) 6962feed ( 'zl' ) 6963screen : expect ( [[ 6964{7: }mnopqrstuvwxy^z | 6965{7: }{16:5678} | 6966{7: }{1: 678} | 6967{1:~ }|*8 6968| 6969]] ) 6970api . nvim_buf_set_extmark ( 0 , ns , 0 , 1 , { 6971virt_lines ={ { { '123\t45\t67' , 'NonText' } } } , 6972virt_lines_leftcol =true , 6973virt_lines_overflow ='trunc' , 6974} ) 6975api . nvim_buf_set_extmark ( 0 , ns , 0 , 2 , { 6976virt_lines ={ { { '123\t45\t6' , 'NonText' } } } , 6977virt_lines_leftcol =false , 6978virt_lines_overflow ='trunc' , 6979} ) 6980screen : expect ( [[ 6981{7: }mnopqrstuvwxy^z | 6982{7: }{16:5678} | 6983{7: }{1: 678} | 6984{1:123 45 67} | 6985{7: }{1:123 45 6} | 6986{1:~ }|*6 6987| 6988]] ) 6989end ) 6990 6991it ( 'virt_lines_overflow=wrap' , function () 6992command ( 'set wrap signcolumn=yes' ) 6993insert ( 'line1\nline2\nline3\n' ) 6994api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 6995virt_lines ={ 6996{ 6997{ 6998string . rep ( 6999'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean non felis dapibus, semper sapien vitae, fringilla orci.' , 70005 7001), 7002'Special' , 7003} , 7004} , 7005} , 7006virt_lines_overflow ='wrap' , 7007} ) 7008screen : expect ( [[ 7009{7: }{16:rem ipsum dolor sit amet, consectetur adipiscing}| 7010{7: }{16: elit. Aenean non felis dapibus, semper sapien v}| 7011{7: }{16:itae, fringilla orci.Lorem ipsum dolor sit amet,}| 7012{7: }{16: consectetur adipiscing elit. Aenean non felis d}| 7013{7: }{16:apibus, semper sapien vitae, fringilla orci.Lore}| 7014{7: }{16:m ipsum dolor sit amet, consectetur adipiscing e}| 7015{7: }{16:lit. Aenean non felis dapibus, semper sapien vit}| 7016{7: }{16:ae, fringilla orci.} | 7017{7: }line2 | 7018{7: }line3 | 7019{7: }^ | 7020| 7021]] ) 7022feed ( '<C-e>' ) 7023screen : expect ( [[ 7024{7: }{16: elit. Aenean non felis dapibus, semper sapien v}| 7025{7: }{16:itae, fringilla orci.Lorem ipsum dolor sit amet,}| 7026{7: }{16: consectetur adipiscing elit. Aenean non felis d}| 7027{7: }{16:apibus, semper sapien vitae, fringilla orci.Lore}| 7028{7: }{16:m ipsum dolor sit amet, consectetur adipiscing e}| 7029{7: }{16:lit. Aenean non felis dapibus, semper sapien vit}| 7030{7: }{16:ae, fringilla orci.} | 7031{7: }line2 | 7032{7: }line3 | 7033{7: }^ | 7034{1:~ }| 7035| 7036]] ) 7037feed ( '<C-e>' ) 7038screen : expect ( [[ 7039{7: }{16:itae, fringilla orci.Lorem ipsum dolor sit amet,}| 7040{7: }{16: consectetur adipiscing elit. Aenean non felis d}| 7041{7: }{16:apibus, semper sapien vitae, fringilla orci.Lore}| 7042{7: }{16:m ipsum dolor sit amet, consectetur adipiscing e}| 7043{7: }{16:lit. Aenean non felis dapibus, semper sapien vit}| 7044{7: }{16:ae, fringilla orci.} | 7045{7: }line2 | 7046{7: }line3 | 7047{7: }^ | 7048{1:~ }|*2 7049| 7050]] ) 7051end ) 7052 7053it ( 'virt_lines_overflow=wrap with 2 cell character' , function () 7054command ( 'set wrap signcolumn=yes' ) 7055insert ( 'line1\nline2\nline3\n' ) 7056api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7057virt_lines ={ 7058{ { string . rep ( '12345678古' , 5 ), 'Special' } } , 7059} , 7060virt_lines_overflow ='wrap' , 7061} ) 7062screen : expect ( [[ 7063{7: }line1 | 7064{7: }{16:12345678古12345678古12345678古12345678古12345678}| 7065{7: }{16:古} | 7066{7: }line2 | 7067{7: }line3 | 7068{7: }^ | 7069{1:~ }|*5 7070| 7071]] ) 7072feed ( '<C-e>' ) 7073 7074screen : expect ( [[ 7075{7: }{16:12345678古12345678古12345678古12345678古12345678}| 7076{7: }{16:古} | 7077{7: }line2 | 7078{7: }line3 | 7079{7: }^ | 7080{1:~ }|*6 7081| 7082]] ) 7083 7084feed ( '<C-e>' ) 7085screen : expect ( [[ 7086{7: }{16:古} | 7087{7: }line2 | 7088{7: }line3 | 7089{7: }^ | 7090{1:~ }|*7 7091| 7092]] ) 7093end ) 7094 7095it ( 'virt_lines_overflow=wrap with tabs' , function () 7096command ( 'set wrap signcolumn=yes' ) 7097api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7098virt_lines ={ 7099{ { string . rep ( '1234\t\t\t5\t6\t78古' , 10 ), 'Special' } } , 7100} , 7101virt_lines_overflow ='wrap' , 7102} ) 7103screen : expect ( [[ 7104{7: }^ | 7105{7: }{16:1234 5 6 78古1234}| 7106{7: }{16: 5 6 78古1234}|*8 7107{7: }{16: 5 6 78古} | 7108| 7109]] ) 7110end ) 7111 7112it ( 'virt_lines_overflow=wrap with 2 cell character at the boundary' , function () 7113insert ( 'x' ) 7114api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7115virt_lines ={ { { string . rep ( 'a' , 49 ) .. string . rep ( '古' , 4 ), 'Special' } } } , 7116virt_lines_overflow ='wrap' , 7117} ) 7118screen : expect ( [[ 7119^x | 7120{16:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa }| 7121{16:古古古古} | 7122{1:~ }|*8 7123| 7124]] ) 7125api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 7126screen : try_resize ( 13 , 10 ) 7127api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7128virt_lines ={ 7129{ { 'AB' , 'Special' } } , 7130{ { string . rep ( '古' , 13 ), 'Special' } } , 7131} , 7132virt_lines_overflow ='wrap' , 7133} ) 7134screen : expect ( [[ 7135^x | 7136{16:AB} | 7137{16:古古古古古古 }|*2 7138{16:古} | 7139{1:~ }|*4 7140| 7141]] ) 7142end ) 7143 7144it ( 'virt_lines_overflow=wrap with nowrap' , function () 7145command ( 'set nowrap signcolumn=yes' ) 7146insert ( string . rep ( 'abcdefghij' , 6 ) .. 'line1\nline2\nline3\n' ) 7147api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7148virt_lines ={ 7149{ { string . rep ( '12345678古' , 5 ), 'Special' } } , 7150} , 7151virt_lines_overflow ='wrap' , 7152} ) 7153feed ( 'ggzlzl' ) 7154screen : expect ( [[ 7155{7: }^cdefghijabcdefghijabcdefghijabcdefghijabcdefghij| 7156{7: }{16:12345678古12345678古12345678古12345678古12345678}| 7157{7: }{16:古} | 7158{7: }ne2 | 7159{7: }ne3 | 7160{7: } | 7161{1:~ }|*5 7162| 7163]] ) 7164end ) 7165 7166it ( 'virt_lines_overflow=auto with wrap' , function () 7167command ( 'set wrap signcolumn=yes' ) 7168insert ( 'line1\nline2\nline3\n' ) 7169api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7170virt_lines ={ 7171{ { string . rep ( 'Thequickbrownfoxjumpsoverthelazydog. The quick brown fox jumps over the lazy dog' , 20 ), 'Special' } } , 7172} , 7173virt_lines_overflow ='auto' , 7174} ) 7175screen : expect ( [[ 7176{7: }{16:rown fox jumps over the lazy dogThequickbrownfox}| 7177{7: }{16:jumpsoverthelazydog. The quick brown fox jumps o}| 7178{7: }{16:ver the lazy dogThequickbrownfoxjumpsoverthelazy}| 7179{7: }{16:dog. The quick brown fox jumps over the lazy dog}| 7180{7: }{16:Thequickbrownfoxjumpsoverthelazydog. The quick b}| 7181{7: }{16:rown fox jumps over the lazy dogThequickbrownfox}| 7182{7: }{16:jumpsoverthelazydog. The quick brown fox jumps o}| 7183{7: }{16:ver the lazy dog} | 7184{7: }line2 | 7185{7: }line3 | 7186{7: }^ | 7187| 7188]] ) 7189end ) 7190 7191it ( 'virt_lines_overflow=auto and nowrap scrolls horizontally' , function () 7192command ( 'set nowrap signcolumn=yes' ) 7193insert ( 'abcdefghijklmnopqrstuvwxyz' ) 7194api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7195virt_lines ={ 7196{ { '12α口β̳γ̲=' , 'Special' } , { '❤️345678' , 'Special' } } , 7197{ { '123\t45\t678' , 'NonText' } } , 7198} , 7199virt_lines_overflow ='auto' , 7200} ) 7201screen : expect ( [[ 7202{7: }abcdefghijklmnopqrstuvwxy^z | 7203{7: }{16:12α口β̳γ̲=❤️345678} | 7204{7: }{1:123 45 678} | 7205{1:~ }|*8 7206| 7207]] ) 7208feed ( 'zl' ) 7209screen : expect ( [[ 7210{7: }bcdefghijklmnopqrstuvwxy^z | 7211{7: }{16:2α口β̳γ̲=❤️345678} | 7212{7: }{1:23 45 678} | 7213{1:~ }|*8 7214| 7215]] ) 7216end ) 7217 7218it ( 'virt_lines_overflow=wrap with virt_lines_above + virt_lines_leftcol' , function () 7219command ( 'set wrap signcolumn=yes' ) 7220insert ( 'line1\nline2\nline3\n' ) 7221feed ( '2gg' ) 7222api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { 7223virt_lines ={ 7224{ { string . rep ( 'Lorem ipsum dolor sit amet, consectetur. ' , 6 ), 'Special' } } , 7225} , 7226virt_lines_overflow ='wrap' , 7227virt_lines_above =true , 7228virt_lines_leftcol =true , 7229} ) 7230screen : expect ( [[ 7231{7: }line1 | 7232{16:Lorem ipsum dolor sit amet, consectetur. Lorem ips}| 7233{16:um dolor sit amet, consectetur. Lorem ipsum dolor }| 7234{16:sit amet, consectetur. Lorem ipsum dolor sit amet,}| 7235{16: consectetur. Lorem ipsum dolor sit amet, consecte}| 7236{16:tur. Lorem ipsum dolor sit amet, consectetur. } | 7237{7: }^line2 | 7238{7: }line3 | 7239{7: } | 7240{1:~ }|*2 7241| 7242]] ) 7243end ) 7244 7245it ( 'virt_lines_overflow=wrap with wrapped rows for statuscolumn' , function () 7246command ( 'set wrap statuscolumn=[%{v:lnum}]' ) 7247insert ( 'line1\nline2\nline3\n' ) 7248feed ( '2gg' ) 7249api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7250virt_lines ={ 7251{ { 'BELOW ' .. string . rep ( 'Lorem ipsum dolor sit amet, consectetur. ' , 4 ), 'Special' } } , 7252} , 7253virt_lines_overflow ='wrap' , 7254} ) 7255api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { 7256virt_lines ={ 7257{ { 'ABOVE ' .. string . rep ( 'Lorem ipsum dolor sit amet, consectetur. ' , 4 ), 'Special' } } , 7258} , 7259virt_lines_overflow ='wrap' , 7260virt_lines_above =true , 7261} ) 7262screen : expect ( [[ 7263{8:[1]}line1 | 7264{8:[1]}{16:BELOW Lorem ipsum dolor sit amet, consectetur. }| 7265{8:[1]}{16:Lorem ipsum dolor sit amet, consectetur. Lorem }| 7266{8:[1]}{16:ipsum dolor sit amet, consectetur. Lorem ipsum }| 7267{8:[1]}{16:dolor sit amet, consectetur. } | 7268{8:[2]}{16:ABOVE Lorem ipsum dolor sit amet, consectetur. }| 7269{8:[2]}{16:Lorem ipsum dolor sit amet, consectetur. Lorem }| 7270{8:[2]}{16:ipsum dolor sit amet, consectetur. Lorem ipsum }| 7271{8:[2]}{16:dolor sit amet, consectetur. } | 7272{8:[2]}^line2 | 7273{8:[3]}line3 | 7274| 7275]] ) 7276end ) 7277 7278it ( 'mixing virt_lines_overflow=wrap and virt_lines_overflow=scroll' , function () 7279command ( 'set nowrap signcolumn=yes' ) 7280insert ( 'line1\nline2\nline3\n' ) 7281api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7282virt_lines ={ { { 'BELOW ' .. string . rep ( 'a' , 60 ), 'Special' } } } , 7283virt_lines_overflow ='wrap' , 7284} ) 7285api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { 7286virt_lines ={ { { 'ABOVE ' .. string . rep ( 'b' , 60 ), 'Special' } } } , 7287virt_lines_overflow ='scroll' , 7288virt_lines_above =true , 7289} ) 7290api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { 7291virt_lines ={ { { 'BELOW ' .. string . rep ( 'c' , 60 ), 'Special' } } } , 7292virt_lines_overflow ='scroll' , 7293} ) 7294api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { 7295virt_lines ={ { { 'ABOVE ' .. string . rep ( 'd' , 60 ), 'Special' } } } , 7296virt_lines_overflow ='wrap' , 7297virt_lines_above =true , 7298} ) 7299feed ( '2ggzlzl' ) 7300screen : expect ( [[ 7301{7: }ne1 | 7302{7: }{16:BELOW aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| 7303{7: }{16:aaaaaaaaaaaaaaaaaa} | 7304{7: }{16:OVE bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}| 7305{7: }^ne2 | 7306{7: }{16:LOW cccccccccccccccccccccccccccccccccccccccccccc}| 7307{7: }{16:ABOVE dddddddddddddddddddddddddddddddddddddddddd}| 7308{7: }{16:dddddddddddddddddd} | 7309{7: }ne3 | 7310{7: } | 7311{1:~ }| 7312| 7313]] ) 7314end ) 7315 7316it ( 'highlight till eol with virt_lines_overflow=trunc' , function () 7317insert ( 'line1' ) 7318api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7319virt_lines ={ { { 'VIRT LINE1' , 'String' } , { '' , 'Visual' } } , { { 'VIRT LINE2' , 'String' } } } , 7320} ) 7321screen : expect ( [[ 7322line^1 | 7323{26:VIRT LINE1}{17: }| 7324{26:VIRT LINE2} | 7325{1:~ }|*8 7326| 7327]] ) 7328end ) 7329 7330it ( 'highlight till eol with virt_lines_overflow=wrap' , function () 7331insert ( 'line1' ) 7332api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7333virt_lines ={ { { 'VIRT LINE' , 'String' } , { string . rep ( '-' , 50 ), 'Visual' } , { '' , 'Visual' } } } , 7334virt_lines_overflow ='wrap' , 7335} ) 7336screen : expect ( [[ 7337line^1 | 7338{26:VIRT LINE}{17:-----------------------------------------}| 7339{17:--------- }| 7340{1:~ }|*8 7341| 7342]] ) 7343end ) 7344 7345it ( 'highlight till eol with virt_lines_overflow=scroll' , function () 7346command ( 'set nowrap' ) 7347insert ( 'abcdefghijklmnopqrstuvwxyz' ) 7348api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { 7349virt_lines ={ { { 'VIRT LINE' , 'String' } , { '' , 'Visual' } } } , 7350virt_lines_overflow ='scroll' , 7351} ) 7352screen : expect ( [[ 7353abcdefghijklmnopqrstuvwxy^z | 7354{26:VIRT LINE}{17: }| 7355{1:~ }|*9 7356| 7357]] ) 7358 7359feed ( 'zl' ) 7360screen : expect ( [[ 7361bcdefghijklmnopqrstuvwxy^z | 7362{26:IRT LINE}{17: }| 7363{1:~ }|*9 7364| 7365]] ) 7366 7367feed ( 'zl' ) 7368screen : expect ( [[ 7369cdefghijklmnopqrstuvwxy^z | 7370{26:RT LINE}{17: }| 7371{1:~ }|*9 7372| 7373]] ) 7374 7375feed ( '6zl' ) 7376screen : expect ( [[ 7377ijklmnopqrstuvwxy^z | 7378{26:E}{17: }| 7379{1:~ }|*9 7380| 7381]] ) 7382 7383feed ( 'zl' ) 7384screen : expect ( [[ 7385jklmnopqrstuvwxy^z | 7386{17: }| 7387{1:~ }|*9 7388| 7389]] ) 7390end ) 7391 7392it ( 'does not show twice if end_row or end_col is specified #18622' , function () 7393screen : try_resize ( 50 , 8 ) 7394insert ( [[ 7395aaa 7396bbb 7397ccc 7398ddd]] ) 7399api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =2 , virt_lines ={ { { 'VIRT LINE 1' , 'NonText' } } } } ) 7400api . nvim_buf_set_extmark ( 0 , ns , 3 , 0 , { end_col =2 , virt_lines ={ { { 'VIRT LINE 2' , 'NonText' } } } } ) 7401screen : expect { 7402grid =[[ 7403aaa | 7404{1:VIRT LINE 1} | 7405bbb | 7406ccc | 7407dd^d | 7408{1:VIRT LINE 2} | 7409{1:~ }| 7410| 7411]] , 7412} 7413end ) 7414 7415it ( 'works with rightleft' , function () 7416screen : try_resize ( 50 , 8 ) 7417insert ( [[ 7418aaa 7419bbb 7420ccc 7421ddd]] ) 7422command ( 'set number rightleft' ) 7423api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines ={ { { 'VIRT LINE 1' , 'NonText' } } } , virt_lines_leftcol =true } ) 7424api . nvim_buf_set_extmark ( 0 , ns , 3 , 0 , { virt_lines ={ { { 'VIRT LINE 2' , 'NonText' } } } } ) 7425screen : expect { 7426grid =[[ 7427aaa{8: 1 }| 7428{1:1 ENIL TRIV}| 7429bbb{8: 2 }| 7430ccc{8: 3 }| 7431^ddd{8: 4 }| 7432{1:2 ENIL TRIV}{8: }| 7433{1: ~}| 7434| 7435]] , 7436} 7437end ) 7438 7439it ( 'works when using dd or yyp #23915 #23916' , function () 7440insert ( [[ 7441line1 7442line2 7443line3 7444line4 7445line5]] ) 7446api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines ={ { { 'foo' } } , { { 'bar' } } , { { 'baz' } } } } ) 7447screen : expect { 7448grid =[[ 7449line1 | 7450foo | 7451bar | 7452baz | 7453line2 | 7454line3 | 7455line4 | 7456line^5 | 7457{1:~ }|*3 7458| 7459]] , 7460} 7461 7462feed ( 'gg' ) 7463feed ( 'yyp' ) 7464screen : expect { 7465grid =[[ 7466line1 | 7467foo | 7468bar | 7469baz | 7470^line1 | 7471line2 | 7472line3 | 7473line4 | 7474line5 | 7475{1:~ }|*2 7476| 7477]] , 7478} 7479 7480feed ( 'dd' ) 7481screen : expect { 7482grid =[[ 7483line1 | 7484foo | 7485bar | 7486baz | 7487^line2 | 7488line3 | 7489line4 | 7490line5 | 7491{1:~ }|*3 7492| 7493]] , 7494} 7495 7496feed ( 'kdd' ) 7497screen : expect ( [[ 7498^line2 | 7499foo | 7500bar | 7501baz | 7502line3 | 7503line4 | 7504line5 | 7505{1:~ }|*4 7506| 7507]] ) 7508end ) 7509 7510it ( 'does not break cursor position with concealcursor #27887' , function () 7511command ( 'vsplit' ) 7512insert ( '\n' ) 7513api . nvim_set_option_value ( 'conceallevel' , 2 , {} ) 7514api . nvim_set_option_value ( 'concealcursor' , 'niv' , {} ) 7515api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines ={ { { 'VIRT1' } } , { { 'VIRT2' } } } } ) 7516screen : expect ( [[ 7517│ | 7518VIRT1 │VIRT1 | 7519VIRT2 │VIRT2 | 7520^ │ | 7521{1:~ }│{1:~ }|*6 7522{3:[No Name] [+] }{2:[No Name] [+] }| 7523| 7524]] ) 7525end ) 7526 7527it ( 'works with full page scrolling #28290' , function () 7528screen : try_resize ( 20 , 8 ) 7529command ( 'call setline(1, range(20))' ) 7530api . nvim_buf_set_extmark ( 0 , ns , 10 , 0 , { virt_lines ={ { { 'VIRT1' } } , { { 'VIRT2' } } } } ) 7531screen : expect ( [[ 7532^0 | 75331 | 75342 | 75353 | 75364 | 75375 | 75386 | 7539| 7540]] ) 7541feed ( '<C-F>' ) 7542screen : expect ( [[ 7543^5 | 75446 | 75457 | 75468 | 75479 | 754810 | 7549VIRT1 | 7550| 7551]] ) 7552feed ( '<C-F>' ) 7553screen : expect ( [[ 7554^10 | 7555VIRT1 | 7556VIRT2 | 755711 | 755812 | 755913 | 756014 | 7561| 7562]] ) 7563feed ( '<C-F>' ) 7564screen : expect ( [[ 7565^13 | 756614 | 756715 | 756816 | 756917 | 757018 | 757119 | 7572| 7573]] ) 7574feed ( '<C-B>' ) 7575screen : expect ( [[ 757610 | 7577VIRT1 | 7578VIRT2 | 757911 | 758012 | 758113 | 7582^14 | 7583| 7584]] ) 7585feed ( '<C-B>' ) 7586screen : expect ( [[ 75875 | 75886 | 75897 | 75908 | 75919 | 7592^10 | 7593VIRT1 | 7594| 7595]] ) 7596feed ( '<C-B>' ) 7597screen : expect ( [[ 75980 | 75991 | 76002 | 76013 | 76024 | 76035 | 7604^6 | 7605| 7606]] ) 7607end ) 7608 7609it ( 'not drawn when invalid' , function () 7610api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { 'foo' , 'bar' } ) 7611api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines ={ { { 'VIRT1' } } } , invalidate =true } ) 7612screen : expect ( { 7613grid =[[ 7614^foo | 7615VIRT1 | 7616bar | 7617{1:~ }|*8 7618| 7619]] , 7620} ) 7621feed ( 'dd' ) 7622screen : expect ( { 7623grid =[[ 7624^bar | 7625{1:~ }|*10 7626| 7627]] , 7628} ) 7629end ) 7630 7631it ( "not revealed before skipcol scrolling up with 'smoothscroll'" , function () 7632api . nvim_set_option_value ( 'smoothscroll' , true , {} ) 7633api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { ( 'x' ): rep ( screen . _width * 2 ) } ) 7634api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { virt_lines_above =true , virt_lines ={ { { 'VIRT1' } } } } ) 7635feed ( '<C-E>' ) 7636screen : expect ( [[ 7637{1:<<<}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x| 7638{1:~ }|*10 7639| 7640]] ) 7641feed ( '<C-Y>' ) 7642screen : expect ( [[ 7643xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| 7644xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x| 7645{1:~ }|*9 7646| 7647]] ) 7648feed ( '<C-Y>' ) 7649screen : expect ( [[ 7650VIRT1 | 7651xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| 7652xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x| 7653{1:~ }|*8 7654| 7655]] ) 7656end ) 7657end ) 7658 7659describe ( 'decorations: signs' , function () 7660local screen ---@type test.functional.ui.screen 7661local ns ---@type integer 7662 7663before_each ( function () 7664clear () 7665screen =Screen . new ( 50 , 10 ) 7666screen : add_extra_attr_ids { 7667[ 100 ] ={ foreground =Screen . colors . Blue , background =Screen . colors . Yellow } , 7668} 7669 7670ns =api . nvim_create_namespace 'test' 7671api . nvim_set_option_value ( 'signcolumn' , 'auto:9' , {} ) 7672end ) 7673 7674local example_test3 =[[ 7675l1 7676l2 7677l3 7678l4 7679l5 7680]] 7681 7682it ( 'can add a single sign (no end row)' , function () 7683insert ( example_test3 ) 7684feed 'gg' 7685 7686api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S' } ) 7687 7688screen : expect ( [[ 7689{7: }^l1 | 7690{7:S }l2 | 7691{7: }l3 | 7692{7: }l4 | 7693{7: }l5 | 7694{7: } | 7695{1:~ }|*3 7696| 7697]] ) 7698end ) 7699 7700it ( 'can add a single sign (with end row)' , function () 7701insert ( example_test3 ) 7702feed 'gg' 7703 7704api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S' , end_row =1 } ) 7705 7706screen : expect ( [[ 7707{7: }^l1 | 7708{7:S }l2 | 7709{7: }l3 | 7710{7: }l4 | 7711{7: }l5 | 7712{7: } | 7713{1:~ }|*3 7714| 7715]] ) 7716end ) 7717 7718it ( 'can add a single sign and text highlight' , function () 7719insert ( example_test3 ) 7720feed 'gg' 7721 7722api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { sign_text ='S' , hl_group ='Todo' , end_col =1 } ) 7723screen : expect ( [[ 7724{7: }^l1 | 7725{7:S }{100:l}2 | 7726{7: }l3 | 7727{7: }l4 | 7728{7: }l5 | 7729{7: } | 7730{1:~ }|*3 7731| 7732]] ) 7733 7734api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 7735end ) 7736 7737it ( 'can add multiple signs (single extmark)' , function () 7738insert ( example_test3 ) 7739feed 'gg' 7740 7741api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S' , end_row =2 } ) 7742 7743screen : expect ( [[ 7744{7: }^l1 | 7745{7:S }l2 | 7746{7:S }l3 | 7747{7: }l4 | 7748{7: }l5 | 7749{7: } | 7750{1:~ }|*3 7751| 7752]] ) 7753end ) 7754 7755it ( 'can add multiple signs (multiple extmarks)' , function () 7756insert ( example_test3 ) 7757feed 'gg' 7758 7759api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S1' } ) 7760api . nvim_buf_set_extmark ( 0 , ns , 3 , - 1 , { sign_text ='S2' , end_row =4 } ) 7761 7762screen : expect ( [[ 7763{7: }^l1 | 7764{7:S1}l2 | 7765{7: }l3 | 7766{7:S2}l4 | 7767{7:S2}l5 | 7768{7: } | 7769{1:~ }|*3 7770| 7771]] ) 7772end ) 7773 7774it ( 'can add multiple signs (multiple extmarks) 2' , function () 7775insert ( example_test3 ) 7776feed 'gg' 7777 7778api . nvim_buf_set_extmark ( 0 , ns , 3 , - 1 , { sign_text ='S1' } ) 7779api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S2' , end_row =3 } ) 7780screen : expect ( [[ 7781{7: }^l1 | 7782{7:S2 }l2 | 7783{7:S2 }l3 | 7784{7:S2S1}l4 | 7785{7: }l5 | 7786{7: } | 7787{1:~ }|*3 7788| 7789]] ) 7790end ) 7791 7792it ( 'can add multiple signs (multiple extmarks) 3' , function () 7793insert ( example_test3 ) 7794feed 'gg' 7795 7796api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S1' , end_row =2 } ) 7797api . nvim_buf_set_extmark ( 0 , ns , 2 , - 1 , { sign_text ='S2' , end_row =3 } ) 7798 7799screen : expect ( [[ 7800{7: }^l1 | 7801{7:S1 }l2 | 7802{7:S2S1}l3 | 7803{7:S2 }l4 | 7804{7: }l5 | 7805{7: } | 7806{1:~ }|*3 7807| 7808]] ) 7809end ) 7810 7811it ( 'can add multiple signs (multiple extmarks) 4' , function () 7812insert ( example_test3 ) 7813feed 'gg' 7814 7815api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S1' , end_row =0 } ) 7816api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S2' , end_row =1 } ) 7817 7818screen : expect ( [[ 7819{7:S1}^l1 | 7820{7:S2}l2 | 7821{7: }l3 | 7822{7: }l4 | 7823{7: }l5 | 7824{7: } | 7825{1:~ }|*3 7826| 7827]] ) 7828end ) 7829 7830it ( 'works with old signs' , function () 7831insert ( example_test3 ) 7832feed 'gg' 7833 7834n . command ( 'sign define Oldsign text=x' ) 7835n . command ( [[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]] ) 7836 7837api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S1' } ) 7838api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S2' } ) 7839api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S4' } ) 7840api . nvim_buf_set_extmark ( 0 , ns , 2 , - 1 , { sign_text ='S5' } ) 7841 7842screen : expect ( [[ 7843{7:S4S1}^l1 | 7844{7:S2x }l2 | 7845{7:S5 }l3 | 7846{7: }l4 | 7847{7: }l5 | 7848{7: } | 7849{1:~ }|*3 7850| 7851]] ) 7852end ) 7853 7854it ( 'works with old signs (with range)' , function () 7855insert ( example_test3 ) 7856feed 'gg' 7857 7858n . command ( 'sign define Oldsign text=x' ) 7859n . command ( [[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]] ) 7860 7861api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S1' } ) 7862api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S2' } ) 7863api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S3' , end_row =4 } ) 7864api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S4' } ) 7865api . nvim_buf_set_extmark ( 0 , ns , 2 , - 1 , { sign_text ='S5' } ) 7866 7867screen : expect ( [[ 7868{7:S4S3S1}^l1 | 7869{7:S3S2x }l2 | 7870{7:S5S3 }l3 | 7871{7:S3 }l4 | 7872{7:S3 }l5 | 7873{7: } | 7874{1:~ }|*3 7875| 7876]] ) 7877end ) 7878 7879it ( 'can add a ranged sign (with start out of view)' , function () 7880insert ( example_test3 ) 7881command 'set signcolumn=yes:2' 7882feed 'gg' 7883feed '2<C-e>' 7884 7885api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='X' , end_row =3 } ) 7886 7887screen : expect ( [[ 7888{7:X }^l3 | 7889{7:X }l4 | 7890{7: }l5 | 7891{7: } | 7892{1:~ }|*5 7893| 7894]] ) 7895end ) 7896 7897it ( 'can add lots of signs' , function () 7898screen : try_resize ( 40 , 10 ) 7899command 'normal 10oa b c d e f g h' 7900 7901for i =1 , 10 do 7902api . nvim_buf_set_extmark ( 0 , ns , i , 0 , { end_col =1 , hl_group ='Todo' } ) 7903api . nvim_buf_set_extmark ( 0 , ns , i , 2 , { end_col =3 , hl_group ='Todo' } ) 7904api . nvim_buf_set_extmark ( 0 , ns , i , 4 , { end_col =5 , hl_group ='Todo' } ) 7905api . nvim_buf_set_extmark ( 0 , ns , i , 6 , { end_col =7 , hl_group ='Todo' } ) 7906api . nvim_buf_set_extmark ( 0 , ns , i , 8 , { end_col =9 , hl_group ='Todo' } ) 7907api . nvim_buf_set_extmark ( 0 , ns , i , 10 , { end_col =11 , hl_group ='Todo' } ) 7908api . nvim_buf_set_extmark ( 0 , ns , i , 12 , { end_col =13 , hl_group ='Todo' } ) 7909api . nvim_buf_set_extmark ( 0 , ns , i , 14 , { end_col =15 , hl_group ='Todo' } ) 7910api . nvim_buf_set_extmark ( 0 , ns , i , - 1 , { sign_text ='W' } ) 7911api . nvim_buf_set_extmark ( 0 , ns , i , - 1 , { sign_text ='X' } ) 7912api . nvim_buf_set_extmark ( 0 , ns , i , - 1 , { sign_text ='Y' } ) 7913api . nvim_buf_set_extmark ( 0 , ns , i , - 1 , { sign_text ='Z' } ) 7914end 7915 7916screen : expect ( [[ 7917{7:Z Y X W }{100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:h} |*8 7918{7:Z Y X W }{100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:^h} | 7919| 7920]] ) 7921end ) 7922 7923it ( 'works with priority #19716' , function () 7924screen : try_resize ( 20 , 3 ) 7925insert ( example_test3 ) 7926feed 'gg' 7927 7928command ( 'sign define Oldsign text=O3' ) 7929command ( [[exe 'sign place 42 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7930 7931api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S4' , priority =100 } ) 7932api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S2' , priority =5 } ) 7933api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S5' , priority =200 } ) 7934api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S1' , priority =1 } ) 7935 7936screen : expect ( [[ 7937{7:S5S4O3S2S1}^l1 | 7938{7: }l2 | 7939| 7940]] ) 7941 7942-- Check truncation works too 7943api . nvim_set_option_value ( 'signcolumn' , 'auto' , {} ) 7944 7945screen : expect ( [[ 7946{7:S5}^l1 | 7947{7: }l2 | 7948| 7949]] ) 7950end ) 7951 7952it ( 'does not overflow with many old signs #23852' , function () 7953screen : try_resize ( 20 , 3 ) 7954 7955command ( 'set signcolumn:auto:9' ) 7956command ( 'sign define Oldsign text=O3' ) 7957command ( [[exe 'sign place 01 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7958command ( [[exe 'sign place 02 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7959command ( [[exe 'sign place 03 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7960command ( [[exe 'sign place 04 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7961command ( [[exe 'sign place 05 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7962command ( [[exe 'sign place 06 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7963command ( [[exe 'sign place 07 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7964command ( [[exe 'sign place 08 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7965command ( [[exe 'sign place 09 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]] ) 7966screen : expect ( [[ 7967{7:O3O3O3O3O3O3O3O3O3}^ | 7968{1:~ }| 7969| 7970]] ) 7971 7972api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S1' , priority =1 } ) 7973screen : expect_unchanged () 7974 7975api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S5' , priority =200 } ) 7976screen : expect ( [[ 7977{7:S5O3O3O3O3O3O3O3O3}^ | 7978{1:~ }| 7979| 7980]] ) 7981 7982assert_alive () 7983end ) 7984 7985it ( 'does not set signcolumn for signs without text' , function () 7986screen : try_resize ( 20 , 3 ) 7987api . nvim_set_option_value ( 'signcolumn' , 'auto' , {} ) 7988insert ( example_test3 ) 7989feed 'gg' 7990api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { number_hl_group ='Error' } ) 7991screen : expect { grid =[[ 7992^l1 | 7993l2 | 7994| 7995]] } 7996end ) 7997 7998it ( 'correct width when removing multiple signs from sentinel line' , function () 7999screen : try_resize ( 20 , 4 ) 8000insert ( example_test3 ) 8001api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S1' , end_row =3 } ) 8002api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { invalidate =true , sign_text ='S2' } ) 8003api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { invalidate =true , sign_text ='S3' } ) 8004feed ( '2Gdd' ) 8005 8006screen : expect ( [[ 8007{7:S1}l1 | 8008{7:S1}^l3 | 8009{7:S1}l4 | 8010| 8011]] ) 8012end ) 8013 8014it ( 'correct width with multiple overlapping signs' , function () 8015screen : try_resize ( 20 , 4 ) 8016insert ( example_test3 ) 8017api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S1' } ) 8018api . nvim_buf_set_extmark ( 0 , ns , 0 , - 1 , { sign_text ='S2' , end_row =2 } ) 8019api . nvim_buf_set_extmark ( 0 , ns , 1 , - 1 , { sign_text ='S3' , end_row =2 } ) 8020feed ( 'gg' ) 8021 8022local s1 =[[ 8023{7:S2S1}^l1 | 8024{7:S3S2}l2 | 8025{7:S3S2}l3 | 8026| 8027]] 8028screen : expect ( s1 ) 8029-- Correct width when :move'ing a line with signs 8030command ( 'move2' ) 8031screen : expect ( [[ 8032{7:S3 }l2 | 8033{7:S3S2S1}^l1 | 8034{7: }l3 | 8035| 8036]] ) 8037command ( 'silent undo' ) 8038screen : expect { grid =s1 } 8039command ( 'd' ) 8040screen : expect ( [[ 8041{7:S3S2S1}^l2 | 8042{7:S3S2 }l3 | 8043{7: }l4 | 8044| 8045]] ) 8046command ( 'd' ) 8047screen : expect ( [[ 8048{7:S3S2S1}^l3 | 8049{7: }l4 | 8050{7: }l5 | 8051| 8052]] ) 8053end ) 8054 8055it ( 'correct width when adding and removing multiple signs' , function () 8056screen : try_resize ( 20 , 4 ) 8057insert ( example_test3 ) 8058feed ( 'gg' ) 8059command ( [[ 8060let ns = nvim_create_namespace('') 8061call nvim_buf_set_extmark(0, ns, 0, 0, {'sign_text':'S1', 'end_row':3}) 8062let s1 = nvim_buf_set_extmark(0, ns, 2, 0, {'sign_text':'S2', 'end_row':4}) 8063let s2 = nvim_buf_set_extmark(0, ns, 5, 0, {'sign_text':'S3'}) 8064let s3 = nvim_buf_set_extmark(0, ns, 6, 0, {'sign_text':'S3'}) 8065let s4 = nvim_buf_set_extmark(0, ns, 5, 0, {'sign_text':'S3'}) 8066let s5 = nvim_buf_set_extmark(0, ns, 6, 0, {'sign_text':'S3'}) 8067redraw! 8068call nvim_buf_del_extmark(0, ns, s2) 8069call nvim_buf_del_extmark(0, ns, s3) 8070call nvim_buf_del_extmark(0, ns, s4) 8071call nvim_buf_del_extmark(0, ns, s5) 8072redraw! 8073call nvim_buf_del_extmark(0, ns, s1) 8074]] ) 8075screen : expect ( [[ 8076{7:S1}^l1 | 8077{7:S1}l2 | 8078{7:S1}l3 | 8079| 8080]] ) 8081end ) 8082 8083it ( 'correct width when deleting lines' , function () 8084screen : try_resize ( 20 , 4 ) 8085insert ( example_test3 ) 8086feed ( 'gg' ) 8087command ( [[ 8088let ns = nvim_create_namespace('') 8089call nvim_buf_set_extmark(0, ns, 4, 0, {'sign_text':'S1'}) 8090call nvim_buf_set_extmark(0, ns, 4, 0, {'sign_text':'S2'}) 8091let s3 = nvim_buf_set_extmark(0, ns, 5, 0, {'sign_text':'S3'}) 8092call nvim_buf_del_extmark(0, ns, s3) 8093norm 4Gdd 8094]] ) 8095screen : expect ( [[ 8096{7: }l3 | 8097{7:S2S1}l5 | 8098{7: }^ | 8099| 8100]] ) 8101end ) 8102 8103it ( 'correct width when splitting lines with signs on different columns' , function () 8104screen : try_resize ( 20 , 4 ) 8105insert ( example_test3 ) 8106feed ( 'gg' ) 8107api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { sign_text ='S1' } ) 8108api . nvim_buf_set_extmark ( 0 , ns , 0 , 1 , { sign_text ='S2' } ) 8109feed ( 'a<cr><esc>' ) 8110screen : expect ( [[ 8111{7:S1}l | 8112{7:S2}^1 | 8113{7: }l2 | 8114| 8115]] ) 8116end ) 8117 8118it ( 'correct width after wiping a buffer' , function () 8119screen : try_resize ( 20 , 4 ) 8120insert ( example_test3 ) 8121feed ( 'gg' ) 8122local buf =api . nvim_get_current_buf () 8123api . nvim_buf_set_extmark ( buf , ns , 0 , 0 , { sign_text ='h' } ) 8124screen : expect ( [[ 8125{7:h }^l1 | 8126{7: }l2 | 8127{7: }l3 | 8128| 8129]] ) 8130api . nvim_win_set_buf ( 0 , api . nvim_create_buf ( false , true )) 8131api . nvim_buf_delete ( buf , { unload =true , force =true } ) 8132api . nvim_buf_set_lines ( buf , 0 , - 1 , false , { '' } ) 8133api . nvim_win_set_buf ( 0 , buf ) 8134screen : expect { grid =[[ 8135^ | 8136{1:~ }|*2 8137| 8138]] } 8139end ) 8140 8141it ( 'correct width with moved marks before undo savepos' , function () 8142screen : try_resize ( 20 , 4 ) 8143insert ( example_test3 ) 8144feed ( 'gg' ) 8145exec_lua ( [[ 8146local ns = vim.api.nvim_create_namespace('') 8147vim.api.nvim_buf_set_extmark(0, ns, 0, 0, { sign_text = 'S1' }) 8148vim.api.nvim_buf_set_extmark(0, ns, 1, 0, { sign_text = 'S2' }) 8149local s3 = vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { sign_text = 'S3' }) 8150local s4 = vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { sign_text = 'S4' }) 8151vim.schedule(function() 8152vim.cmd('silent d3') 8153vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { id = s3, sign_text = 'S3' }) 8154vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { id = s4, sign_text = 'S4' }) 8155vim.cmd('silent undo') 8156vim.api.nvim_buf_del_extmark(0, ns, s3) 8157end) 8158]] ) 8159 8160screen : expect ( [[ 8161{7:S1}^l1 | 8162{7:S2}l2 | 8163{7:S4}l3 | 8164| 8165]] ) 8166end ) 8167 8168it ( 'no crash with sign after many marks #27137' , function () 8169screen : try_resize ( 20 , 4 ) 8170insert ( 'a' ) 8171for _ =0 , 104 do 8172api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { hl_group ='Error' , end_col =1 } ) 8173end 8174api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { sign_text ='S1' } ) 8175 8176screen : expect ( [[ 8177{7:S1}{9:^a} | 8178{1:~ }|*2 8179| 8180]] ) 8181end ) 8182 8183it ( 'correct sort order with multiple namespaces and same id' , function () 8184local ns2 =api . nvim_create_namespace ( '' ) 8185api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { sign_text ='S1' , id =1 } ) 8186api . nvim_buf_set_extmark ( 0 , ns2 , 0 , 0 , { sign_text ='S2' , id =1 } ) 8187 8188screen : expect ( [[ 8189{7:S2S1}^ | 8190{1:~ }|*8 8191| 8192]] ) 8193end ) 8194 8195it ( 'correct number of signs after deleting text (#27046)' , function () 8196command ( 'call setline(1, ["foo"]->repeat(31))' ) 8197api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =0 , sign_text ='S1' } ) 8198api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { end_row =0 , end_col =3 , hl_group ='Error' } ) 8199api . nvim_buf_set_extmark ( 0 , ns , 9 , 0 , { end_row =9 , sign_text ='S2' } ) 8200api . nvim_buf_set_extmark ( 0 , ns , 9 , 0 , { end_row =9 , end_col =3 , hl_group ='Error' } ) 8201api . nvim_buf_set_extmark ( 0 , ns , 19 , 0 , { end_row =19 , sign_text ='S3' } ) 8202api . nvim_buf_set_extmark ( 0 , ns , 19 , 0 , { end_row =19 , end_col =3 , hl_group ='Error' } ) 8203api . nvim_buf_set_extmark ( 0 , ns , 29 , 0 , { end_row =29 , sign_text ='S4' } ) 8204api . nvim_buf_set_extmark ( 0 , ns , 29 , 0 , { end_row =29 , end_col =3 , hl_group ='Error' } ) 8205api . nvim_buf_set_extmark ( 0 , ns , 30 , 0 , { end_row =30 , sign_text ='S5' } ) 8206api . nvim_buf_set_extmark ( 0 , ns , 30 , 0 , { end_row =30 , end_col =3 , hl_group ='Error' } ) 8207command ( '0d29' ) 8208 8209screen : expect ( [[ 8210{7:S4S3S2S1}{9:^foo} | 8211{7:S5 }{9:foo} | 8212{1:~ }|*7 821329 fewer lines | 8214]] ) 8215 8216api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 8217end ) 8218 8219it ( [[correct numberwidth with 'signcolumn' set to "number" #28984]] , function () 8220command ( 'set number numberwidth=1 signcolumn=number' ) 8221api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { sign_text ='S1' } ) 8222screen : expect ( [[ 8223{7:S1 }^ | 8224{1:~ }|*8 8225| 8226]] ) 8227api . nvim_buf_del_extmark ( 0 , ns , 1 ) 8228screen : expect ( [[ 8229{8:1 }^ | 8230{1:~ }|*8 8231| 8232]] ) 8233end ) 8234 8235it ( 'supports emoji as signs' , function () 8236insert ( example_test3 ) 8237feed 'gg' 8238api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { sign_text ='🧑🌾' } ) 8239-- VS16 can change width of character 8240api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { sign_text ='❤️' } ) 8241api . nvim_buf_set_extmark ( 0 , ns , 3 , 0 , { sign_text ='❤' } ) 8242api . nvim_buf_set_extmark ( 0 , ns , 4 , 0 , { sign_text ='❤x' } ) 8243screen : expect ( [[ 8244{7: }^l1 | 8245{7:🧑🌾}l2 | 8246{7:❤️}l3 | 8247{7:❤ }l4 | 8248{7:❤x}l5 | 8249{7: } | 8250{1:~ }|*3 8251| 8252]] ) 8253eq ( "Invalid 'sign_text'" , pcall_err ( api . nvim_buf_set_extmark , 0 , ns , 5 , 0 , { sign_text ='❤️x' } )) 8254end ) 8255 8256it ( 'auto signcolumn hides with invalidated sign' , function () 8257api . nvim_set_option_value ( 'signcolumn' , 'auto' , {} ) 8258api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { sign_text ='S1' , invalidate =true } ) 8259feed ( 'ia<cr>b<esc>dd' ) 8260screen : expect ( { 8261grid =[[ 8262^a | 8263{1:~ }|*8 8264| 8265]] , 8266} ) 8267end ) 8268 8269it ( 'signcolumn correctly tracked with signs beyond eob and pair end before start' , function () 8270api . nvim_set_option_value ( 'signcolumn' , 'auto:2' , {} ) 8271api . nvim_set_option_value ( 'filetype' , 'lua' , {} ) 8272api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { 'foo' , 'bar' } ) 8273api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { sign_text ='S1' } ) 8274api . nvim_set_hl ( 0 , 'SignColumn' , { link ='Error' } ) 8275screen : expect ( [[ 8276^foo | 8277bar | 8278{1:~ }|*7 8279| 8280]] ) 8281api . nvim_buf_set_extmark ( 0 , ns , 0 , 0 , { sign_text ='S2' , end_row =1 } ) 8282api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { '-- foo' , '-- bar' } ) 8283api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 8284screen : expect ( [[ 8285^-- foo | 8286-- bar | 8287{1:~ }|*7 8288| 8289]] ) 8290assert_alive () 8291end ) 8292end ) 8293 8294describe ( 'decorations: virt_text' , function () 8295local ns , screen ---@type integer, test.functional.ui.screen 8296 8297before_each ( function () 8298clear () 8299screen =Screen . new ( 50 , 10 ) 8300ns =api . nvim_create_namespace ( 'test' ) 8301end ) 8302 8303it ( 'avoids regression in #17638' , function () 8304command 'set number relativenumber' 8305command 'normal 4ohello' 8306command 'normal aVIRTUAL' 8307 8308api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { 8309virt_text ={ { 'hello' , 'String' } } , 8310virt_text_win_col =20 , 8311} ) 8312 8313screen : expect { 8314grid =[[ 8315{8: 4 } | 8316{8: 3 }hello | 8317{8: 2 }hello {26:hello} | 8318{8: 1 }hello | 8319{8:5 }helloVIRTUA^L | 8320{1:~ }|*4 8321| 8322]] , 8323} 8324 8325-- Trigger a screen update 8326feed ( 'k' ) 8327 8328screen : expect { 8329grid =[[ 8330{8: 3 } | 8331{8: 2 }hello | 8332{8: 1 }hello {26:hello} | 8333{8:4 }hell^o | 8334{8: 1 }helloVIRTUAL | 8335{1:~ }|*4 8336| 8337]] , 8338} 8339end ) 8340 8341it ( 'redraws correctly when re-using extmark ids' , function () 8342command 'normal 5ohello' 8343 8344screen : expect { 8345grid =[[ 8346| 8347hello |*4 8348hell^o | 8349{1:~ }|*3 8350| 8351]] , 8352} 8353 8354for row =1 , 5 do 8355api . nvim_buf_set_extmark ( 0 , ns , row , 0 , { id =1 , virt_text ={ { 'world' , 'Normal' } } } ) 8356end 8357 8358screen : expect { 8359grid =[[ 8360| 8361hello |*4 8362hell^o world | 8363{1:~ }|*3 8364| 8365]] , 8366} 8367end ) 8368 8369it ( 'redraws correctly when removing mark whose end ends up in front of start' , function () 8370command ( 'normal 5ohello' ) 8371api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { end_col =1 , virt_text ={ { 'world' , 'Normal' } } } ) 8372screen : expect ( [[ 8373| 8374hello | 8375hello world | 8376hello |*2 8377hell^o | 8378{1:~ }|*3 8379| 8380]] ) 8381feed ( '3Gdd' ) 8382api . nvim_buf_clear_namespace ( 0 , ns , 0 , - 1 ) 8383screen : expect ( [[ 8384| 8385hello | 8386^hello | 8387hello |*2 8388{1:~ }|*4 8389| 8390]] ) 8391end ) 8392end ) 8393 8394describe ( 'decorations: window scoped' , function () 8395local screen ---@type test.functional.ui.screen 8396local ns ---@type integer 8397local win_other ---@type integer 8398 8399local url ='https://example.com' 8400before_each ( function () 8401clear () 8402screen =Screen . new ( 20 , 10 ) 8403screen : add_extra_attr_ids { 8404[ 100 ] ={ special =Screen . colors . Red , undercurl =true } , 8405[ 101 ] ={ url ='https://example.com' } , 8406} 8407 8408ns =api . nvim_create_namespace 'test' 8409 8410insert ( '12345' ) 8411 8412win_other =api . nvim_open_win ( 0 , false , { 8413col =0 , 8414row =0 , 8415width =20 , 8416height =10 , 8417relative ='win' , 8418style ='minimal' , 8419hide =true , 8420} ) 8421end ) 8422 8423local noextmarks ={ 8424grid =[[ 84251234^5 | 8426{1:~ }|*8 8427| 8428]] , 8429} 8430 8431local function set_extmark ( line , col , opts ) 8432return api . nvim_buf_set_extmark ( 0 , ns , line , col , opts ) 8433end 8434 8435it ( 'rejects an invalid window without leaking the window set' , function () 8436-- The bad handle comes second, so the set already owns an allocation by 8437-- the time validation fails and returns. 8438eq ( 'Invalid window id: 9999' , t . pcall_err ( api . nvim__ns_set , ns , { wins ={ api . nvim_get_current_win (), 9999 } } )) 8439assert_alive () 8440end ) 8441 8442it ( 'hl_group' , function () 8443set_extmark ( 0 , 0 , { 8444hl_group ='Comment' , 8445end_col =3 , 8446} ) 8447 8448api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8449 8450screen : expect { 8451grid =[[ 8452{18:123}4^5 | 8453{1:~ }|*8 8454| 8455]] , 8456} 8457 8458command 'split' 8459command 'only' 8460 8461screen : expect ( noextmarks ) 8462end ) 8463 8464it ( 'virt_text' , function () 8465set_extmark ( 0 , 0 , { 8466virt_text ={ { 'a' , 'Comment' } } , 8467virt_text_pos ='eol' , 8468} ) 8469set_extmark ( 0 , 5 , { 8470virt_text ={ { 'b' , 'Comment' } } , 8471virt_text_pos ='inline' , 8472} ) 8473set_extmark ( 0 , 1 , { 8474virt_text ={ { 'c' , 'Comment' } } , 8475virt_text_pos ='overlay' , 8476} ) 8477set_extmark ( 0 , 1 , { 8478virt_text ={ { 'd' , 'Comment' } } , 8479virt_text_pos ='right_align' , 8480} ) 8481 8482api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8483 8484screen : expect { 8485grid =[[ 84861{18:c}34^5{18:b} {18:a} {18:d}| 8487{1:~ }|*8 8488| 8489]] , 8490} 8491 8492command 'split' 8493command 'only' 8494 8495screen : expect ( noextmarks ) 8496 8497api . nvim__ns_set ( ns , { wins ={} } ) 8498 8499screen : expect { 8500grid =[[ 85011{18:c}34^5{18:b} {18:a} {18:d}| 8502{1:~ }|*8 8503| 8504]] , 8505} 8506end ) 8507 8508it ( 'virt_lines' , function () 8509set_extmark ( 0 , 0 , { 8510virt_lines ={ { { 'a' , 'Comment' } } } , 8511} ) 8512 8513api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8514 8515screen : expect { 8516grid =[[ 85171234^5 | 8518{18:a} | 8519{1:~ }|*7 8520| 8521]] , 8522} 8523 8524command 'split' 8525command 'only' 8526 8527screen : expect ( noextmarks ) 8528end ) 8529 8530it ( 'redraws correctly with inline virt_text and wrapping' , function () 8531set_extmark ( 0 , 2 , { 8532virt_text ={ { ( 'b' ): rep ( 18 ), 'Comment' } } , 8533virt_text_pos ='inline' , 8534} ) 8535 8536api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8537 8538screen : expect { 8539grid =[[ 854012{18:bbbbbbbbbbbbbbbbbb}| 854134^5 | 8542{1:~ }|*7 8543| 8544]] , 8545} 8546 8547api . nvim__ns_set ( ns , { wins ={ win_other } } ) 8548 8549screen : expect ( noextmarks ) 8550end ) 8551 8552pending ( 'sign_text' , function () 8553-- TODO(altermo): The window signcolumn width is calculated wrongly (when `signcolumn=auto`) 8554-- This happens in function `win_redraw_signcols` on line containing `buf_meta_total(buf, kMTMetaSignText) > 0` 8555set_extmark ( 0 , 0 , { 8556sign_text ='a' , 8557sign_hl_group ='Comment' , 8558} ) 8559 8560api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8561 8562screen : expect { 8563grid =[[ 8564a 1234^5 | 8565{2:~ }|*8 8566| 8567]] , 8568} 8569 8570command 'split' 8571command 'only' 8572 8573screen : expect ( noextmarks ) 8574end ) 8575 8576it ( 'statuscolumn hl group' , function () 8577set_extmark ( 0 , 0 , { 8578number_hl_group ='comment' , 8579} ) 8580set_extmark ( 0 , 0 , { 8581line_hl_group ='comment' , 8582} ) 8583 8584command 'set number' 8585 8586api . nvim__ns_set ( ns , { wins ={ win_other } } ) 8587 8588screen : expect { 8589grid =[[ 8590{8: 1 }1234^5 | 8591{1:~ }|*8 8592| 8593]] , 8594} 8595 8596api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8597 8598screen : expect { 8599grid =[[ 8600{18: 1 1234^5 }| 8601{1:~ }|*8 8602| 8603]] , 8604} 8605 8606command 'split' 8607command 'only' 8608 8609screen : expect { 8610grid =[[ 8611{8: 1 }1234^5 | 8612{1:~ }|*8 8613| 8614]] , 8615} 8616end ) 8617 8618it ( 'spell' , function () 8619api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'aa' } ) 8620 8621set_extmark ( 0 , 0 , { 8622spell =true , 8623end_col =2 , 8624} ) 8625 8626command 'set spelloptions=noplainbuffer' 8627command 'set spell' 8628command 'syntax off' 8629 8630screen : expect ( { unchanged =true } ) 8631 8632api . nvim__ns_set ( ns , { wins ={ win_other } } ) 8633 8634screen : expect { 8635grid =[[ 8636a^a | 8637{1:~ }|*8 8638| 8639]] , 8640} 8641 8642api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8643 8644screen : expect { 8645grid =[[ 8646{100:a^a} | 8647{1:~ }|*8 8648| 8649]] , 8650} 8651 8652command 'split' 8653command 'only' 8654 8655screen : expect { 8656grid =[[ 8657a^a | 8658{1:~ }|*8 8659| 8660]] , 8661} 8662end ) 8663 8664it ( 'url' , function () 8665set_extmark ( 0 , 0 , { 8666end_col =3 , 8667url =url , 8668} ) 8669 8670api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8671 8672screen : expect { 8673grid =[[ 8674{101:123}4^5 | 8675{1:~ }|*8 8676| 8677]] , 8678} 8679 8680command 'split' 8681command 'only' 8682 8683screen : expect ( noextmarks ) 8684end ) 8685 8686it ( 'change namespace scope' , function () 8687set_extmark ( 0 , 0 , { 8688hl_group ='Comment' , 8689end_col =3 , 8690} ) 8691 8692api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8693eq ( { wins ={ api . nvim_get_current_win () } } , api . nvim__ns_get ( ns )) 8694 8695screen : expect { 8696grid =[[ 8697{18:123}4^5 | 8698{1:~ }|*8 8699| 8700]] , 8701} 8702 8703command 'split' 8704command 'only' 8705 8706screen : expect ( noextmarks ) 8707 8708api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8709eq ( { wins ={ api . nvim_get_current_win () } } , api . nvim__ns_get ( ns )) 8710 8711screen : expect { 8712grid =[[ 8713{18:123}4^5 | 8714{1:~ }|*8 8715| 8716]] , 8717} 8718 8719local win_new =api . nvim_open_win ( 0 , false , { 8720col =0 , 8721row =0 , 8722width =20 , 8723height =10 , 8724relative ='win' , 8725style ='minimal' , 8726hide =true , 8727} ) 8728 8729api . nvim__ns_set ( ns , { wins ={ win_new } } ) 8730eq ( { wins ={ win_new } } , api . nvim__ns_get ( ns )) 8731 8732screen : expect ( noextmarks ) 8733end ) 8734 8735it ( 'namespace get works' , function () 8736eq ( { wins ={} } , api . nvim__ns_get ( ns )) 8737 8738api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8739 8740eq ( { wins ={ api . nvim_get_current_win () } } , api . nvim__ns_get ( ns )) 8741 8742api . nvim__ns_set ( ns , { wins ={} } ) 8743 8744eq ( { wins ={} } , api . nvim__ns_get ( ns )) 8745end ) 8746 8747it ( 'remove window from namespace scope when deleted' , function () 8748api . nvim__ns_set ( ns , { wins ={ 0 } } ) 8749 8750eq ( { wins ={ api . nvim_get_current_win () } } , api . nvim__ns_get ( ns )) 8751 8752command 'split' 8753command 'only' 8754 8755eq ( { wins ={} } , api . nvim__ns_get ( ns )) 8756end ) 8757end )