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 , finally =t . describe , t . it , t . before_each , t . finally 6local clear =n . clear 7local command =n . command 8local exec =n . exec 9local feed =n . feed 10local api =n . api 11local fn =n . fn 12local nvim_dir =n . nvim_dir 13local assert_alive =n . assert_alive 14 15before_each ( clear ) 16 17describe ( 'messages' , function () 18local screen 19 20-- oldtest: Test_warning_scroll() 21it ( 'a warning causes scrolling if and only if it has a stacktrace' , function () 22t . skip ( t . is_arch ( 's390x' ), 'timing-sensitive test unreliable on s390x' ) 23screen =Screen . new ( 75 , 6 ) 24 25-- When the warning comes from a script, messages are scrolled so that the 26-- stacktrace is visible. 27-- It is a bit hard to assert the screen when sourcing a script, so skip this part. 28 29-- When the warning does not come from a script, messages are not scrolled. 30command ( 'enew' ) 31command ( 'set readonly' ) 32feed ( 'u' ) 33screen : expect ( { 34grid =[[ 35| 36{1:~ }|*4 37{19:W10: Warning: Changing a readonly file}^ | 38]] , 39timeout =500 , 40} ) 41screen : expect ( [[ 42^ | 43{1:~ }|*4 44Already at oldest change | 45]] ) 46end ) 47 48-- oldtest: Test_message_not_cleared_after_mode() 49it ( 'clearing mode does not remove message' , function () 50screen =Screen . new ( 60 , 10 ) 51exec ( [[ 52nmap <silent> gx :call DebugSilent('normal')<CR> 53vmap <silent> gx :call DebugSilent('visual')<CR> 54function DebugSilent(arg) 55echomsg "from DebugSilent" a:arg 56endfunction 57set showmode 58set cmdheight=1 59call setline(1, ['one', 'NoSuchFile', 'three']) 60]] ) 61 62feed ( 'gx' ) 63screen : expect ( [[ 64^one | 65NoSuchFile | 66three | 67{1:~ }|*6 68from DebugSilent normal | 69]] ) 70 71-- removing the mode message used to also clear the intended message 72feed ( 'vEgx' ) 73screen : expect ( [[ 74^one | 75NoSuchFile | 76three | 77{1:~ }|*6 78from DebugSilent visual | 79]] ) 80 81-- removing the mode message used to also clear the error message 82command ( 'set cmdheight=2' ) 83feed ( '2GvEgf' ) 84screen : expect ( [[ 85one | 86NoSuchFil^e | 87three | 88{1:~ }|*5 89| 90{9:E447: Can't find file "NoSuchFile" in path} | 91]] ) 92end ) 93 94-- oldtest: Test_mode_cleared_after_silent_message() 95it ( 'mode is cleared properly after silent message' , function () 96screen =Screen . new ( 60 , 10 ) 97exec ( [[ 98edit XsilentMessageMode.txt 99call setline(1, 'foobar') 100autocmd TextChanged * silent update 101]] ) 102finally ( function () 103os . remove ( 'XsilentMessageMode.txt' ) 104end ) 105 106feed ( 'v' ) 107screen : expect ( [[ 108{17:^f}oobar | 109{1:~ }|*8 110{5:-- VISUAL --} | 111]] ) 112 113feed ( 'd' ) 114screen : expect ( [[ 115^oobar | 116{1:~ }|*8 117| 118]] ) 119end ) 120 121describe ( 'more prompt' , function () 122before_each ( function () 123command ( 'set more' ) 124end ) 125 126-- oldtest: Test_message_more() 127it ( 'works' , function () 128screen =Screen . new ( 75 , 6 ) 129 130command ( 'call setline(1, range(1, 100))' ) 131 132feed ( ':%pfoo<C-H><C-H><C-H>#' ) 133screen : expect ( [[ 1341 | 1352 | 1363 | 1374 | 1385 | 139:%p#^ | 140]] ) 141feed ( '\n' ) 142screen : expect ( [[ 143{8: 1 }1 | 144{8: 2 }2 | 145{8: 3 }3 | 146{8: 4 }4 | 147{8: 5 }5 | 148{6:-- More --}^ | 149]] ) 150 151feed ( '?' ) 152screen : expect ( [[ 153{8: 1 }1 | 154{8: 2 }2 | 155{8: 3 }3 | 156{8: 4 }4 | 157{8: 5 }5 | 158{6:-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit }^ | 159]] ) 160 161-- Down a line with j, <CR>, <NL> or <Down>. 162feed ( 'j' ) 163screen : expect ( [[ 164{8: 2 }2 | 165{8: 3 }3 | 166{8: 4 }4 | 167{8: 5 }5 | 168{8: 6 }6 | 169{6:-- More --}^ | 170]] ) 171feed ( '<NL>' ) 172screen : expect ( [[ 173{8: 3 }3 | 174{8: 4 }4 | 175{8: 5 }5 | 176{8: 6 }6 | 177{8: 7 }7 | 178{6:-- More --}^ | 179]] ) 180feed ( '<CR>' ) 181screen : expect ( [[ 182{8: 4 }4 | 183{8: 5 }5 | 184{8: 6 }6 | 185{8: 7 }7 | 186{8: 8 }8 | 187{6:-- More --}^ | 188]] ) 189feed ( '<Down>' ) 190screen : expect ( [[ 191{8: 5 }5 | 192{8: 6 }6 | 193{8: 7 }7 | 194{8: 8 }8 | 195{8: 9 }9 | 196{6:-- More --}^ | 197]] ) 198 199-- Down a screen with <Space>, f, <C-F>, or <PageDown>. 200feed ( 'f' ) 201screen : expect ( [[ 202{8: 10 }10 | 203{8: 11 }11 | 204{8: 12 }12 | 205{8: 13 }13 | 206{8: 14 }14 | 207{6:-- More --}^ | 208]] ) 209feed ( '\6' ) 210screen : expect ( [[ 211{8: 15 }15 | 212{8: 16 }16 | 213{8: 17 }17 | 214{8: 18 }18 | 215{8: 19 }19 | 216{6:-- More --}^ | 217]] ) 218feed ( ' ' ) 219screen : expect ( [[ 220{8: 20 }20 | 221{8: 21 }21 | 222{8: 22 }22 | 223{8: 23 }23 | 224{8: 24 }24 | 225{6:-- More --}^ | 226]] ) 227feed ( '<PageDown>' ) 228screen : expect ( [[ 229{8: 25 }25 | 230{8: 26 }26 | 231{8: 27 }27 | 232{8: 28 }28 | 233{8: 29 }29 | 234{6:-- More --}^ | 235]] ) 236 237-- Down a page (half a screen) with d. 238feed ( 'd' ) 239screen : expect ( [[ 240{8: 28 }28 | 241{8: 29 }29 | 242{8: 30 }30 | 243{8: 31 }31 | 244{8: 32 }32 | 245{6:-- More --}^ | 246]] ) 247 248-- Down all the way with 'G'. 249feed ( 'G' ) 250screen : expect ( [[ 251{8: 96 }96 | 252{8: 97 }97 | 253{8: 98 }98 | 254{8: 99 }99 | 255{8:100 }100 | 256{6:Press ENTER or type command to continue}^ | 257]] ) 258 259-- Up a line k, <BS> or <Up>. 260feed ( 'k' ) 261screen : expect ( [[ 262{8: 95 }95 | 263{8: 96 }96 | 264{8: 97 }97 | 265{8: 98 }98 | 266{8: 99 }99 | 267{6:-- More --}^ | 268]] ) 269feed ( '<BS>' ) 270screen : expect ( [[ 271{8: 94 }94 | 272{8: 95 }95 | 273{8: 96 }96 | 274{8: 97 }97 | 275{8: 98 }98 | 276{6:-- More --}^ | 277]] ) 278feed ( '<Up>' ) 279screen : expect ( [[ 280{8: 93 }93 | 281{8: 94 }94 | 282{8: 95 }95 | 283{8: 96 }96 | 284{8: 97 }97 | 285{6:-- More --}^ | 286]] ) 287 288-- Up a screen with b, <C-B> or <PageUp>. 289feed ( 'b' ) 290screen : expect ( [[ 291{8: 88 }88 | 292{8: 89 }89 | 293{8: 90 }90 | 294{8: 91 }91 | 295{8: 92 }92 | 296{6:-- More --}^ | 297]] ) 298feed ( '\2' ) 299screen : expect ( [[ 300{8: 83 }83 | 301{8: 84 }84 | 302{8: 85 }85 | 303{8: 86 }86 | 304{8: 87 }87 | 305{6:-- More --}^ | 306]] ) 307feed ( '<PageUp>' ) 308screen : expect ( [[ 309{8: 78 }78 | 310{8: 79 }79 | 311{8: 80 }80 | 312{8: 81 }81 | 313{8: 82 }82 | 314{6:-- More --}^ | 315]] ) 316 317-- Up a page (half a screen) with u. 318feed ( 'u' ) 319screen : expect ( [[ 320{8: 75 }75 | 321{8: 76 }76 | 322{8: 77 }77 | 323{8: 78 }78 | 324{8: 79 }79 | 325{6:-- More --}^ | 326]] ) 327 328-- Test <C-F> and <C-B> as keycodes instead of raw control chars. 329feed ( '<C-F>' ) 330screen : expect ( [[ 331{8: 80 }80 | 332{8: 81 }81 | 333{8: 82 }82 | 334{8: 83 }83 | 335{8: 84 }84 | 336{6:-- More --}^ | 337]] ) 338feed ( '<C-B>' ) 339screen : expect ( [[ 340{8: 75 }75 | 341{8: 76 }76 | 342{8: 77 }77 | 343{8: 78 }78 | 344{8: 79 }79 | 345{6:-- More --}^ | 346]] ) 347 348-- Up all the way with 'g'. 349feed ( 'g' ) 350screen : expect ( [[ 351:%p# | 352{8: 1 }1 | 353{8: 2 }2 | 354{8: 3 }3 | 355{8: 4 }4 | 356{6:-- More --}^ | 357]] ) 358 359-- All the way down. Pressing f or CTRL-F should do nothing but pressing 360-- space should end the more prompt. 361feed ( 'G' ) 362screen : expect ( [[ 363{8: 96 }96 | 364{8: 97 }97 | 365{8: 98 }98 | 366{8: 99 }99 | 367{8:100 }100 | 368{6:Press ENTER or type command to continue}^ | 369]] ) 370feed ( 'f' ) 371screen : expect_unchanged () 372feed ( '<C-F>' ) 373screen : expect_unchanged () 374feed ( '<Space>' ) 375screen : expect ( [[ 37696 | 37797 | 37898 | 37999 | 380^100 | 381| 382]] ) 383 384-- Pressing g< shows the previous command output. 385feed ( 'g<lt>' ) 386screen : expect ( [[ 387{8: 96 }96 | 388{8: 97 }97 | 389{8: 98 }98 | 390{8: 99 }99 | 391{8:100 }100 | 392{6:Press ENTER or type command to continue}^ | 393]] ) 394 395-- A command line that doesn't print text is appended to scrollback, 396-- even if it invokes a nested command line. 397feed ( [[:<C-R>=':'<CR>:<CR>g<lt>]] ) 398screen : expect ( [[ 399{8: 97 }97 | 400{8: 98 }98 | 401{8: 99 }99 | 402{8:100 }100 | 403::: | 404{6:Press ENTER or type command to continue}^ | 405]] ) 406 407feed ( ':%p#\n' ) 408screen : expect ( [[ 409{8: 1 }1 | 410{8: 2 }2 | 411{8: 3 }3 | 412{8: 4 }4 | 413{8: 5 }5 | 414{6:-- More --}^ | 415]] ) 416 417-- Stop command output with q, <Esc> or CTRL-C. 418feed ( 'q' ) 419screen : expect ( [[ 42096 | 42197 | 42298 | 42399 | 424^100 | 425| 426]] ) 427 428-- Execute a : command from the more prompt 429feed ( ':%p#\n' ) 430screen : expect ( [[ 431{8: 1 }1 | 432{8: 2 }2 | 433{8: 3 }3 | 434{8: 4 }4 | 435{8: 5 }5 | 436{6:-- More --}^ | 437]] ) 438feed ( ':' ) 439screen : expect ( [[ 440{8: 1 }1 | 441{8: 2 }2 | 442{8: 3 }3 | 443{8: 4 }4 | 444{8: 5 }5 | 445:^ | 446]] ) 447feed ( "echo 'Hello'\n" ) 448screen : expect ( [[ 449{8: 2 }2 | 450{8: 3 }3 | 451{8: 4 }4 | 452{8: 5 }5 | 453Hello | 454{6:Press ENTER or type command to continue}^ | 455]] ) 456end ) 457 458-- oldtest: Test_message_more_recording() 459it ( "hitting 'q' at hit-enter prompt does not start recording" , function () 460screen =Screen . new ( 60 , 6 ) 461command ( 'call setline(1, range(1, 100))' ) 462feed ( ':%p\n' ) 463screen : expect ( [[ 4641 | 4652 | 4663 | 4674 | 4685 | 469{6:-- More --}^ | 470]] ) 471feed ( 'G' ) 472screen : expect ( [[ 47396 | 47497 | 47598 | 47699 | 477100 | 478{6:Press ENTER or type command to continue}^ | 479]] ) 480 481-- Hitting 'q' at the end of the more prompt should not start recording 482feed ( 'q' ) 483screen : expect ( [[ 48496 | 48597 | 48698 | 48799 | 488^100 | 489| 490]] ) 491-- Hitting 'k' now should move the cursor up instead of recording keys 492feed ( 'k' ) 493screen : expect ( [[ 49496 | 49597 | 49698 | 497^99 | 498100 | 499| 500]] ) 501end ) 502 503-- oldtest: Test_echo_verbose_system() 504it ( 'verbose message before echo command' , function () 505screen =Screen . new ( 60 , 10 ) 506 507command ( 'cd ' .. nvim_dir ) 508api . nvim_set_option_value ( 'shell' , './shell-test' , {} ) 509api . nvim_set_option_value ( 'shellcmdflag' , 'REP 20' , {} ) 510api . nvim_set_option_value ( 'shellxquote' , '' , {} ) -- win: avoid extra quotes 511 512-- display a page and go back, results in exactly the same view 513feed ( [[:4 verbose echo system('foo')<CR>]] ) 514screen : expect ( [[ 515Executing command: "'./shell-test' 'REP' '20' 'foo'" | 516| 5170: foo | 5181: foo | 5192: foo | 5203: foo | 5214: foo | 5225: foo | 5236: foo | 524{6:-- More --}^ | 525]] ) 526feed ( '<Space>' ) 527screen : expect ( [[ 5287: foo | 5298: foo | 5309: foo | 53110: foo | 53211: foo | 53312: foo | 53413: foo | 53514: foo | 53615: foo | 537{6:-- More --}^ | 538]] ) 539feed ( 'b' ) 540screen : expect ( [[ 541Executing command: "'./shell-test' 'REP' '20' 'foo'" | 542| 5430: foo | 5441: foo | 5452: foo | 5463: foo | 5474: foo | 5485: foo | 5496: foo | 550{6:-- More --}^ | 551]] ) 552 553-- do the same with 'cmdheight' set to 2 554feed ( 'q' ) 555command ( 'set ch=2' ) 556screen : expect ( [[ 557^ | 558{1:~ }|*7 559|*2 560]] ) 561feed ( [[:4 verbose echo system('foo')<CR>]] ) 562screen : expect ( [[ 563Executing command: "'./shell-test' 'REP' '20' 'foo'" | 564| 5650: foo | 5661: foo | 5672: foo | 5683: foo | 5694: foo | 5705: foo | 5716: foo | 572{6:-- More --}^ | 573]] ) 574feed ( '<Space>' ) 575screen : expect ( [[ 5767: foo | 5778: foo | 5789: foo | 57910: foo | 58011: foo | 58112: foo | 58213: foo | 58314: foo | 58415: foo | 585{6:-- More --}^ | 586]] ) 587feed ( 'b' ) 588screen : expect ( [[ 589Executing command: "'./shell-test' 'REP' '20' 'foo'" | 590| 5910: foo | 5921: foo | 5932: foo | 5943: foo | 5954: foo | 5965: foo | 5976: foo | 598{6:-- More --}^ | 599]] ) 600end ) 601 602-- oldtest: Test_quit_long_message() 603it ( 'with control characters can be quit vim-patch:8.2.1844' , function () 604screen =Screen . new ( 40 , 10 ) 605 606feed ( [[:echom range(9999)->join("\x01")<CR>]] ) 607screen : expect ( [[ 6080{18:^A}1{18:^A}2{18:^A}3{18:^A}4{18:^A}5{18:^A}6{18:^A}7{18:^A}8{18:^A}9{18:^A}10{18:^A}11{18:^A}12| 609{18:^A}13{18:^A}14{18:^A}15{18:^A}16{18:^A}17{18:^A}18{18:^A}19{18:^A}20{18:^A}21{18:^A}22| 610{18:^A}23{18:^A}24{18:^A}25{18:^A}26{18:^A}27{18:^A}28{18:^A}29{18:^A}30{18:^A}31{18:^A}32| 611{18:^A}33{18:^A}34{18:^A}35{18:^A}36{18:^A}37{18:^A}38{18:^A}39{18:^A}40{18:^A}41{18:^A}42| 612{18:^A}43{18:^A}44{18:^A}45{18:^A}46{18:^A}47{18:^A}48{18:^A}49{18:^A}50{18:^A}51{18:^A}52| 613{18:^A}53{18:^A}54{18:^A}55{18:^A}56{18:^A}57{18:^A}58{18:^A}59{18:^A}60{18:^A}61{18:^A}62| 614{18:^A}63{18:^A}64{18:^A}65{18:^A}66{18:^A}67{18:^A}68{18:^A}69{18:^A}70{18:^A}71{18:^A}72| 615{18:^A}73{18:^A}74{18:^A}75{18:^A}76{18:^A}77{18:^A}78{18:^A}79{18:^A}80{18:^A}81{18:^A}82| 616{18:^A}83{18:^A}84{18:^A}85{18:^A}86{18:^A}87{18:^A}88{18:^A}89{18:^A}90{18:^A}91{18:^A}92| 617{6:-- More --}^ | 618]] ) 619feed ( 'q' ) 620screen : expect ( [[ 621^ | 622{1:~ }|*8 623| 624]] ) 625end ) 626end ) 627 628describe ( 'mode is cleared when' , function () 629before_each ( function () 630screen =Screen . new ( 40 , 6 ) 631end ) 632 633-- oldtest: Test_mode_message_at_leaving_insert_by_ctrl_c() 634it ( 'leaving Insert mode with Ctrl-C vim-patch:8.1.1189' , function () 635exec ( [[ 636func StatusLine() abort 637return "" 638endfunc 639set statusline=%!StatusLine() 640set laststatus=2 641]] ) 642feed ( 'i' ) 643screen : expect ( [[ 644^ | 645{1:~ }|*3 646{3: }| 647{5:-- INSERT --} | 648]] ) 649feed ( '<C-C>' ) 650screen : expect ( [[ 651^ | 652{1:~ }|*3 653{3: }| 654| 655]] ) 656end ) 657 658-- oldtest: Test_mode_message_at_leaving_insert_with_esc_mapped() 659it ( 'leaving Insert mode with ESC in the middle of a mapping vim-patch:8.1.1192' , function () 660exec ( [[ 661set laststatus=2 662inoremap <Esc> <Esc>00 663]] ) 664feed ( 'i' ) 665screen : expect ( [[ 666^ | 667{1:~ }|*3 668{3:[No Name] }| 669{5:-- INSERT --} | 670]] ) 671feed ( '<Esc>' ) 672screen : expect ( [[ 673^ | 674{1:~ }|*3 675{3:[No Name] }| 676| 677]] ) 678end ) 679 680-- oldtest: Test_mode_updated_after_ctrl_c() 681it ( 'pressing Ctrl-C in i_CTRL-O' , function () 682feed ( 'i<C-O>' ) 683screen : expect ( [[ 684^ | 685{1:~ }|*4 686{5:-- (insert) --} | 687]] ) 688feed ( '<C-C>' ) 689screen : expect ( [[ 690^ | 691{1:~ }|*4 692| 693]] ) 694end ) 695end ) 696 697-- oldtest: Test_ask_yesno() 698it ( 'y/n prompt works' , function () 699screen =Screen . new ( 75 , 6 ) 700command ( 'set noincsearch nohlsearch inccommand=' ) 701command ( 'call setline(1, range(1, 2))' ) 702 703feed ( ':2,1s/^/n/\n' ) 704screen : expect ( [[ 7051 | 7062 | 707{1:~ }|*3 708{6:Backwards range given, OK to swap (y/n)?}^ | 709]] ) 710feed ( 'n' ) 711screen : expect ( [[ 712^1 | 7132 | 714{1:~ }|*3 715{6:Backwards range given, OK to swap (y/n)?}n | 716]] ) 717 718feed ( ':2,1s/^/Esc/\n' ) 719screen : expect ( [[ 7201 | 7212 | 722{1:~ }|*3 723{6:Backwards range given, OK to swap (y/n)?}^ | 724]] ) 725feed ( '<Esc>' ) 726screen : expect ( [[ 727^1 | 7282 | 729{1:~ }|*3 730{6:Backwards range given, OK to swap (y/n)?}n | 731]] ) 732 733feed ( ':2,1s/^/y/\n' ) 734screen : expect ( [[ 7351 | 7362 | 737{1:~ }|*3 738{6:Backwards range given, OK to swap (y/n)?}^ | 739]] ) 740feed ( 'y' ) 741screen : expect ( [[ 742y1 | 743^y2 | 744{1:~ }|*3 745{6:Backwards range given, OK to swap (y/n)?}y | 746]] ) 747end ) 748 749-- oldtest: Test_fileinfo_tabpage_cmdheight() 750it ( "fileinfo works when 'cmdheight' has just decreased" , function () 751screen =Screen . new ( 40 , 6 ) 752 753exec ( [[ 754set shortmess-=o 755set shortmess-=O 756set shortmess-=F 757tabnew 758set cmdheight=2 759]] ) 760screen : expect ( [[ 761{24: [No Name] }{5: [No Name] }{2: }{24:X}| 762^ | 763{1:~ }|*2 764|*2 765]] ) 766 767feed ( ':tabprev | edit Xfileinfo.txt<CR>' ) 768screen : expect ( [[ 769{5: Xfileinfo.txt }{24: [No Name] }{2: }{24:X}| 770^ | 771{1:~ }|*3 772"Xfileinfo.txt" [New] | 773]] ) 774assert_alive () 775end ) 776 777-- oldtest: Test_fileinfo_after_echo() 778it ( 'fileinfo does not overwrite echo message vim-patch:8.2.4156' , function () 779screen =Screen . new ( 40 , 6 ) 780 781exec ( [[ 782set shortmess-=F 783 784file a.txt 785 786hide edit b.txt 787call setline(1, "hi") 788setlocal modified 789 790hide buffer a.txt 791 792autocmd CursorHold * buf b.txt | w | echo "'b' written" 793]] ) 794 795command ( 'set updatetime=50' ) 796feed ( '0$' ) 797screen : expect ( [[ 798^hi | 799{1:~ }|*4 800'b' written | 801]] ) 802os . remove ( 'b.txt' ) 803end ) 804 805-- oldtest: Test_messagesopt_wait() 806it ( '&messagesopt "wait"' , function () 807screen =Screen . new ( 45 , 6 ) 808command ( 'set cmdheight=1' ) 809 810-- Check hit-enter prompt 811command ( 'set messagesopt=hit-enter,history:500' ) 812feed ( ":echo 'foo' | echo 'bar' | echo 'baz'\n" ) 813screen : expect ( [[ 814| 815{3: }| 816foo | 817bar | 818baz | 819{6:Press ENTER or type command to continue}^ | 820]] ) 821feed ( '<CR>' ) 822 823-- Check no hit-enter prompt when "wait:" is set 824command ( 'set messagesopt=wait:500,history:500' ) 825feed ( ":echo 'foo' | echo 'bar' | echo 'baz'\n" ) 826screen : expect ( { 827grid =[[ 828| 829{1:~ }| 830{3: }| 831foo | 832bar | 833baz | 834]] , 835timeout =500 , 836} ) 837screen : expect ( [[ 838^ | 839{1:~ }|*4 840| 841]] ) 842end ) 843 844-- oldtest: Test_long_formatprg_no_hit_enter() 845it ( "long 'formatprg' doesn't cause hit-enter prompt or wrong cursor pos" , function () 846t . skip ( fn . executable ( 'sed' ) == 0 , 'missing "sed" command' ) 847 848screen =Screen . new ( 75 , 10 ) 849exec ( [[ 850setlocal scrolloff=0 851call setline(1, range(1, 40)) 852let &l:formatprg = $'sed{repeat(' ', &columns)}p' 853normal 20Gmz 854normal 10Gzt 855]] ) 856screen : expect ( [[ 857^10 | 85811 | 85912 | 86013 | 86114 | 86215 | 86316 | 86417 | 86518 | 866| 867]] ) 868feed ( 'gq2j' ) 869screen : expect ( [[ 87010 |*2 87111 |*2 87212 | 873^12 | 87413 | 87514 | 87615 | 877| 878]] ) 879feed ( ':messages<CR>' ) 880screen : expect ( [[ 88110 |*2 88211 |*2 88312 | 884^12 | 88513 | 88614 | 88715 | 8883 lines filtered | 889]] ) 890end ) 891 892-- oldtest: Test_hit_enter_during_mapping() 893it ( 'hit-enter prompt during a mapping' , function () 894screen =Screen . new ( 75 , 10 ) 895exec ( [[ 896set ruler 897call setline(1, range(1, 20)) 898" The 8-line :echo leads to a hit-enter prompt. 899nnoremap X :echo "a\nb\nc\nd\ne\nf\ng\nh"<CR>gg 900nnoremap \b :echo "a\nb\nc\nd\ne\nf\ng\nh"<CR>:b<Space> 901normal! 10G 902]] ) 903t . eq ( { mode ='n' , blocking =false } , api . nvim_get_mode ()) 904t . eq ( { 10 , 0 } , api . nvim_win_get_cursor ( 0 )) 905 906feed ( 'X' ) 907-- Without the fix the hit-enter prompt eats the mapping's "g" keys and the 908-- cursor stays put. With the fix "gg" runs and moves the cursor to line 1. 909t . eq ( { mode ='n' , blocking =false } , api . nvim_get_mode ()) 910t . eq ( { 1 , 0 } , api . nvim_win_get_cursor ( 0 )) 911 912-- If a mapping starts cmdline after multiline messages exceeding 'cmdheight', 913-- the messages should still be visible. 914feed ( '\\b' ) 915screen : expect ( [[ 916{3: }| 917a | 918b | 919c | 920d | 921e | 922f | 923g | 924h | 925:b ^ | 926]] ) 927end ) 928 929-- oldtest: Test_fileinfo_after_last_bd() 930it ( 'fileinfo is shown after :bd on last listed buffer' , function () 931screen =Screen . new ( 50 , 10 ) 932exec ( [[ 933set shortmess-=F 934edit xxx 935edit yyy 936]] ) 937screen : expect ( [[ 938^ | 939{1:~ }|*8 940"yyy" [New] | 941]] ) 942 943command ( 'bd' ) 944screen : expect ( [[ 945^ | 946{1:~ }|*8 947"xxx" [New] --No lines in buffer-- | 948]] ) 949 950command ( 'bd' ) 951screen : expect ( [[ 952^ | 953{1:~ }|*8 954"[No Name]" --No lines in buffer-- | 955]] ) 956end ) 957end )