popupmenu_spec.lua 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local clear, feed = helpers.clear, helpers.feed
  4. local source = helpers.source
  5. local insert = helpers.insert
  6. local meths = helpers.meths
  7. local command = helpers.command
  8. local funcs = helpers.funcs
  9. local get_pathsep = helpers.get_pathsep
  10. local eq = helpers.eq
  11. local pcall_err = helpers.pcall_err
  12. local eval = helpers.eval
  13. describe('ui/ext_popupmenu', function()
  14. local screen
  15. before_each(function()
  16. clear()
  17. screen = Screen.new(60, 8)
  18. screen:attach({rgb=true, ext_popupmenu=true})
  19. screen:set_default_attr_ids({
  20. [1] = {bold=true, foreground=Screen.colors.Blue},
  21. [2] = {bold = true},
  22. [3] = {reverse = true},
  23. [4] = {bold = true, reverse = true},
  24. [5] = {bold = true, foreground = Screen.colors.SeaGreen},
  25. [6] = {background = Screen.colors.WebGray},
  26. [7] = {background = Screen.colors.LightMagenta},
  27. })
  28. source([[
  29. function! TestComplete() abort
  30. call complete(1, [{'word':'foo', 'abbr':'fo', 'menu':'the foo', 'info':'foo-y', 'kind':'x'}, 'bar', 'spam'])
  31. return ''
  32. endfunction
  33. ]])
  34. end)
  35. local expected = {
  36. {'fo', 'x', 'the foo', 'foo-y'},
  37. {'bar', '', '', ''},
  38. {'spam', '', '', ''},
  39. }
  40. it('works', function()
  41. feed('o<C-r>=TestComplete()<CR>')
  42. screen:expect{grid=[[
  43. |
  44. foo^ |
  45. {1:~ }|
  46. {1:~ }|
  47. {1:~ }|
  48. {1:~ }|
  49. {1:~ }|
  50. {2:-- INSERT --} |
  51. ]], popupmenu={
  52. items=expected,
  53. pos=0,
  54. anchor={1,1,0},
  55. }}
  56. feed('<c-p>')
  57. screen:expect{grid=[[
  58. |
  59. ^ |
  60. {1:~ }|
  61. {1:~ }|
  62. {1:~ }|
  63. {1:~ }|
  64. {1:~ }|
  65. {2:-- INSERT --} |
  66. ]], popupmenu={
  67. items=expected,
  68. pos=-1,
  69. anchor={1,1,0},
  70. }}
  71. -- down moves the selection in the menu, but does not insert anything
  72. feed('<down><down>')
  73. screen:expect{grid=[[
  74. |
  75. ^ |
  76. {1:~ }|
  77. {1:~ }|
  78. {1:~ }|
  79. {1:~ }|
  80. {1:~ }|
  81. {2:-- INSERT --} |
  82. ]], popupmenu={
  83. items=expected,
  84. pos=1,
  85. anchor={1,1,0},
  86. }}
  87. feed('<cr>')
  88. screen:expect{grid=[[
  89. |
  90. bar^ |
  91. {1:~ }|
  92. {1:~ }|
  93. {1:~ }|
  94. {1:~ }|
  95. {1:~ }|
  96. {2:-- INSERT --} |
  97. ]]}
  98. end)
  99. it('can be controlled by API', function()
  100. feed('o<C-r>=TestComplete()<CR>')
  101. screen:expect{grid=[[
  102. |
  103. foo^ |
  104. {1:~ }|
  105. {1:~ }|
  106. {1:~ }|
  107. {1:~ }|
  108. {1:~ }|
  109. {2:-- INSERT --} |
  110. ]], popupmenu={
  111. items=expected,
  112. pos=0,
  113. anchor={1,1,0},
  114. }}
  115. meths.select_popupmenu_item(1,false,false,{})
  116. screen:expect{grid=[[
  117. |
  118. foo^ |
  119. {1:~ }|
  120. {1:~ }|
  121. {1:~ }|
  122. {1:~ }|
  123. {1:~ }|
  124. {2:-- INSERT --} |
  125. ]], popupmenu={
  126. items=expected,
  127. pos=1,
  128. anchor={1,1,0},
  129. }}
  130. meths.select_popupmenu_item(2,true,false,{})
  131. screen:expect{grid=[[
  132. |
  133. spam^ |
  134. {1:~ }|
  135. {1:~ }|
  136. {1:~ }|
  137. {1:~ }|
  138. {1:~ }|
  139. {2:-- INSERT --} |
  140. ]], popupmenu={
  141. items=expected,
  142. pos=2,
  143. anchor={1,1,0},
  144. }}
  145. meths.select_popupmenu_item(0,true,true,{})
  146. screen:expect([[
  147. |
  148. foo^ |
  149. {1:~ }|
  150. {1:~ }|
  151. {1:~ }|
  152. {1:~ }|
  153. {1:~ }|
  154. {2:-- INSERT --} |
  155. ]])
  156. feed('<c-w><C-r>=TestComplete()<CR>')
  157. screen:expect{grid=[[
  158. |
  159. foo^ |
  160. {1:~ }|
  161. {1:~ }|
  162. {1:~ }|
  163. {1:~ }|
  164. {1:~ }|
  165. {2:-- INSERT --} |
  166. ]], popupmenu={
  167. items=expected,
  168. pos=0,
  169. anchor={1,1,0},
  170. }}
  171. meths.select_popupmenu_item(-1,false,false,{})
  172. screen:expect{grid=[[
  173. |
  174. foo^ |
  175. {1:~ }|
  176. {1:~ }|
  177. {1:~ }|
  178. {1:~ }|
  179. {1:~ }|
  180. {2:-- INSERT --} |
  181. ]], popupmenu={
  182. items=expected,
  183. pos=-1,
  184. anchor={1,1,0},
  185. }}
  186. meths.select_popupmenu_item(1,true,false,{})
  187. screen:expect{grid=[[
  188. |
  189. bar^ |
  190. {1:~ }|
  191. {1:~ }|
  192. {1:~ }|
  193. {1:~ }|
  194. {1:~ }|
  195. {2:-- INSERT --} |
  196. ]], popupmenu={
  197. items=expected,
  198. pos=1,
  199. anchor={1,1,0},
  200. }}
  201. meths.select_popupmenu_item(-1,true,false,{})
  202. screen:expect{grid=[[
  203. |
  204. ^ |
  205. {1:~ }|
  206. {1:~ }|
  207. {1:~ }|
  208. {1:~ }|
  209. {1:~ }|
  210. {2:-- INSERT --} |
  211. ]], popupmenu={
  212. items=expected,
  213. pos=-1,
  214. anchor={1,1,0},
  215. }}
  216. meths.select_popupmenu_item(0,true,false,{})
  217. screen:expect{grid=[[
  218. |
  219. foo^ |
  220. {1:~ }|
  221. {1:~ }|
  222. {1:~ }|
  223. {1:~ }|
  224. {1:~ }|
  225. {2:-- INSERT --} |
  226. ]], popupmenu={
  227. items=expected,
  228. pos=0,
  229. anchor={1,1,0},
  230. }}
  231. meths.select_popupmenu_item(-1,true,true,{})
  232. screen:expect([[
  233. |
  234. ^ |
  235. {1:~ }|
  236. {1:~ }|
  237. {1:~ }|
  238. {1:~ }|
  239. {1:~ }|
  240. {2:-- INSERT --} |
  241. ]])
  242. command('imap <f1> <cmd>call nvim_select_popupmenu_item(2,v:true,v:false,{})<cr>')
  243. command('imap <f2> <cmd>call nvim_select_popupmenu_item(-1,v:false,v:false,{})<cr>')
  244. command('imap <f3> <cmd>call nvim_select_popupmenu_item(1,v:false,v:true,{})<cr>')
  245. feed('<C-r>=TestComplete()<CR>')
  246. screen:expect{grid=[[
  247. |
  248. foo^ |
  249. {1:~ }|
  250. {1:~ }|
  251. {1:~ }|
  252. {1:~ }|
  253. {1:~ }|
  254. {2:-- INSERT --} |
  255. ]], popupmenu={
  256. items=expected,
  257. pos=0,
  258. anchor={1,1,0},
  259. }}
  260. feed('<f1>')
  261. screen:expect{grid=[[
  262. |
  263. spam^ |
  264. {1:~ }|
  265. {1:~ }|
  266. {1:~ }|
  267. {1:~ }|
  268. {1:~ }|
  269. {2:-- INSERT --} |
  270. ]], popupmenu={
  271. items=expected,
  272. pos=2,
  273. anchor={1,1,0},
  274. }}
  275. feed('<f2>')
  276. screen:expect{grid=[[
  277. |
  278. spam^ |
  279. {1:~ }|
  280. {1:~ }|
  281. {1:~ }|
  282. {1:~ }|
  283. {1:~ }|
  284. {2:-- INSERT --} |
  285. ]], popupmenu={
  286. items=expected,
  287. pos=-1,
  288. anchor={1,1,0},
  289. }}
  290. feed('<f3>')
  291. screen:expect([[
  292. |
  293. bar^ |
  294. {1:~ }|
  295. {1:~ }|
  296. {1:~ }|
  297. {1:~ }|
  298. {1:~ }|
  299. {2:-- INSERT --} |
  300. ]])
  301. -- also should work for builtin popupmenu
  302. screen:set_option('ext_popupmenu', false)
  303. feed('<C-r>=TestComplete()<CR>')
  304. screen:expect([[
  305. |
  306. foo^ |
  307. {6:fo x the foo }{1: }|
  308. {7:bar }{1: }|
  309. {7:spam }{1: }|
  310. {1:~ }|
  311. {1:~ }|
  312. {2:-- INSERT --} |
  313. ]])
  314. feed('<f1>')
  315. screen:expect([[
  316. |
  317. spam^ |
  318. {7:fo x the foo }{1: }|
  319. {7:bar }{1: }|
  320. {6:spam }{1: }|
  321. {1:~ }|
  322. {1:~ }|
  323. {2:-- INSERT --} |
  324. ]])
  325. feed('<f2>')
  326. screen:expect([[
  327. |
  328. spam^ |
  329. {7:fo x the foo }{1: }|
  330. {7:bar }{1: }|
  331. {7:spam }{1: }|
  332. {1:~ }|
  333. {1:~ }|
  334. {2:-- INSERT --} |
  335. ]])
  336. feed('<f3>')
  337. screen:expect([[
  338. |
  339. bar^ |
  340. {1:~ }|
  341. {1:~ }|
  342. {1:~ }|
  343. {1:~ }|
  344. {1:~ }|
  345. {2:-- INSERT --} |
  346. ]])
  347. end)
  348. local function source_complete_month()
  349. source([[
  350. function! TestCompleteMonth() abort
  351. call complete(1, ['January', 'February', 'March', 'April',
  352. \ 'May', 'June', 'July', 'August',
  353. \ 'September', 'October', 'November', 'December'])
  354. return ''
  355. endfunction
  356. ]])
  357. end
  358. describe('pum_set_height', function()
  359. it('can set pum height', function()
  360. source_complete_month()
  361. local month_expected = {
  362. {'January', '', '', ''},
  363. {'February', '', '', ''},
  364. {'March', '', '', ''},
  365. {'April', '', '', ''},
  366. {'May', '', '', ''},
  367. {'June', '', '', ''},
  368. {'July', '', '', ''},
  369. {'August', '', '', ''},
  370. {'September', '', '', ''},
  371. {'October', '', '', ''},
  372. {'November', '', '', ''},
  373. {'December', '', '', ''},
  374. }
  375. local pum_height = 6
  376. feed('o<C-r>=TestCompleteMonth()<CR>')
  377. meths.ui_pum_set_height(pum_height)
  378. feed('<PageDown>')
  379. -- pos becomes pum_height-2 because it is subtracting 2 to keep some
  380. -- context in ins_compl_key2count()
  381. screen:expect{grid=[[
  382. |
  383. January^ |
  384. {1:~ }|
  385. {1:~ }|
  386. {1:~ }|
  387. {1:~ }|
  388. {1:~ }|
  389. {2:-- INSERT --} |
  390. ]], popupmenu={
  391. items=month_expected,
  392. pos=pum_height-2,
  393. anchor={1,1,0},
  394. }}
  395. end)
  396. it('an error occurs if set 0 or less', function()
  397. meths.ui_pum_set_height(1)
  398. eq('Expected pum height > 0',
  399. pcall_err(meths.ui_pum_set_height, 0))
  400. end)
  401. it('an error occurs when ext_popupmenu is false', function()
  402. meths.ui_pum_set_height(1)
  403. screen:set_option('ext_popupmenu', false)
  404. eq('It must support the ext_popupmenu option',
  405. pcall_err(meths.ui_pum_set_height, 1))
  406. end)
  407. end)
  408. describe('pum_set_bounds', function()
  409. it('can set pum bounds', function()
  410. source_complete_month()
  411. local month_expected = {
  412. {'January', '', '', ''},
  413. {'February', '', '', ''},
  414. {'March', '', '', ''},
  415. {'April', '', '', ''},
  416. {'May', '', '', ''},
  417. {'June', '', '', ''},
  418. {'July', '', '', ''},
  419. {'August', '', '', ''},
  420. {'September', '', '', ''},
  421. {'October', '', '', ''},
  422. {'November', '', '', ''},
  423. {'December', '', '', ''},
  424. }
  425. local pum_height = 6
  426. feed('o<C-r>=TestCompleteMonth()<CR>')
  427. meths.ui_pum_set_height(pum_height)
  428. -- set bounds w h r c
  429. meths.ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4)
  430. feed('<PageDown>')
  431. -- pos becomes pum_height-2 because it is subtracting 2 to keep some
  432. -- context in ins_compl_key2count()
  433. screen:expect{grid=[[
  434. |
  435. January^ |
  436. {1:~ }|
  437. {1:~ }|
  438. {1:~ }|
  439. {1:~ }|
  440. {1:~ }|
  441. {2:-- INSERT --} |
  442. ]], popupmenu={
  443. items=month_expected,
  444. pos=pum_height-2,
  445. anchor={1,1,0},
  446. }}
  447. end)
  448. it('no error occurs if row or col set less than 0', function()
  449. meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
  450. meths.ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0)
  451. meths.ui_pum_set_bounds(1.0, 1.0, 0.0, -1.0)
  452. end)
  453. it('an error occurs if width or height set 0 or less', function()
  454. meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
  455. eq('Expected width > 0',
  456. pcall_err(meths.ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0))
  457. eq('Expected height > 0',
  458. pcall_err(meths.ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0))
  459. end)
  460. it('an error occurs when ext_popupmenu is false', function()
  461. meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
  462. screen:set_option('ext_popupmenu', false)
  463. eq('UI must support the ext_popupmenu option',
  464. pcall_err(meths.ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5))
  465. end)
  466. end)
  467. it('<PageUP>, <PageDown> works without ui_pum_set_height', function()
  468. source_complete_month()
  469. local month_expected = {
  470. {'January', '', '', ''},
  471. {'February', '', '', ''},
  472. {'March', '', '', ''},
  473. {'April', '', '', ''},
  474. {'May', '', '', ''},
  475. {'June', '', '', ''},
  476. {'July', '', '', ''},
  477. {'August', '', '', ''},
  478. {'September', '', '', ''},
  479. {'October', '', '', ''},
  480. {'November', '', '', ''},
  481. {'December', '', '', ''},
  482. }
  483. feed('o<C-r>=TestCompleteMonth()<CR>')
  484. feed('<PageDown>')
  485. screen:expect{grid=[[
  486. |
  487. January^ |
  488. {1:~ }|
  489. {1:~ }|
  490. {1:~ }|
  491. {1:~ }|
  492. {1:~ }|
  493. {2:-- INSERT --} |
  494. ]], popupmenu={
  495. items=month_expected,
  496. pos=3,
  497. anchor={1,1,0},
  498. }}
  499. feed('<PageUp>')
  500. screen:expect{grid=[[
  501. |
  502. January^ |
  503. {1:~ }|
  504. {1:~ }|
  505. {1:~ }|
  506. {1:~ }|
  507. {1:~ }|
  508. {2:-- INSERT --} |
  509. ]], popupmenu={
  510. items=month_expected,
  511. pos=0,
  512. anchor={1,1,0},
  513. }}
  514. end)
  515. it('works with wildoptions=pum', function()
  516. screen:try_resize(32,10)
  517. command('set wildmenu')
  518. command('set wildoptions=pum')
  519. local wild_expected = {
  520. {'define', '', '', ''},
  521. {'jump', '', '', ''},
  522. {'list', '', '', ''},
  523. {'place', '', '', ''},
  524. {'undefine', '', '', ''},
  525. {'unplace', '', '', ''},
  526. }
  527. feed(':sign ')
  528. screen:expect([[
  529. |
  530. {1:~ }|
  531. {1:~ }|
  532. {1:~ }|
  533. {1:~ }|
  534. {1:~ }|
  535. {1:~ }|
  536. {1:~ }|
  537. {1:~ }|
  538. :sign ^ |
  539. ]])
  540. eq(0, funcs.wildmenumode())
  541. feed('<tab>')
  542. screen:expect{grid=[[
  543. |
  544. {1:~ }|
  545. {1:~ }|
  546. {1:~ }|
  547. {1:~ }|
  548. {1:~ }|
  549. {1:~ }|
  550. {1:~ }|
  551. {1:~ }|
  552. :sign define^ |
  553. ]], popupmenu={items=wild_expected, pos=0, anchor={1, 9, 6}}}
  554. eq(1, funcs.wildmenumode())
  555. feed('<left>')
  556. screen:expect{grid=[[
  557. |
  558. {1:~ }|
  559. {1:~ }|
  560. {1:~ }|
  561. {1:~ }|
  562. {1:~ }|
  563. {1:~ }|
  564. {1:~ }|
  565. {1:~ }|
  566. :sign ^ |
  567. ]], popupmenu={items=wild_expected, pos=-1, anchor={1, 9, 6}}}
  568. feed('<left>')
  569. screen:expect{grid=[[
  570. |
  571. {1:~ }|
  572. {1:~ }|
  573. {1:~ }|
  574. {1:~ }|
  575. {1:~ }|
  576. {1:~ }|
  577. {1:~ }|
  578. {1:~ }|
  579. :sign unplace^ |
  580. ]], popupmenu={items=wild_expected, pos=5, anchor={1, 9, 6}}}
  581. feed('x')
  582. screen:expect([[
  583. |
  584. {1:~ }|
  585. {1:~ }|
  586. {1:~ }|
  587. {1:~ }|
  588. {1:~ }|
  589. {1:~ }|
  590. {1:~ }|
  591. {1:~ }|
  592. :sign unplacex^ |
  593. ]])
  594. feed('<esc>')
  595. -- #10042: make sure shift-tab also triggers the pum
  596. feed(':sign <S-tab>')
  597. screen:expect{grid=[[
  598. |
  599. {1:~ }|
  600. {1:~ }|
  601. {1:~ }|
  602. {1:~ }|
  603. {1:~ }|
  604. {1:~ }|
  605. {1:~ }|
  606. {1:~ }|
  607. :sign unplace^ |
  608. ]], popupmenu={items=wild_expected, pos=5, anchor={1, 9, 6}}}
  609. feed('<esc>')
  610. eq(0, funcs.wildmenumode())
  611. -- check positioning with multibyte char in pattern
  612. command("e långfile1")
  613. command("sp långfile2")
  614. feed(':b lå<tab>')
  615. screen:expect{grid=[[
  616. |
  617. {1:~ }|
  618. {1:~ }|
  619. {1:~ }|
  620. {4:långfile2 }|
  621. |
  622. {1:~ }|
  623. {1:~ }|
  624. {3:långfile1 }|
  625. :b långfile1^ |
  626. ]], popupmenu={
  627. anchor = {1, 9, 3},
  628. items = {{"långfile1", "", "", "" }, {"långfile2", "", "", ""}},
  629. pos = 0,
  630. }}
  631. end)
  632. end)
  633. describe('builtin popupmenu', function()
  634. local screen
  635. before_each(function()
  636. clear()
  637. screen = Screen.new(32, 20)
  638. screen:attach()
  639. screen:set_default_attr_ids({
  640. -- popup selected item / scrollbar track
  641. ['s'] = {background = Screen.colors.WebGray},
  642. -- popup non-selected item
  643. ['n'] = {background = Screen.colors.LightMagenta},
  644. -- popup scrollbar knob
  645. ['c'] = {background = Screen.colors.Grey0},
  646. [1] = {bold = true, foreground = Screen.colors.Blue},
  647. [2] = {bold = true},
  648. [3] = {reverse = true},
  649. [4] = {bold = true, reverse = true},
  650. [5] = {bold = true, foreground = Screen.colors.SeaGreen},
  651. [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  652. })
  653. end)
  654. it('with preview-window above', function()
  655. feed(':ped<CR><c-w>4+')
  656. feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
  657. feed('<c-x><c-n>')
  658. screen:expect([[
  659. aa bb cc dd ee ff gg hh ii jj |
  660. aa |
  661. {1:~ }|
  662. {1:~ }|
  663. {1:~ }|
  664. {1:~ }|
  665. {1:~ }|
  666. {1:~ }|
  667. {3:[No Name] [Preview][+] }|
  668. aa bb cc dd ee ff gg hh ii jj |
  669. aa^ |
  670. {s:aa }{c: }{1: }|
  671. {n:bb }{c: }{1: }|
  672. {n:cc }{c: }{1: }|
  673. {n:dd }{c: }{1: }|
  674. {n:ee }{c: }{1: }|
  675. {n:ff }{c: }{1: }|
  676. {n:gg }{s: }{1: }|
  677. {n:hh }{s: }{4: }|
  678. {2:-- }{5:match 1 of 10} |
  679. ]])
  680. end)
  681. it('with preview-window below', function()
  682. feed(':ped<CR><c-w>4+<c-w>r')
  683. feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
  684. feed('<c-x><c-n>')
  685. screen:expect([[
  686. aa bb cc dd ee ff gg hh ii jj |
  687. aa^ |
  688. {s:aa }{c: }{1: }|
  689. {n:bb }{c: }{1: }|
  690. {n:cc }{c: }{1: }|
  691. {n:dd }{c: }{1: }|
  692. {n:ee }{c: }{1: }|
  693. {n:ff }{c: }{1: }|
  694. {n:gg }{s: }{1: }|
  695. {n:hh }{s: }{4: }|
  696. aa bb cc dd ee ff gg hh ii jj |
  697. aa |
  698. {1:~ }|
  699. {1:~ }|
  700. {1:~ }|
  701. {1:~ }|
  702. {1:~ }|
  703. {1:~ }|
  704. {3:[No Name] [Preview][+] }|
  705. {2:-- }{5:match 1 of 10} |
  706. ]])
  707. end)
  708. it('with preview-window above and tall and inverted', function()
  709. feed(':ped<CR><c-w>8+')
  710. feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
  711. feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
  712. feed('kk<cr>ll<cr>mm<cr>nn<cr>oo<cr>')
  713. feed('<c-x><c-n>')
  714. screen:expect([[
  715. aa |
  716. bb |
  717. cc |
  718. dd |
  719. {s:aa }{c: }{3:ew][+] }|
  720. {n:bb }{c: } |
  721. {n:cc }{c: } |
  722. {n:dd }{c: } |
  723. {n:ee }{c: } |
  724. {n:ff }{c: } |
  725. {n:gg }{c: } |
  726. {n:hh }{c: } |
  727. {n:ii }{c: } |
  728. {n:jj }{c: } |
  729. {n:kk }{c: } |
  730. {n:ll }{s: } |
  731. {n:mm }{s: } |
  732. aa^ |
  733. {4:[No Name] [+] }|
  734. {2:-- }{5:match 1 of 15} |
  735. ]])
  736. end)
  737. it('with preview-window above and short and inverted', function()
  738. feed(':ped<CR><c-w>4+')
  739. feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
  740. feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
  741. feed('<c-x><c-n>')
  742. screen:expect([[
  743. aa |
  744. bb |
  745. cc |
  746. dd |
  747. ee |
  748. ff |
  749. gg |
  750. hh |
  751. {s:aa }{c: }{3:ew][+] }|
  752. {n:bb }{c: } |
  753. {n:cc }{c: } |
  754. {n:dd }{c: } |
  755. {n:ee }{c: } |
  756. {n:ff }{c: } |
  757. {n:gg }{c: } |
  758. {n:hh }{c: } |
  759. {n:ii }{s: } |
  760. aa^ |
  761. {4:[No Name] [+] }|
  762. {2:-- }{5:match 1 of 10} |
  763. ]])
  764. end)
  765. it('with preview-window below and inverted', function()
  766. feed(':ped<CR><c-w>4+<c-w>r')
  767. feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
  768. feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
  769. feed('<c-x><c-n>')
  770. screen:expect([[
  771. {s:aa }{c: } |
  772. {n:bb }{c: } |
  773. {n:cc }{c: } |
  774. {n:dd }{c: } |
  775. {n:ee }{c: } |
  776. {n:ff }{c: } |
  777. {n:gg }{s: } |
  778. {n:hh }{s: } |
  779. aa^ |
  780. {4:[No Name] [+] }|
  781. aa |
  782. bb |
  783. cc |
  784. dd |
  785. ee |
  786. ff |
  787. gg |
  788. hh |
  789. {3:[No Name] [Preview][+] }|
  790. {2:-- }{5:match 1 of 10} |
  791. ]])
  792. end)
  793. it('with vsplits', function()
  794. insert('aaa aab aac\n')
  795. feed(':vsplit<cr>')
  796. screen:expect([[
  797. aaa aab aac {3:│}aaa aab aac|
  798. ^ {3:│} |
  799. {1:~ }{3:│}{1:~ }|
  800. {1:~ }{3:│}{1:~ }|
  801. {1:~ }{3:│}{1:~ }|
  802. {1:~ }{3:│}{1:~ }|
  803. {1:~ }{3:│}{1:~ }|
  804. {1:~ }{3:│}{1:~ }|
  805. {1:~ }{3:│}{1:~ }|
  806. {1:~ }{3:│}{1:~ }|
  807. {1:~ }{3:│}{1:~ }|
  808. {1:~ }{3:│}{1:~ }|
  809. {1:~ }{3:│}{1:~ }|
  810. {1:~ }{3:│}{1:~ }|
  811. {1:~ }{3:│}{1:~ }|
  812. {1:~ }{3:│}{1:~ }|
  813. {1:~ }{3:│}{1:~ }|
  814. {1:~ }{3:│}{1:~ }|
  815. {4:[No Name] [+] }{3:<Name] [+] }|
  816. :vsplit |
  817. ]])
  818. feed('ibbb a<c-x><c-n>')
  819. screen:expect([[
  820. aaa aab aac {3:│}aaa aab aac|
  821. bbb aaa^ {3:│}bbb aaa |
  822. {1:~ }{s: aaa }{1: }{3:│}{1:~ }|
  823. {1:~ }{n: aab }{1: }{3:│}{1:~ }|
  824. {1:~ }{n: aac }{1: }{3:│}{1:~ }|
  825. {1:~ }{3:│}{1:~ }|
  826. {1:~ }{3:│}{1:~ }|
  827. {1:~ }{3:│}{1:~ }|
  828. {1:~ }{3:│}{1:~ }|
  829. {1:~ }{3:│}{1:~ }|
  830. {1:~ }{3:│}{1:~ }|
  831. {1:~ }{3:│}{1:~ }|
  832. {1:~ }{3:│}{1:~ }|
  833. {1:~ }{3:│}{1:~ }|
  834. {1:~ }{3:│}{1:~ }|
  835. {1:~ }{3:│}{1:~ }|
  836. {1:~ }{3:│}{1:~ }|
  837. {1:~ }{3:│}{1:~ }|
  838. {4:[No Name] [+] }{3:<Name] [+] }|
  839. {2:-- }{5:match 1 of 3} |
  840. ]])
  841. feed('<esc><c-w><c-w>oc a<c-x><c-n>')
  842. screen:expect([[
  843. aaa aab aac{3:│}aaa aab aac |
  844. bbb aaa {3:│}bbb aaa |
  845. c aaa {3:│}c aaa^ |
  846. {1:~ }{3:│}{1:~}{s: aaa }{1: }|
  847. {1:~ }{3:│}{1:~}{n: aab }{1: }|
  848. {1:~ }{3:│}{1:~}{n: aac }{1: }|
  849. {1:~ }{3:│}{1:~ }|
  850. {1:~ }{3:│}{1:~ }|
  851. {1:~ }{3:│}{1:~ }|
  852. {1:~ }{3:│}{1:~ }|
  853. {1:~ }{3:│}{1:~ }|
  854. {1:~ }{3:│}{1:~ }|
  855. {1:~ }{3:│}{1:~ }|
  856. {1:~ }{3:│}{1:~ }|
  857. {1:~ }{3:│}{1:~ }|
  858. {1:~ }{3:│}{1:~ }|
  859. {1:~ }{3:│}{1:~ }|
  860. {1:~ }{3:│}{1:~ }|
  861. {3:<Name] [+] }{4:[No Name] [+] }|
  862. {2:-- }{5:match 1 of 3} |
  863. ]])
  864. end)
  865. it('with split and scroll', function()
  866. screen:try_resize(60,14)
  867. command("split")
  868. command("set completeopt+=noinsert")
  869. command("set mouse=a")
  870. insert([[
  871. Lorem ipsum dolor sit amet, consectetur
  872. adipisicing elit, sed do eiusmod tempor
  873. incididunt ut labore et dolore magna aliqua.
  874. Ut enim ad minim veniam, quis nostrud
  875. exercitation ullamco laboris nisi ut aliquip ex
  876. ea commodo consequat. Duis aute irure dolor in
  877. reprehenderit in voluptate velit esse cillum
  878. dolore eu fugiat nulla pariatur. Excepteur sint
  879. occaecat cupidatat non proident, sunt in culpa
  880. qui officia deserunt mollit anim id est
  881. laborum.
  882. ]])
  883. screen:expect([[
  884. reprehenderit in voluptate velit esse cillum |
  885. dolore eu fugiat nulla pariatur. Excepteur sint |
  886. occaecat cupidatat non proident, sunt in culpa |
  887. qui officia deserunt mollit anim id est |
  888. laborum. |
  889. ^ |
  890. {4:[No Name] [+] }|
  891. Lorem ipsum dolor sit amet, consectetur |
  892. adipisicing elit, sed do eiusmod tempor |
  893. incididunt ut labore et dolore magna aliqua. |
  894. Ut enim ad minim veniam, quis nostrud |
  895. exercitation ullamco laboris nisi ut aliquip ex |
  896. {3:[No Name] [+] }|
  897. |
  898. ]])
  899. feed('ggOEst <c-x><c-p>')
  900. screen:expect([[
  901. Est ^ |
  902. L{n: sunt }{s: }sit amet, consectetur |
  903. a{n: in }{s: }sed do eiusmod tempor |
  904. i{n: culpa }{s: }re et dolore magna aliqua. |
  905. U{n: qui }{s: }eniam, quis nostrud |
  906. e{n: officia }{s: }co laboris nisi ut aliquip ex |
  907. {4:[No}{n: deserunt }{s: }{4: }|
  908. L{n: mollit }{s: }sit amet, consectetur |
  909. a{n: anim }{s: }sed do eiusmod tempor |
  910. i{n: id }{s: }re et dolore magna aliqua. |
  911. U{n: est }{s: }eniam, quis nostrud |
  912. e{n: laborum }{c: }co laboris nisi ut aliquip ex |
  913. {3:[No}{s: Est }{c: }{3: }|
  914. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  915. ]])
  916. meths.input_mouse('wheel', 'down', '', 0, 9, 40)
  917. screen:expect([[
  918. Est ^ |
  919. L{n: sunt }{s: }sit amet, consectetur |
  920. a{n: in }{s: }sed do eiusmod tempor |
  921. i{n: culpa }{s: }re et dolore magna aliqua. |
  922. U{n: qui }{s: }eniam, quis nostrud |
  923. e{n: officia }{s: }co laboris nisi ut aliquip ex |
  924. {4:[No}{n: deserunt }{s: }{4: }|
  925. U{n: mollit }{s: }eniam, quis nostrud |
  926. e{n: anim }{s: }co laboris nisi ut aliquip ex |
  927. e{n: id }{s: }at. Duis aute irure dolor in |
  928. r{n: est }{s: }oluptate velit esse cillum |
  929. d{n: laborum }{c: }ulla pariatur. Excepteur sint |
  930. {3:[No}{s: Est }{c: }{3: }|
  931. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  932. ]])
  933. feed('e')
  934. screen:expect([[
  935. Est e^ |
  936. L{n: elit } sit amet, consectetur |
  937. a{n: eiusmod } sed do eiusmod tempor |
  938. i{n: et }ore et dolore magna aliqua. |
  939. U{n: enim }veniam, quis nostrud |
  940. e{n: exercitation }mco laboris nisi ut aliquip ex |
  941. {4:[No}{n: ex }{4: }|
  942. U{n: ea }veniam, quis nostrud |
  943. e{n: esse }mco laboris nisi ut aliquip ex |
  944. e{n: eu }uat. Duis aute irure dolor in |
  945. r{s: est }voluptate velit esse cillum |
  946. dolore eu fugiat nulla pariatur. Excepteur sint |
  947. {3:[No Name] [+] }|
  948. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  949. ]])
  950. meths.input_mouse('wheel', 'up', '', 0, 9, 40)
  951. screen:expect([[
  952. Est e^ |
  953. L{n: elit } sit amet, consectetur |
  954. a{n: eiusmod } sed do eiusmod tempor |
  955. i{n: et }ore et dolore magna aliqua. |
  956. U{n: enim }veniam, quis nostrud |
  957. e{n: exercitation }mco laboris nisi ut aliquip ex |
  958. {4:[No}{n: ex }{4: }|
  959. L{n: ea } sit amet, consectetur |
  960. a{n: esse } sed do eiusmod tempor |
  961. i{n: eu }ore et dolore magna aliqua. |
  962. U{s: est }veniam, quis nostrud |
  963. exercitation ullamco laboris nisi ut aliquip ex |
  964. {3:[No Name] [+] }|
  965. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  966. ]])
  967. feed('s')
  968. screen:expect([[
  969. Est es^ |
  970. L{n: esse } sit amet, consectetur |
  971. a{s: est } sed do eiusmod tempor |
  972. incididunt ut labore et dolore magna aliqua. |
  973. Ut enim ad minim veniam, quis nostrud |
  974. exercitation ullamco laboris nisi ut aliquip ex |
  975. {4:[No Name] [+] }|
  976. Lorem ipsum dolor sit amet, consectetur |
  977. adipisicing elit, sed do eiusmod tempor |
  978. incididunt ut labore et dolore magna aliqua. |
  979. Ut enim ad minim veniam, quis nostrud |
  980. exercitation ullamco laboris nisi ut aliquip ex |
  981. {3:[No Name] [+] }|
  982. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  983. ]])
  984. meths.input_mouse('wheel', 'down', '', 0, 9, 40)
  985. screen:expect([[
  986. Est es^ |
  987. L{n: esse } sit amet, consectetur |
  988. a{s: est } sed do eiusmod tempor |
  989. incididunt ut labore et dolore magna aliqua. |
  990. Ut enim ad minim veniam, quis nostrud |
  991. exercitation ullamco laboris nisi ut aliquip ex |
  992. {4:[No Name] [+] }|
  993. Ut enim ad minim veniam, quis nostrud |
  994. exercitation ullamco laboris nisi ut aliquip ex |
  995. ea commodo consequat. Duis aute irure dolor in |
  996. reprehenderit in voluptate velit esse cillum |
  997. dolore eu fugiat nulla pariatur. Excepteur sint |
  998. {3:[No Name] [+] }|
  999. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  1000. ]])
  1001. feed('<bs>')
  1002. screen:expect([[
  1003. Est e^ |
  1004. L{n: elit } sit amet, consectetur |
  1005. a{n: eiusmod } sed do eiusmod tempor |
  1006. i{n: et }ore et dolore magna aliqua. |
  1007. U{n: enim }veniam, quis nostrud |
  1008. e{n: exercitation }mco laboris nisi ut aliquip ex |
  1009. {4:[No}{n: ex }{4: }|
  1010. U{n: ea }veniam, quis nostrud |
  1011. e{n: esse }mco laboris nisi ut aliquip ex |
  1012. e{n: eu }uat. Duis aute irure dolor in |
  1013. r{s: est }voluptate velit esse cillum |
  1014. dolore eu fugiat nulla pariatur. Excepteur sint |
  1015. {3:[No Name] [+] }|
  1016. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  1017. ]])
  1018. feed('<c-p>')
  1019. screen:expect([[
  1020. Est eu^ |
  1021. L{n: elit } sit amet, consectetur |
  1022. a{n: eiusmod } sed do eiusmod tempor |
  1023. i{n: et }ore et dolore magna aliqua. |
  1024. U{n: enim }veniam, quis nostrud |
  1025. e{n: exercitation }mco laboris nisi ut aliquip ex |
  1026. {4:[No}{n: ex }{4: }|
  1027. U{n: ea }veniam, quis nostrud |
  1028. e{n: esse }mco laboris nisi ut aliquip ex |
  1029. e{s: eu }uat. Duis aute irure dolor in |
  1030. r{n: est }voluptate velit esse cillum |
  1031. dolore eu fugiat nulla pariatur. Excepteur sint |
  1032. {3:[No Name] [+] }|
  1033. {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} |
  1034. ]])
  1035. meths.input_mouse('wheel', 'down', '', 0, 9, 40)
  1036. screen:expect([[
  1037. Est eu^ |
  1038. L{n: elit } sit amet, consectetur |
  1039. a{n: eiusmod } sed do eiusmod tempor |
  1040. i{n: et }ore et dolore magna aliqua. |
  1041. U{n: enim }veniam, quis nostrud |
  1042. e{n: exercitation }mco laboris nisi ut aliquip ex |
  1043. {4:[No}{n: ex }{4: }|
  1044. r{n: ea }voluptate velit esse cillum |
  1045. d{n: esse }nulla pariatur. Excepteur sint |
  1046. o{s: eu }t non proident, sunt in culpa |
  1047. q{n: est }unt mollit anim id est |
  1048. laborum. |
  1049. {3:[No Name] [+] }|
  1050. {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} |
  1051. ]])
  1052. funcs.complete(4, {'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'})
  1053. screen:expect([[
  1054. Est eu^ |
  1055. {s: ea }t amet, consectetur |
  1056. {n: eeeeeeeeeeeeeeeeee }d do eiusmod tempor |
  1057. {n: ei } et dolore magna aliqua. |
  1058. {n: eo }iam, quis nostrud |
  1059. {n: eu } laboris nisi ut aliquip ex |
  1060. {4:[N}{n: ey }{4: }|
  1061. {n: eå }uptate velit esse cillum |
  1062. {n: eä }la pariatur. Excepteur sint |
  1063. {n: eö }on proident, sunt in culpa |
  1064. qui officia deserunt mollit anim id est |
  1065. laborum. |
  1066. {3:[No Name] [+] }|
  1067. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} |
  1068. ]])
  1069. funcs.complete(4, {'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'})
  1070. screen:expect([[
  1071. Est eu^ |
  1072. {s: ea }r sit amet, consectetur |
  1073. {n: eee }, sed do eiusmod tempor |
  1074. {n: ei }bore et dolore magna aliqua. |
  1075. {n: eo } veniam, quis nostrud |
  1076. {n: eu }amco laboris nisi ut aliquip ex |
  1077. {4:[N}{n: ey }{4: }|
  1078. {n: eå } voluptate velit esse cillum |
  1079. {n: eä } nulla pariatur. Excepteur sint |
  1080. {n: eö }at non proident, sunt in culpa |
  1081. qui officia deserunt mollit anim id est |
  1082. laborum. |
  1083. {3:[No Name] [+] }|
  1084. {2:-- INSERT --} |
  1085. ]])
  1086. feed('<c-n>')
  1087. screen:expect([[
  1088. Esteee^ |
  1089. {n: ea }r sit amet, consectetur |
  1090. {s: eee }, sed do eiusmod tempor |
  1091. {n: ei }bore et dolore magna aliqua. |
  1092. {n: eo } veniam, quis nostrud |
  1093. {n: eu }amco laboris nisi ut aliquip ex |
  1094. {4:[N}{n: ey }{4: }|
  1095. {n: eå } voluptate velit esse cillum |
  1096. {n: eä } nulla pariatur. Excepteur sint |
  1097. {n: eö }at non proident, sunt in culpa |
  1098. qui officia deserunt mollit anim id est |
  1099. laborum. |
  1100. {3:[No Name] [+] }|
  1101. {2:-- INSERT --} |
  1102. ]])
  1103. funcs.complete(6, {'foo', 'bar'})
  1104. screen:expect([[
  1105. Esteee^ |
  1106. Lo{s: foo }sit amet, consectetur |
  1107. ad{n: bar }sed do eiusmod tempor |
  1108. incididunt ut labore et dolore magna aliqua. |
  1109. Ut enim ad minim veniam, quis nostrud |
  1110. exercitation ullamco laboris nisi ut aliquip ex |
  1111. {4:[No Name] [+] }|
  1112. reprehenderit in voluptate velit esse cillum |
  1113. dolore eu fugiat nulla pariatur. Excepteur sint |
  1114. occaecat cupidatat non proident, sunt in culpa |
  1115. qui officia deserunt mollit anim id est |
  1116. laborum. |
  1117. {3:[No Name] [+] }|
  1118. {2:-- INSERT --} |
  1119. ]])
  1120. feed('<c-y>')
  1121. screen:expect([[
  1122. Esteefoo^ |
  1123. Lorem ipsum dolor sit amet, consectetur |
  1124. adipisicing elit, sed do eiusmod tempor |
  1125. incididunt ut labore et dolore magna aliqua. |
  1126. Ut enim ad minim veniam, quis nostrud |
  1127. exercitation ullamco laboris nisi ut aliquip ex |
  1128. {4:[No Name] [+] }|
  1129. reprehenderit in voluptate velit esse cillum |
  1130. dolore eu fugiat nulla pariatur. Excepteur sint |
  1131. occaecat cupidatat non proident, sunt in culpa |
  1132. qui officia deserunt mollit anim id est |
  1133. laborum. |
  1134. {3:[No Name] [+] }|
  1135. {2:-- INSERT --} |
  1136. ]])
  1137. end)
  1138. it('can be moved due to wrap or resize', function()
  1139. feed('isome long prefix before the ')
  1140. command("set completeopt+=noinsert,noselect")
  1141. command("set linebreak")
  1142. funcs.complete(29, {'word', 'choice', 'text', 'thing'})
  1143. screen:expect([[
  1144. some long prefix before the ^ |
  1145. {1:~ }{n: word }|
  1146. {1:~ }{n: choice}|
  1147. {1:~ }{n: text }|
  1148. {1:~ }{n: thing }|
  1149. {1:~ }|
  1150. {1:~ }|
  1151. {1:~ }|
  1152. {1:~ }|
  1153. {1:~ }|
  1154. {1:~ }|
  1155. {1:~ }|
  1156. {1:~ }|
  1157. {1:~ }|
  1158. {1:~ }|
  1159. {1:~ }|
  1160. {1:~ }|
  1161. {1:~ }|
  1162. {1:~ }|
  1163. {2:-- INSERT --} |
  1164. ]])
  1165. feed('<c-p>')
  1166. screen:expect([[
  1167. some long prefix before the |
  1168. thing^ |
  1169. {n:word }{1: }|
  1170. {n:choice }{1: }|
  1171. {n:text }{1: }|
  1172. {s:thing }{1: }|
  1173. {1:~ }|
  1174. {1:~ }|
  1175. {1:~ }|
  1176. {1:~ }|
  1177. {1:~ }|
  1178. {1:~ }|
  1179. {1:~ }|
  1180. {1:~ }|
  1181. {1:~ }|
  1182. {1:~ }|
  1183. {1:~ }|
  1184. {1:~ }|
  1185. {1:~ }|
  1186. {2:-- INSERT --} |
  1187. ]])
  1188. feed('<c-p>')
  1189. screen:expect([[
  1190. some long prefix before the text|
  1191. {1:^~ }{n: word }|
  1192. {1:~ }{n: choice}|
  1193. {1:~ }{s: text }|
  1194. {1:~ }{n: thing }|
  1195. {1:~ }|
  1196. {1:~ }|
  1197. {1:~ }|
  1198. {1:~ }|
  1199. {1:~ }|
  1200. {1:~ }|
  1201. {1:~ }|
  1202. {1:~ }|
  1203. {1:~ }|
  1204. {1:~ }|
  1205. {1:~ }|
  1206. {1:~ }|
  1207. {1:~ }|
  1208. {1:~ }|
  1209. {2:-- INSERT --} |
  1210. ]])
  1211. screen:try_resize(30,8)
  1212. screen:expect([[
  1213. some long prefix before the |
  1214. text^ |
  1215. {n:word }{1: }|
  1216. {n:choice }{1: }|
  1217. {s:text }{1: }|
  1218. {n:thing }{1: }|
  1219. {1:~ }|
  1220. {2:-- INSERT --} |
  1221. ]])
  1222. screen:try_resize(50,8)
  1223. screen:expect([[
  1224. some long prefix before the text^ |
  1225. {1:~ }{n: word }{1: }|
  1226. {1:~ }{n: choice }{1: }|
  1227. {1:~ }{s: text }{1: }|
  1228. {1:~ }{n: thing }{1: }|
  1229. {1:~ }|
  1230. {1:~ }|
  1231. {2:-- INSERT --} |
  1232. ]])
  1233. screen:try_resize(25,10)
  1234. screen:expect([[
  1235. some long prefix before |
  1236. the text^ |
  1237. {1:~ }{n: word }{1: }|
  1238. {1:~ }{n: choice }{1: }|
  1239. {1:~ }{s: text }{1: }|
  1240. {1:~ }{n: thing }{1: }|
  1241. {1:~ }|
  1242. {1:~ }|
  1243. {1:~ }|
  1244. {2:-- INSERT --} |
  1245. ]])
  1246. screen:try_resize(12,5)
  1247. screen:expect([[
  1248. some long |
  1249. prefix |
  1250. bef{n: word } |
  1251. tex{n: }^ |
  1252. {2:-- INSERT -} |
  1253. ]])
  1254. -- can't draw the pum, but check we don't crash
  1255. screen:try_resize(12,2)
  1256. screen:expect([[
  1257. text^ |
  1258. {2:-- INSERT -} |
  1259. ]])
  1260. -- but state is preserved, pum reappears
  1261. screen:try_resize(20,8)
  1262. screen:expect([[
  1263. some long prefix |
  1264. before the text^ |
  1265. {1:~ }{n: word }{1: }|
  1266. {1:~ }{n: choice }{1: }|
  1267. {1:~ }{s: text }{1: }|
  1268. {1:~ }{n: thing }{1: }|
  1269. {1:~ }|
  1270. {2:-- INSERT --} |
  1271. ]])
  1272. end)
  1273. it('with VimResized autocmd', function()
  1274. feed('isome long prefix before the ')
  1275. command("set completeopt+=noinsert,noselect")
  1276. command("autocmd VimResized * redraw!")
  1277. command("set linebreak")
  1278. funcs.complete(29, {'word', 'choice', 'text', 'thing'})
  1279. screen:expect([[
  1280. some long prefix before the ^ |
  1281. {1:~ }{n: word }|
  1282. {1:~ }{n: choice}|
  1283. {1:~ }{n: text }|
  1284. {1:~ }{n: thing }|
  1285. {1:~ }|
  1286. {1:~ }|
  1287. {1:~ }|
  1288. {1:~ }|
  1289. {1:~ }|
  1290. {1:~ }|
  1291. {1:~ }|
  1292. {1:~ }|
  1293. {1:~ }|
  1294. {1:~ }|
  1295. {1:~ }|
  1296. {1:~ }|
  1297. {1:~ }|
  1298. {1:~ }|
  1299. {2:-- INSERT --} |
  1300. ]])
  1301. screen:try_resize(16,10)
  1302. screen:expect([[
  1303. some long |
  1304. prefix before |
  1305. the ^ |
  1306. {1:~ }{n: word }|
  1307. {1:~ }{n: choice }|
  1308. {1:~ }{n: text }|
  1309. {1:~ }{n: thing }|
  1310. {1:~ }|
  1311. {1:~ }|
  1312. {2:-- INSERT --} |
  1313. ]])
  1314. end)
  1315. it('with rightleft window', function()
  1316. command("set rl wildoptions+=pum")
  1317. feed('isome rightleft ')
  1318. screen:expect([[
  1319. ^ tfelthgir emos|
  1320. {1: ~}|
  1321. {1: ~}|
  1322. {1: ~}|
  1323. {1: ~}|
  1324. {1: ~}|
  1325. {1: ~}|
  1326. {1: ~}|
  1327. {1: ~}|
  1328. {1: ~}|
  1329. {1: ~}|
  1330. {1: ~}|
  1331. {1: ~}|
  1332. {1: ~}|
  1333. {1: ~}|
  1334. {1: ~}|
  1335. {1: ~}|
  1336. {1: ~}|
  1337. {1: ~}|
  1338. {2:-- INSERT --} |
  1339. ]])
  1340. command("set completeopt+=noinsert,noselect")
  1341. funcs.complete(16, {'word', 'choice', 'text', 'thing'})
  1342. screen:expect([[
  1343. ^ tfelthgir emos|
  1344. {1: }{n: drow}{1: ~}|
  1345. {1: }{n: eciohc}{1: ~}|
  1346. {1: }{n: txet}{1: ~}|
  1347. {1: }{n: gniht}{1: ~}|
  1348. {1: ~}|
  1349. {1: ~}|
  1350. {1: ~}|
  1351. {1: ~}|
  1352. {1: ~}|
  1353. {1: ~}|
  1354. {1: ~}|
  1355. {1: ~}|
  1356. {1: ~}|
  1357. {1: ~}|
  1358. {1: ~}|
  1359. {1: ~}|
  1360. {1: ~}|
  1361. {1: ~}|
  1362. {2:-- INSERT --} |
  1363. ]])
  1364. feed('<c-n>')
  1365. screen:expect([[
  1366. ^ drow tfelthgir emos|
  1367. {1: }{s: drow}{1: ~}|
  1368. {1: }{n: eciohc}{1: ~}|
  1369. {1: }{n: txet}{1: ~}|
  1370. {1: }{n: gniht}{1: ~}|
  1371. {1: ~}|
  1372. {1: ~}|
  1373. {1: ~}|
  1374. {1: ~}|
  1375. {1: ~}|
  1376. {1: ~}|
  1377. {1: ~}|
  1378. {1: ~}|
  1379. {1: ~}|
  1380. {1: ~}|
  1381. {1: ~}|
  1382. {1: ~}|
  1383. {1: ~}|
  1384. {1: ~}|
  1385. {2:-- INSERT --} |
  1386. ]])
  1387. feed('<c-y>')
  1388. screen:expect([[
  1389. ^ drow tfelthgir emos|
  1390. {1: ~}|
  1391. {1: ~}|
  1392. {1: ~}|
  1393. {1: ~}|
  1394. {1: ~}|
  1395. {1: ~}|
  1396. {1: ~}|
  1397. {1: ~}|
  1398. {1: ~}|
  1399. {1: ~}|
  1400. {1: ~}|
  1401. {1: ~}|
  1402. {1: ~}|
  1403. {1: ~}|
  1404. {1: ~}|
  1405. {1: ~}|
  1406. {1: ~}|
  1407. {1: ~}|
  1408. {2:-- INSERT --} |
  1409. ]])
  1410. -- not rightleft on the cmdline
  1411. feed('<esc>:sign ')
  1412. screen:expect{grid=[[
  1413. drow tfelthgir emos|
  1414. {1: ~}|
  1415. {1: ~}|
  1416. {1: ~}|
  1417. {1: ~}|
  1418. {1: ~}|
  1419. {1: ~}|
  1420. {1: ~}|
  1421. {1: ~}|
  1422. {1: ~}|
  1423. {1: ~}|
  1424. {1: ~}|
  1425. {1: ~}|
  1426. {1: ~}|
  1427. {1: ~}|
  1428. {1: ~}|
  1429. {1: ~}|
  1430. {1: ~}|
  1431. {1: ~}|
  1432. :sign ^ |
  1433. ]]}
  1434. feed('<tab>')
  1435. screen:expect{grid=[[
  1436. drow tfelthgir emos|
  1437. {1: ~}|
  1438. {1: ~}|
  1439. {1: ~}|
  1440. {1: ~}|
  1441. {1: ~}|
  1442. {1: ~}|
  1443. {1: ~}|
  1444. {1: ~}|
  1445. {1: ~}|
  1446. {1: ~}|
  1447. {1: ~}|
  1448. {1: ~}|
  1449. {1: }{s: define }{1: ~}|
  1450. {1: }{n: jump }{1: ~}|
  1451. {1: }{n: list }{1: ~}|
  1452. {1: }{n: place }{1: ~}|
  1453. {1: }{n: undefine }{1: ~}|
  1454. {1: }{n: unplace }{1: ~}|
  1455. :sign define^ |
  1456. ]]}
  1457. end)
  1458. it('with multiline messages', function()
  1459. screen:try_resize(40,8)
  1460. feed('ixx<cr>')
  1461. command('imap <f2> <cmd>echoerr "very"\\|echoerr "much"\\|echoerr "error"<cr>')
  1462. funcs.complete(1, {'word', 'choice', 'text', 'thing'})
  1463. screen:expect([[
  1464. xx |
  1465. word^ |
  1466. {s:word }{1: }|
  1467. {n:choice }{1: }|
  1468. {n:text }{1: }|
  1469. {n:thing }{1: }|
  1470. {1:~ }|
  1471. {2:-- INSERT --} |
  1472. ]])
  1473. feed('<f2>')
  1474. screen:expect([[
  1475. xx |
  1476. word |
  1477. {s:word }{1: }|
  1478. {4: }|
  1479. {6:very} |
  1480. {6:much} |
  1481. {6:error} |
  1482. {5:Press ENTER or type command to continue}^ |
  1483. ]])
  1484. feed('<cr>')
  1485. screen:expect([[
  1486. xx |
  1487. word^ |
  1488. {s:word }{1: }|
  1489. {n:choice }{1: }|
  1490. {n:text }{1: }|
  1491. {n:thing }{1: }|
  1492. {1:~ }|
  1493. {2:-- INSERT --} |
  1494. ]])
  1495. feed('<c-n>')
  1496. screen:expect([[
  1497. xx |
  1498. choice^ |
  1499. {n:word }{1: }|
  1500. {s:choice }{1: }|
  1501. {n:text }{1: }|
  1502. {n:thing }{1: }|
  1503. {1:~ }|
  1504. {2:-- INSERT --} |
  1505. ]])
  1506. command("split")
  1507. screen:expect([[
  1508. xx |
  1509. choice^ |
  1510. {n:word }{1: }|
  1511. {s:choice }{4: }|
  1512. {n:text } |
  1513. {n:thing } |
  1514. {3:[No Name] [+] }|
  1515. {2:-- INSERT --} |
  1516. ]])
  1517. meths.input_mouse('wheel', 'down', '', 0, 6, 15)
  1518. screen:expect{grid=[[
  1519. xx |
  1520. choice^ |
  1521. {n:word }{1: }|
  1522. {s:choice }{4: }|
  1523. {n:text } |
  1524. {n:thing }{1: }|
  1525. {3:[No Name] [+] }|
  1526. {2:-- INSERT --} |
  1527. ]], unchanged=true}
  1528. end)
  1529. it('with kind, menu and abbr attributes', function()
  1530. screen:try_resize(40,8)
  1531. feed('ixx ')
  1532. funcs.complete(4, {{word='wordey', kind= 'x', menu='extrainfo'}, 'thing', {word='secret', abbr='sneaky', menu='bar'}})
  1533. screen:expect([[
  1534. xx wordey^ |
  1535. {1:~ }{s: wordey x extrainfo }{1: }|
  1536. {1:~ }{n: thing }{1: }|
  1537. {1:~ }{n: sneaky bar }{1: }|
  1538. {1:~ }|
  1539. {1:~ }|
  1540. {1:~ }|
  1541. {2:-- INSERT --} |
  1542. ]])
  1543. feed('<c-p>')
  1544. screen:expect([[
  1545. xx ^ |
  1546. {1:~ }{n: wordey x extrainfo }{1: }|
  1547. {1:~ }{n: thing }{1: }|
  1548. {1:~ }{n: sneaky bar }{1: }|
  1549. {1:~ }|
  1550. {1:~ }|
  1551. {1:~ }|
  1552. {2:-- INSERT --} |
  1553. ]])
  1554. feed('<c-p>')
  1555. screen:expect([[
  1556. xx secret^ |
  1557. {1:~ }{n: wordey x extrainfo }{1: }|
  1558. {1:~ }{n: thing }{1: }|
  1559. {1:~ }{s: sneaky bar }{1: }|
  1560. {1:~ }|
  1561. {1:~ }|
  1562. {1:~ }|
  1563. {2:-- INSERT --} |
  1564. ]])
  1565. feed('<esc>')
  1566. screen:expect([[
  1567. xx secre^t |
  1568. {1:~ }|
  1569. {1:~ }|
  1570. {1:~ }|
  1571. {1:~ }|
  1572. {1:~ }|
  1573. {1:~ }|
  1574. |
  1575. ]])
  1576. end)
  1577. it('wildoptions=pum', function()
  1578. screen:try_resize(32,10)
  1579. command('set wildmenu')
  1580. command('set wildoptions=pum')
  1581. feed(':sign ')
  1582. screen:expect([[
  1583. |
  1584. {1:~ }|
  1585. {1:~ }|
  1586. {1:~ }|
  1587. {1:~ }|
  1588. {1:~ }|
  1589. {1:~ }|
  1590. {1:~ }|
  1591. {1:~ }|
  1592. :sign ^ |
  1593. ]])
  1594. feed('<tab>')
  1595. screen:expect([[
  1596. |
  1597. {1:~ }|
  1598. {1:~ }|
  1599. {1:~ }{s: define }{1: }|
  1600. {1:~ }{n: jump }{1: }|
  1601. {1:~ }{n: list }{1: }|
  1602. {1:~ }{n: place }{1: }|
  1603. {1:~ }{n: undefine }{1: }|
  1604. {1:~ }{n: unplace }{1: }|
  1605. :sign define^ |
  1606. ]])
  1607. feed('<left>')
  1608. screen:expect([[
  1609. |
  1610. {1:~ }|
  1611. {1:~ }|
  1612. {1:~ }{n: define }{1: }|
  1613. {1:~ }{n: jump }{1: }|
  1614. {1:~ }{n: list }{1: }|
  1615. {1:~ }{n: place }{1: }|
  1616. {1:~ }{n: undefine }{1: }|
  1617. {1:~ }{n: unplace }{1: }|
  1618. :sign ^ |
  1619. ]])
  1620. feed('<left>')
  1621. screen:expect([[
  1622. |
  1623. {1:~ }|
  1624. {1:~ }|
  1625. {1:~ }{n: define }{1: }|
  1626. {1:~ }{n: jump }{1: }|
  1627. {1:~ }{n: list }{1: }|
  1628. {1:~ }{n: place }{1: }|
  1629. {1:~ }{n: undefine }{1: }|
  1630. {1:~ }{s: unplace }{1: }|
  1631. :sign unplace^ |
  1632. ]])
  1633. feed('x')
  1634. screen:expect([[
  1635. |
  1636. {1:~ }|
  1637. {1:~ }|
  1638. {1:~ }|
  1639. {1:~ }|
  1640. {1:~ }|
  1641. {1:~ }|
  1642. {1:~ }|
  1643. {1:~ }|
  1644. :sign unplacex^ |
  1645. ]])
  1646. feed('<esc>')
  1647. -- check positioning with multibyte char in pattern
  1648. command("e långfile1")
  1649. command("sp långfile2")
  1650. feed(':b lå<tab>')
  1651. screen:expect([[
  1652. |
  1653. {1:~ }|
  1654. {1:~ }|
  1655. {1:~ }|
  1656. {4:långfile2 }|
  1657. |
  1658. {1:~ }|
  1659. {1:~ }{s: långfile1 }{1: }|
  1660. {3:lå}{n: långfile2 }{3: }|
  1661. :b långfile1^ |
  1662. ]])
  1663. -- check doesn't crash on screen resize
  1664. screen:try_resize(20,6)
  1665. screen:expect([[
  1666. |
  1667. {1:~ }|
  1668. {4:långfile2 }|
  1669. {s: långfile1 } |
  1670. {3:lå}{n: långfile2 }{3: }|
  1671. :b långfile1^ |
  1672. ]])
  1673. screen:try_resize(50,15)
  1674. screen:expect([[
  1675. |
  1676. {1:~ }|
  1677. {4:långfile2 }|
  1678. |
  1679. {1:~ }|
  1680. {1:~ }|
  1681. {1:~ }|
  1682. {1:~ }|
  1683. {1:~ }|
  1684. {1:~ }|
  1685. {1:~ }|
  1686. {1:~ }|
  1687. {1:~ }{s: långfile1 }{1: }|
  1688. {3:lå}{n: långfile2 }{3: }|
  1689. :b långfile1^ |
  1690. ]])
  1691. -- position is calculated correctly with "longest"
  1692. feed('<esc>')
  1693. command('set wildmode=longest:full,full')
  1694. feed(':b lå<tab>')
  1695. screen:expect([[
  1696. |
  1697. {1:~ }|
  1698. {4:långfile2 }|
  1699. |
  1700. {1:~ }|
  1701. {1:~ }|
  1702. {1:~ }|
  1703. {1:~ }|
  1704. {1:~ }|
  1705. {1:~ }|
  1706. {1:~ }|
  1707. {1:~ }|
  1708. {1:~ }{n: långfile1 }{1: }|
  1709. {3:lå}{n: långfile2 }{3: }|
  1710. :b långfile^ |
  1711. ]])
  1712. -- special case: when patterns ends with "/", show menu items aligned
  1713. -- after the "/"
  1714. feed('<esc>')
  1715. command("close")
  1716. command('set wildmode=full')
  1717. command("cd test/functional/fixtures/")
  1718. feed(':e compdir/<tab>')
  1719. screen:expect([[
  1720. |
  1721. {1:~ }|
  1722. {1:~ }|
  1723. {1:~ }|
  1724. {1:~ }|
  1725. {1:~ }|
  1726. {1:~ }|
  1727. {1:~ }|
  1728. {1:~ }|
  1729. {1:~ }|
  1730. {1:~ }|
  1731. {1:~ }|
  1732. {1:~ }{s: file1 }{1: }|
  1733. {1:~ }{n: file2 }{1: }|
  1734. :e compdir]]..get_pathsep()..[[file1^ |
  1735. ]])
  1736. end)
  1737. it('wildoptions=pum with scrolled mesages ', function()
  1738. screen:try_resize(40,10)
  1739. command('set wildmenu')
  1740. command('set wildoptions=pum')
  1741. feed(':echoerr "fail"|echoerr "error"<cr>')
  1742. screen:expect{grid=[[
  1743. |
  1744. {1:~ }|
  1745. {1:~ }|
  1746. {1:~ }|
  1747. {1:~ }|
  1748. {1:~ }|
  1749. {4: }|
  1750. {6:fail} |
  1751. {6:error} |
  1752. {5:Press ENTER or type command to continue}^ |
  1753. ]]}
  1754. feed(':sign <tab>')
  1755. screen:expect{grid=[[
  1756. |
  1757. {1:~ }|
  1758. {1:~ }|
  1759. {1:~ }{s: define }{1: }|
  1760. {1:~ }{n: jump }{1: }|
  1761. {1:~ }{n: list }{1: }|
  1762. {4: }{n: place }{4: }|
  1763. {6:fail} {n: undefine } |
  1764. {6:error}{n: unplace } |
  1765. :sign define^ |
  1766. ]]}
  1767. feed('d')
  1768. screen:expect{grid=[[
  1769. |
  1770. {1:~ }|
  1771. {1:~ }|
  1772. {1:~ }|
  1773. {1:~ }|
  1774. {1:~ }|
  1775. {4: }|
  1776. {6:fail} |
  1777. {6:error} |
  1778. :sign defined^ |
  1779. ]]}
  1780. end)
  1781. it('wildoptions=pum and wildmode=longest,full #11622', function()
  1782. screen:try_resize(30,8)
  1783. command('set wildmenu')
  1784. command('set wildoptions=pum')
  1785. command('set wildmode=longest,full')
  1786. feed(':sign u<tab>')
  1787. screen:expect{grid=[[
  1788. |
  1789. {1:~ }|
  1790. {1:~ }|
  1791. {1:~ }|
  1792. {1:~ }|
  1793. {1:~ }|
  1794. {1:~ }|
  1795. :sign un^ |
  1796. ]]}
  1797. eq(0, funcs.wildmenumode())
  1798. feed('<tab>')
  1799. screen:expect{grid=[[
  1800. |
  1801. {1:~ }|
  1802. {1:~ }|
  1803. {1:~ }|
  1804. {1:~ }|
  1805. {1:~ }{s: undefine }{1: }|
  1806. {1:~ }{n: unplace }{1: }|
  1807. :sign undefine^ |
  1808. ]]}
  1809. eq(1, funcs.wildmenumode())
  1810. end)
  1811. it("'pumblend' RGB-color", function()
  1812. screen:try_resize(60,14)
  1813. screen:set_default_attr_ids({
  1814. [1] = {background = Screen.colors.Yellow},
  1815. [2] = {bold = true, reverse = true},
  1816. [3] = {bold = true, foreground = Screen.colors.Brown},
  1817. [4] = {foreground = Screen.colors.Blue1},
  1818. [5] = {reverse = true},
  1819. [6] = {background = Screen.colors.Gray55, foreground = Screen.colors.Grey45},
  1820. [7] = {background = Screen.colors.Gray55, foreground = Screen.colors.Grey0},
  1821. [8] = {background = tonumber('0x191919'), foreground = Screen.colors.Grey0},
  1822. [9] = {background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8e5')},
  1823. [10] = {background = tonumber('0xffc1ff'), foreground = Screen.colors.Grey0},
  1824. [11] = {foreground = tonumber('0xffc1ff'), background = tonumber('0xe5a8e5'), bold = true},
  1825. [12] = {foreground = Screen.colors.Grey55, background = Screen.colors.Gray45, bold = true},
  1826. [13] = {background = tonumber('0xffc1e5'), foreground = Screen.colors.Grey0},
  1827. [14] = {background = tonumber('0xffc1e5'), foreground = tonumber('0xe5a8e5')},
  1828. [15] = {background = tonumber('0xffc1ff'), foreground = tonumber('0x080202')},
  1829. [16] = {background = tonumber('0xffc1ff'), bold = true, foreground = tonumber('0xf6ace9')},
  1830. [17] = {background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8ff')},
  1831. [18] = {background = tonumber('0xe5a8e5'), foreground = tonumber('0xffc1ff')},
  1832. [19] = {background = Screen.colors.Gray45, foreground = Screen.colors.Grey55},
  1833. [20] = {bold = true},
  1834. [21] = {bold = true, foreground = Screen.colors.SeaGreen4},
  1835. [22] = {background = Screen.colors.WebGray},
  1836. [23] = {background = Screen.colors.Grey0},
  1837. [24] = {background = Screen.colors.LightMagenta},
  1838. [25] = {background = Screen.colors.Gray75, foreground = Screen.colors.Grey25},
  1839. [26] = {background = Screen.colors.Gray75, foreground = Screen.colors.Grey0},
  1840. [27] = {background = Screen.colors.Gray50, foreground = Screen.colors.Grey0},
  1841. [28] = {background = tonumber('0xffddff'), foreground = tonumber('0x7f5d7f')},
  1842. [29] = {background = tonumber('0xffddff'), foreground = Screen.colors.Grey0},
  1843. [30] = {foreground = tonumber('0xffddff'), background = tonumber('0x7f5d7f'), bold = true},
  1844. [31] = {foreground = tonumber('0xffddff'), background = Screen.colors.Grey0, bold = true},
  1845. [32] = {foreground = Screen.colors.Gray75, background = Screen.colors.Grey25, bold = true},
  1846. [33] = {background = tonumber('0xffdd7f'), foreground = Screen.colors.Grey0},
  1847. [34] = {background = tonumber('0xffdd7f'), foreground = tonumber('0x7f5d7f')},
  1848. [35] = {background = tonumber('0xffddff'), bold = true, foreground = tonumber('0x290a0a')},
  1849. [36] = {background = tonumber('0xffddff'), bold = true, foreground = tonumber('0xd27294')},
  1850. [37] = {background = tonumber('0xffddff'), foreground = tonumber('0x7f5dff')},
  1851. [38] = {background = tonumber('0x7f5d7f'), foreground = tonumber('0xffddff')},
  1852. [39] = {background = Screen.colors.Grey0, foreground = tonumber('0xffddff')},
  1853. [40] = {background = Screen.colors.Gray25, foreground = Screen.colors.Grey75},
  1854. [41] = {background = tonumber('0xffddff'), foreground = tonumber('0x00003f')},
  1855. [42] = {foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5')},
  1856. [43] = {background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f')},
  1857. [44] = {foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f')},
  1858. [45] = {background = Screen.colors.WebGray, blend=0},
  1859. })
  1860. command('syntax on')
  1861. command('set mouse=a')
  1862. command('set pumblend=10')
  1863. insert([[
  1864. Lorem ipsum dolor sit amet, consectetur
  1865. adipisicing elit, sed do eiusmod tempor
  1866. incididunt ut labore et dolore magna aliqua.
  1867. Ut enim ad minim veniam, quis nostrud
  1868. exercitation ullamco laboris nisi ut aliquip ex
  1869. ea commodo consequat. Duis aute irure dolor in
  1870. reprehenderit in voluptate velit esse cillum
  1871. dolore eu fugiat nulla pariatur. Excepteur sint
  1872. occaecat cupidatat non proident, sunt in culpa
  1873. qui officia deserunt mollit anim id est
  1874. laborum.]])
  1875. command('match Statement /el/')
  1876. command('2match Comment /ut/')
  1877. command('1')
  1878. command('split')
  1879. command('/ol')
  1880. screen:expect([[
  1881. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1882. adipisicing elit, sed do eiusmod tempor |
  1883. ^incididunt ut labore et d{1:ol}ore magna aliqua. |
  1884. Ut enim ad minim veniam, quis nostrud |
  1885. exercitation ullamco laboris nisi ut aliquip ex |
  1886. ea commodo consequat. Duis aute irure d{1:ol}or in |
  1887. {2:[No Name] [+] }|
  1888. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1889. adipisicing {3:el}it, sed do eiusmod tempor |
  1890. incididunt {4:ut} labore et d{1:ol}ore magna aliqua. |
  1891. Ut enim ad minim veniam, quis nostrud |
  1892. exercitation ullamco laboris nisi {4:ut} aliquip ex |
  1893. {5:[No Name] [+] }|
  1894. |
  1895. ]])
  1896. feed('Obla bla <c-x><c-n>')
  1897. screen:expect([[
  1898. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1899. adipisicing elit, sed do eiusmod tempor |
  1900. bla bla incididunt^ |
  1901. incidid{6:u}{7:incididunt}{6:re et}{8: }d{1:ol}ore magna aliqua. |
  1902. Ut enim{9: }{10:ut}{9: minim veniam}{6:,} quis nostrud |
  1903. exercit{9:a}{10:labore}{9:llamco la}{6:b}oris nisi ut aliquip ex |
  1904. {2:[No Nam}{11:e}{42:et}{11:[+] }{12: }{2: }|
  1905. Lorem i{9:p}{10:dolor}{13:e}{14:l}{9:or sit a}{6:m}et, consectetur |
  1906. adipisi{9:c}{10:magn}{15:a}{16:l}{9:it, sed d}{6:o} eiusmod tempor |
  1907. bla bla{9: }{10:aliqua}{9:dunt }{6: } |
  1908. incidid{9:u}{10:Ut}{9: }{17:ut}{9: labore et}{6: }d{1:ol}ore magna aliqua. |
  1909. Ut enim{9: }{10:enim}{9:inim veniam}{6:,} quis nostrud |
  1910. {5:[No Nam}{18:e}{42:ad}{18:[+] }{19: }{5: }|
  1911. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  1912. ]])
  1913. command('set pumblend=0')
  1914. screen:expect([[
  1915. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1916. adipisicing elit, sed do eiusmod tempor |
  1917. bla bla incididunt^ |
  1918. incidid{22: incididunt }{23: }d{1:ol}ore magna aliqua. |
  1919. Ut enim{24: ut }{22: } quis nostrud |
  1920. exercit{24: labore }{22: }oris nisi ut aliquip ex |
  1921. {2:[No Nam}{24: et }{22: }{2: }|
  1922. Lorem i{24: dolore }{22: }et, consectetur |
  1923. adipisi{24: magna }{22: } eiusmod tempor |
  1924. bla bla{24: aliqua }{22: } |
  1925. incidid{24: Ut }{22: }d{1:ol}ore magna aliqua. |
  1926. Ut enim{24: enim }{22: } quis nostrud |
  1927. {5:[No Nam}{24: ad }{22: }{5: }|
  1928. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  1929. ]])
  1930. command('set pumblend=50')
  1931. screen:expect([[
  1932. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1933. adipisicing elit, sed do eiusmod tempor |
  1934. bla bla incididunt^ |
  1935. incidid{25:u}{26:incididunt}{25:re et}{27: }d{1:ol}ore magna aliqua. |
  1936. Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
  1937. exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
  1938. {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
  1939. Lorem i{28:p}{29:dolor}{33:e}{34:l}{28:or sit a}{25:m}et, consectetur |
  1940. adipisi{28:c}{29:magn}{35:a}{36:l}{28:it, sed d}{25:o} eiusmod tempor |
  1941. bla bla{28: }{29:aliqua}{28:dunt }{25: } |
  1942. incidid{28:u}{29:Ut}{28: }{37:ut}{28: labore et}{25: }d{1:ol}ore magna aliqua. |
  1943. Ut enim{28: }{29:enim}{28:inim veniam}{25:,} quis nostrud |
  1944. {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
  1945. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  1946. ]])
  1947. meths.input_mouse('wheel', 'down', '', 0, 9, 40)
  1948. screen:expect([[
  1949. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1950. adipisicing elit, sed do eiusmod tempor |
  1951. bla bla incididunt^ |
  1952. incidid{25:u}{26:incididunt}{25:re et}{27: }d{1:ol}ore magna aliqua. |
  1953. Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
  1954. exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
  1955. {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
  1956. incidid{28:u}{29:dol}{41:or}{29:e}{28:labore et}{25: }d{1:ol}ore magna aliqua. |
  1957. Ut enim{28: }{29:magna}{28:nim veniam}{25:,} quis nostrud |
  1958. exercit{28:a}{29:aliqua}{28:llamco la}{25:b}oris nisi {4:ut} aliquip ex |
  1959. ea comm{28:o}{29:Ut}{28: consequat. D}{25:u}is a{4:ut}e irure d{1:ol}or in |
  1960. reprehe{28:n}{29:enim}{28:t in v}{34:ol}{28:upt}{25:a}te v{3:el}it esse cillum |
  1961. {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
  1962. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  1963. ]])
  1964. -- can disable blending for indiviual attribute. For instance current
  1965. -- selected item. (also tests that `hi Pmenu*` take immediate effect)
  1966. command('hi PMenuSel blend=0')
  1967. screen:expect([[
  1968. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1969. adipisicing elit, sed do eiusmod tempor |
  1970. bla bla incididunt^ |
  1971. incidid{45: incididunt }{27: }d{1:ol}ore magna aliqua. |
  1972. Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
  1973. exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
  1974. {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
  1975. incidid{28:u}{29:dol}{41:or}{29:e}{28:labore et}{25: }d{1:ol}ore magna aliqua. |
  1976. Ut enim{28: }{29:magna}{28:nim veniam}{25:,} quis nostrud |
  1977. exercit{28:a}{29:aliqua}{28:llamco la}{25:b}oris nisi {4:ut} aliquip ex |
  1978. ea comm{28:o}{29:Ut}{28: consequat. D}{25:u}is a{4:ut}e irure d{1:ol}or in |
  1979. reprehe{28:n}{29:enim}{28:t in v}{34:ol}{28:upt}{25:a}te v{3:el}it esse cillum |
  1980. {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
  1981. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  1982. ]])
  1983. feed('<c-e>')
  1984. screen:expect([[
  1985. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1986. adipisicing elit, sed do eiusmod tempor |
  1987. bla bla ^ |
  1988. incididunt ut labore et d{1:ol}ore magna aliqua. |
  1989. Ut enim ad minim veniam, quis nostrud |
  1990. exercitation ullamco laboris nisi ut aliquip ex |
  1991. {2:[No Name] [+] }|
  1992. incididunt {4:ut} labore et d{1:ol}ore magna aliqua. |
  1993. Ut enim ad minim veniam, quis nostrud |
  1994. exercitation ullamco laboris nisi {4:ut} aliquip ex |
  1995. ea commodo consequat. Duis a{4:ut}e irure d{1:ol}or in |
  1996. reprehenderit in v{1:ol}uptate v{3:el}it esse cillum |
  1997. {5:[No Name] [+] }|
  1998. {20:-- INSERT --} |
  1999. ]])
  2000. end)
  2001. it("'pumblend' 256-color (non-RGB)", function()
  2002. screen:detach()
  2003. screen = Screen.new(60, 8)
  2004. screen:attach({rgb=false, ext_popupmenu=false})
  2005. screen:set_default_attr_ids({
  2006. [1] = {foreground = Screen.colors.Grey0, background = tonumber('0x000007')},
  2007. [2] = {foreground = tonumber('0x000055'), background = tonumber('0x000007')},
  2008. [3] = {foreground = tonumber('0x00008f'), background = Screen.colors.Grey0},
  2009. [4] = {foreground = Screen.colors.Grey0, background = tonumber('0x0000e1')},
  2010. [5] = {foreground = tonumber('0x0000d1'), background = tonumber('0x0000e1')},
  2011. [6] = {foreground = Screen.colors.NavyBlue, background = tonumber('0x0000f8')},
  2012. [7] = {foreground = tonumber('0x0000a5'), background = tonumber('0x0000f8')},
  2013. [8] = {foreground = tonumber('0x00000c')},
  2014. [9] = {bold = true},
  2015. [10] = {foreground = tonumber('0x000002')},
  2016. })
  2017. command('set notermguicolors pumblend=10')
  2018. insert([[
  2019. Lorem ipsum dolor sit amet, consectetur
  2020. adipisicing elit, sed do eiusmod tempor
  2021. incididunt ut labore et dolore magna aliqua.
  2022. Ut enim ad minim veniam, quis nostrud
  2023. laborum.]])
  2024. feed('ggOdo<c-x><c-n>')
  2025. screen:expect([[
  2026. dolor^ |
  2027. {1:dolor}{2: ipsum dol}or sit amet, consectetur |
  2028. {4:do}{5:ipisicing eli}t, sed do eiusmod tempor |
  2029. {4:dolore}{5:dunt ut l}abore et dolore magna aliqua. |
  2030. Ut enim ad minim veniam, quis nostrud |
  2031. laborum. |
  2032. {8:~ }|
  2033. {9:-- Keyword Local completion (^N^P) }{10:match 1 of 3} |
  2034. ]])
  2035. end)
  2036. it("'pumheight'", function()
  2037. screen:try_resize(32,8)
  2038. feed('isome long prefix before the ')
  2039. command("set completeopt+=noinsert,noselect")
  2040. command("set linebreak")
  2041. command("set pumheight=2")
  2042. funcs.complete(29, {'word', 'choice', 'text', 'thing'})
  2043. screen:expect([[
  2044. some long prefix before the ^ |
  2045. {1:~ }{n: word }{c: }|
  2046. {1:~ }{n: choice}{s: }|
  2047. {1:~ }|
  2048. {1:~ }|
  2049. {1:~ }|
  2050. {1:~ }|
  2051. {2:-- INSERT --} |
  2052. ]])
  2053. end)
  2054. it("'pumwidth'", function()
  2055. screen:try_resize(32,8)
  2056. feed('isome long prefix before the ')
  2057. command("set completeopt+=noinsert,noselect")
  2058. command("set linebreak")
  2059. command("set pumwidth=8")
  2060. funcs.complete(29, {'word', 'choice', 'text', 'thing'})
  2061. screen:expect([[
  2062. some long prefix before the ^ |
  2063. {1:~ }{n: word }|
  2064. {1:~ }{n: choice}|
  2065. {1:~ }{n: text }|
  2066. {1:~ }{n: thing }|
  2067. {1:~ }|
  2068. {1:~ }|
  2069. {2:-- INSERT --} |
  2070. ]])
  2071. end)
  2072. it('does not crash when displayed in the last column with rightleft (#12032)', function()
  2073. local col = 30
  2074. local items = {'word', 'choice', 'text', 'thing'}
  2075. local max_len = 0
  2076. for _, v in ipairs(items) do
  2077. max_len = max_len < #v and #v or max_len
  2078. end
  2079. screen:try_resize(col, 8)
  2080. command('set rightleft')
  2081. command('call setline(1, repeat(" ", &columns - '..max_len..'))')
  2082. feed('$i')
  2083. funcs.complete(col - max_len, items)
  2084. feed('<c-y>')
  2085. eq(2, eval('1+1'))
  2086. end)
  2087. end)