Mercurial > vim
comparison src/testdir/test_popupwin.vim @ 18396:ba5d8c5d77d7 v8.1.2192
patch 8.1.2192: cannot easily fill the info popup asynchronously
Commit: https://github.com/vim/vim/commit/dca7abe79cc4f0933473c3e4bcc75b46cc2c48fd
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 20 18:17:57 2019 +0200
patch 8.1.2192: cannot easily fill the info popup asynchronously
Problem: Cannot easily fill the info popup asynchronously.
Solution: Add the "popuphidden" value to 'completeopt'. (closes https://github.com/vim/vim/issues/4924)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 20 Oct 2019 18:30:04 +0200 |
parents | a776385eac9f |
children | 21c25bee9df8 |
comparison
equal
deleted
inserted
replaced
18395:dbfbbb32cf07 | 18396:ba5d8c5d77d7 |
---|---|
2496 call setline(1, 'text text text text text text text ') | 2496 call setline(1, 'text text text text text text text ') |
2497 func ChangeColor() | 2497 func ChangeColor() |
2498 let id = popup_findinfo() | 2498 let id = popup_findinfo() |
2499 eval id->popup_setoptions(#{highlight: 'InfoPopup'}) | 2499 eval id->popup_setoptions(#{highlight: 'InfoPopup'}) |
2500 endfunc | 2500 endfunc |
2501 | |
2502 func InfoHidden() | |
2503 set completepopup=height:4,border:off,align:menu | |
2504 set completeopt-=popup completeopt+=popuphidden | |
2505 au CompleteChanged * call HandleChange() | |
2506 endfunc | |
2507 | |
2508 let s:counter = 0 | |
2509 func HandleChange() | |
2510 let s:counter += 1 | |
2511 let selected = complete_info(['selected']).selected | |
2512 if selected <= 0 | |
2513 " First time: do nothing, info remains hidden | |
2514 return | |
2515 endif | |
2516 if selected == 1 | |
2517 " Second time: show info right away | |
2518 let id = popup_findinfo() | |
2519 if id | |
2520 call popup_settext(id, 'immediate info ' .. s:counter) | |
2521 call popup_show(id) | |
2522 endif | |
2523 else | |
2524 " Third time: show info after a short delay | |
2525 call timer_start(100, 'ShowInfo') | |
2526 endif | |
2527 endfunc | |
2528 | |
2529 func ShowInfo(...) | |
2530 let id = popup_findinfo() | |
2531 if id | |
2532 call popup_settext(id, 'async info ' .. s:counter) | |
2533 call popup_show(id) | |
2534 endif | |
2535 endfunc | |
2501 END | 2536 END |
2502 return lines | 2537 return lines |
2503 endfunc | 2538 endfunc |
2504 | 2539 |
2505 func Test_popupmenu_info_border() | 2540 func Test_popupmenu_info_border() |
2576 call term_sendkeys(buf, "Gotest text test text\<C-X>\<C-U>") | 2611 call term_sendkeys(buf, "Gotest text test text\<C-X>\<C-U>") |
2577 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_3', {}) | 2612 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_3', {}) |
2578 | 2613 |
2579 call StopVimInTerminal(buf) | 2614 call StopVimInTerminal(buf) |
2580 call delete('XtestInfoPopupNb') | 2615 call delete('XtestInfoPopupNb') |
2616 endfunc | |
2617 | |
2618 func Test_popupmenu_info_hidden() | |
2619 CheckScreendump | |
2620 | |
2621 let lines = Get_popupmenu_lines() | |
2622 call add(lines, 'call InfoHidden()') | |
2623 call writefile(lines, 'XtestInfoPopupHidden') | |
2624 | |
2625 let buf = RunVimInTerminal('-S XtestInfoPopupHidden', #{rows: 14}) | |
2626 call term_wait(buf, 50) | |
2627 | |
2628 call term_sendkeys(buf, "A\<C-X>\<C-U>") | |
2629 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_1', {}) | |
2630 | |
2631 call term_sendkeys(buf, "\<C-N>") | |
2632 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_2', {}) | |
2633 | |
2634 call term_sendkeys(buf, "\<C-N>") | |
2635 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_3', {}) | |
2636 | |
2637 call term_sendkeys(buf, "\<Esc>") | |
2638 call StopVimInTerminal(buf) | |
2639 call delete('XtestInfoPopupHidden') | |
2581 endfunc | 2640 endfunc |
2582 | 2641 |
2583 func Test_popupwin_recycle_bnr() | 2642 func Test_popupwin_recycle_bnr() |
2584 let bufnr = popup_notification('nothing wrong', {})->winbufnr() | 2643 let bufnr = popup_notification('nothing wrong', {})->winbufnr() |
2585 call popup_clear() | 2644 call popup_clear() |