1" Tests for popup windows for text properties 2 3source check.vim 4CheckFeature popupwin 5CheckFeature textprop 6 7source screendump.vim 8CheckScreendump 9 10func Test_textprop_popup() 11 let lines =<< trim END 12 call setline(1, range(1, 100)) 13 call setline(50, 'some text to work with') 14 50 15 normal zz 16 set scrolloff=0 17 call prop_type_add('popupMarker', #{highlight: 'DiffAdd', bufnr: bufnr('%')}) 18 call prop_add(50, 11, #{ 19 \ length: 7, 20 \ type: 'popupMarker', 21 \ bufnr: bufnr('%'), 22 \ }) 23 let winid = popup_create('the text', #{ 24 \ pos: 'botleft', 25 \ textprop: 'popupMarker', 26 \ border: [], 27 \ padding: [0,1,0,1], 28 \ close: 'click', 29 \ }) 30 END 31 call writefile(lines, 'XtestTextpropPopup') 32 let buf = RunVimInTerminal('-S XtestTextpropPopup', #{rows: 10}) 33 call VerifyScreenDump(buf, 'Test_popup_textprop_01', {}) 34 35 call term_sendkeys(buf, "zt") 36 call VerifyScreenDump(buf, 'Test_popup_textprop_02', {}) 37 38 call term_sendkeys(buf, "zzIawe\<Esc>") 39 call VerifyScreenDump(buf, 'Test_popup_textprop_03', {}) 40 41 call term_sendkeys(buf, "0dw") 42 call VerifyScreenDump(buf, 'Test_popup_textprop_04', {}) 43 44 call term_sendkeys(buf, "Oinserted\<Esc>") 45 call VerifyScreenDump(buf, 'Test_popup_textprop_05', {}) 46 47 call term_sendkeys(buf, "k2dd") 48 call VerifyScreenDump(buf, 'Test_popup_textprop_06', {}) 49 50 call term_sendkeys(buf, "4\<C-E>") 51 call VerifyScreenDump(buf, 'Test_popup_textprop_07', {}) 52 53 " clean up 54 call StopVimInTerminal(buf) 55 call delete('XtestTextpropPopup') 56endfunc 57 58func Test_textprop_popup_corners() 59 let lines =<< trim END 60 call setline(1, range(1, 100)) 61 call setline(50, 'now working with some longer text here') 62 50 63 normal zz 64 set scrolloff=0 65 call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) 66 call prop_add(50, 23, #{ 67 \ length: 6, 68 \ type: 'popupMarker', 69 \ }) 70 let winid = popup_create('bottom left', #{ 71 \ pos: 'botleft', 72 \ textprop: 'popupMarker', 73 \ textpropwin: win_getid(), 74 \ padding: [0,1,0,1], 75 \ }) 76 let winid = popup_create('bottom right', #{ 77 \ pos: 'botright', 78 \ textprop: 'popupMarker', 79 \ border: [], 80 \ padding: [0,1,0,1], 81 \ }) 82 let winid = popup_create('top left', #{ 83 \ pos: 'topleft', 84 \ textprop: 'popupMarker', 85 \ border: [], 86 \ padding: [0,1,0,1], 87 \ }) 88 let winid = popup_create('top right', #{ 89 \ pos: 'topright', 90 \ textprop: 'popupMarker', 91 \ padding: [0,1,0,1], 92 \ }) 93 END 94 call writefile(lines, 'XtestTextpropPopupCorners') 95 let buf = RunVimInTerminal('-S XtestTextpropPopupCorners', #{rows: 12}) 96 call VerifyScreenDump(buf, 'Test_popup_textprop_corn_1', {}) 97 98 call term_sendkeys(buf, "0dw") 99 call VerifyScreenDump(buf, 'Test_popup_textprop_corn_2', {}) 100 101 call term_sendkeys(buf, "46Goextra\<Esc>") 102 call VerifyScreenDump(buf, 'Test_popup_textprop_corn_3', {}) 103 104 call term_sendkeys(buf, "u") 105 call term_sendkeys(buf, ":\<CR>") 106 call VerifyScreenDump(buf, 'Test_popup_textprop_corn_4', {}) 107 108 call term_sendkeys(buf, ":vsplit foo\<CR>") 109 call VerifyScreenDump(buf, 'Test_popup_textprop_corn_5', {}) 110 111 call term_sendkeys(buf, ":only!\<CR>") 112 call VerifyScreenDump(buf, 'Test_popup_textprop_corn_6', {}) 113 114 " clean up 115 call StopVimInTerminal(buf) 116 call delete('XtestTextpropPopupCorners') 117endfunc 118 119func Test_textprop_popup_offsets() 120 let lines =<< trim END 121 call setline(1, range(1, 100)) 122 call setline(50, 'now working with some longer text here') 123 50 124 normal zz 125 set scrolloff=0 126 call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) 127 call prop_add(50, 23, #{ 128 \ length: 6, 129 \ type: 'popupMarker', 130 \ }) 131 let winid = popup_create('bottom left', #{ 132 \ pos: 'botleft', 133 \ line: -1, 134 \ col: 2, 135 \ textprop: 'popupMarker', 136 \ padding: [0,1,0,1], 137 \ }) 138 let winid = popup_create('bottom right', #{ 139 \ pos: 'botright', 140 \ line: -1, 141 \ col: -2, 142 \ textprop: 'popupMarker', 143 \ border: [], 144 \ padding: [0,1,0,1], 145 \ }) 146 let winid = popup_create('top left', #{ 147 \ pos: 'topleft', 148 \ line: 1, 149 \ col: 2, 150 \ textprop: 'popupMarker', 151 \ border: [], 152 \ padding: [0,1,0,1], 153 \ }) 154 let winid = popup_create('top right', #{ 155 \ pos: 'topright', 156 \ line: 1, 157 \ col: -2, 158 \ textprop: 'popupMarker', 159 \ padding: [0,1,0,1], 160 \ }) 161 END 162 call writefile(lines, 'XtestTextpropPopupOffset') 163 let buf = RunVimInTerminal('-S XtestTextpropPopupOffset', #{rows: 12}) 164 call VerifyScreenDump(buf, 'Test_popup_textprop_off_1', {}) 165 166 " test that removing the text property closes the popups 167 call term_sendkeys(buf, ":call prop_clear(50)\<CR>") 168 call VerifyScreenDump(buf, 'Test_popup_textprop_off_2', {}) 169 170 " clean up 171 call StopVimInTerminal(buf) 172 call delete('XtestTextpropPopupOffset') 173endfunc 174 175 176" vim: shiftwidth=2 sts=2 177