comparison src/testdir/test_cmdline.vim @ 27875:ae38d2e81fca v8.2.4463

patch 8.2.4463: completion only uses strict matching Commit: https://github.com/vim/vim/commit/38b85cb4d7216705058708bacbc25ab90cd61595 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Feb 24 13:28:41 2022 +0000 patch 8.2.4463: completion only uses strict matching Problem: Completion only uses strict matching. Solution: Add the "fuzzy" item for 'wildoptions'. (Yegappan Lakshmanan, closes #9803)
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Feb 2022 14:30:05 +0100
parents 515ce8e07bf2
children 76e2115dddb8
comparison
equal deleted inserted replaced
27874:f4a227222e7a 27875:ae38d2e81fca
1570 call assert_equal(1, winnr('$')) 1570 call assert_equal(1, winnr('$'))
1571 1571
1572 " opening command window twice should fail 1572 " opening command window twice should fail
1573 call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")') 1573 call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")')
1574 call assert_equal(1, winnr('$')) 1574 call assert_equal(1, winnr('$'))
1575 endfunc
1576
1577 func Test_cmdwin_tabpage()
1578 tabedit
1579 call assert_fails("silent norm q/g :I\<Esc>", 'E11:')
1580 tabclose!
1575 endfunc 1581 endfunc
1576 1582
1577 func Test_cmdwin_interrupted() 1583 func Test_cmdwin_interrupted()
1578 CheckFeature cmdwin 1584 CheckFeature cmdwin
1579 CheckScreendump 1585 CheckScreendump
2436 call assert_equal("\"dlist 10 /pat\\\t", @:) 2442 call assert_equal("\"dlist 10 /pat\\\t", @:)
2437 call feedkeys(":dlist 10 /pat/ | chist\<Tab>\<C-B>\"\<CR>", 'xt') 2443 call feedkeys(":dlist 10 /pat/ | chist\<Tab>\<C-B>\"\<CR>", 'xt')
2438 call assert_equal("\"dlist 10 /pat/ | chistory", @:) 2444 call assert_equal("\"dlist 10 /pat/ | chistory", @:)
2439 endfunc 2445 endfunc
2440 2446
2447 " Test for 'fuzzy' in 'wildoptions' (fuzzy completion)
2448 func Test_wildoptions_fuzzy()
2449 " argument list (only for :argdel)
2450 argadd change.py count.py charge.py
2451 set wildoptions&
2452 call feedkeys(":argdel cge\<C-A>\<C-B>\"\<CR>", 'tx')
2453 call assert_equal('"argdel cge', @:)
2454 set wildoptions=fuzzy
2455 call feedkeys(":argdel cge\<C-A>\<C-B>\"\<CR>", 'tx')
2456 call assert_equal('"argdel change.py charge.py', @:)
2457 %argdelete
2458
2459 " autocmd group name fuzzy completion
2460 set wildoptions&
2461 augroup MyFuzzyGroup
2462 augroup END
2463 call feedkeys(":augroup mfg\<Tab>\<C-B>\"\<CR>", 'tx')
2464 call assert_equal('"augroup mfg', @:)
2465 call feedkeys(":augroup My*p\<Tab>\<C-B>\"\<CR>", 'tx')
2466 call assert_equal('"augroup MyFuzzyGroup', @:)
2467 set wildoptions=fuzzy
2468 call feedkeys(":augroup mfg\<Tab>\<C-B>\"\<CR>", 'tx')
2469 call assert_equal('"augroup MyFuzzyGroup', @:)
2470 call feedkeys(":augroup My*p\<Tab>\<C-B>\"\<CR>", 'tx')
2471 call assert_equal('"augroup My*p', @:)
2472 augroup! MyFuzzyGroup
2473
2474 " buffer name fuzzy completion
2475 set wildoptions&
2476 edit SomeFile.txt
2477 enew
2478 call feedkeys(":b SF\<Tab>\<C-B>\"\<CR>", 'tx')
2479 call assert_equal('"b SF', @:)
2480 call feedkeys(":b S*File.txt\<Tab>\<C-B>\"\<CR>", 'tx')
2481 call assert_equal('"b SomeFile.txt', @:)
2482 set wildoptions=fuzzy
2483 call feedkeys(":b SF\<Tab>\<C-B>\"\<CR>", 'tx')
2484 call assert_equal('"b SomeFile.txt', @:)
2485 call feedkeys(":b S*File.txt\<Tab>\<C-B>\"\<CR>", 'tx')
2486 call assert_equal('"b S*File.txt', @:)
2487 %bw!
2488
2489 " buffer name (full path) fuzzy completion
2490 if has('unix')
2491 set wildoptions&
2492 call mkdir('Xcmd/Xstate/Xfile.js', 'p')
2493 edit Xcmd/Xstate/Xfile.js
2494 cd Xcmd/Xstate
2495 enew
2496 call feedkeys(":b CmdStateFile\<Tab>\<C-B>\"\<CR>", 'tx')
2497 call assert_equal('"b CmdStateFile', @:)
2498 set wildoptions=fuzzy
2499 call feedkeys(":b CmdStateFile\<Tab>\<C-B>\"\<CR>", 'tx')
2500 call assert_match('Xcmd/Xstate/Xfile.js$', @:)
2501 cd -
2502 call delete('Xcmd', 'rf')
2503 endif
2504
2505 " :behave suboptions fuzzy completion
2506 set wildoptions&
2507 call feedkeys(":behave xm\<Tab>\<C-B>\"\<CR>", 'tx')
2508 call assert_equal('"behave xm', @:)
2509 call feedkeys(":behave xt*m\<Tab>\<C-B>\"\<CR>", 'tx')
2510 call assert_equal('"behave xterm', @:)
2511 set wildoptions=fuzzy
2512 call feedkeys(":behave xm\<Tab>\<C-B>\"\<CR>", 'tx')
2513 call assert_equal('"behave xterm', @:)
2514 call feedkeys(":behave xt*m\<Tab>\<C-B>\"\<CR>", 'tx')
2515 call assert_equal('"behave xt*m', @:)
2516 let g:Sline = ''
2517 call feedkeys(":behave win\<C-D>\<F4>\<C-B>\"\<CR>", 'tx')
2518 call assert_equal('mswin', g:Sline)
2519 call assert_equal('"behave win', @:)
2520
2521 " colorscheme name fuzzy completion - NOT supported
2522
2523 " built-in command name fuzzy completion
2524 set wildoptions&
2525 call feedkeys(":sbwin\<Tab>\<C-B>\"\<CR>", 'tx')
2526 call assert_equal('"sbwin', @:)
2527 call feedkeys(":sbr*d\<Tab>\<C-B>\"\<CR>", 'tx')
2528 call assert_equal('"sbrewind', @:)
2529 set wildoptions=fuzzy
2530 call feedkeys(":sbwin\<Tab>\<C-B>\"\<CR>", 'tx')
2531 call assert_equal('"sbrewind', @:)
2532 call feedkeys(":sbr*d\<Tab>\<C-B>\"\<CR>", 'tx')
2533 call assert_equal('"sbr*d', @:)
2534
2535 " compiler name fuzzy completion - NOT supported
2536
2537 " :cscope suboptions fuzzy completion
2538 if has('cscope')
2539 set wildoptions&
2540 call feedkeys(":cscope ret\<Tab>\<C-B>\"\<CR>", 'tx')
2541 call assert_equal('"cscope ret', @:)
2542 call feedkeys(":cscope re*t\<Tab>\<C-B>\"\<CR>", 'tx')
2543 call assert_equal('"cscope reset', @:)
2544 set wildoptions=fuzzy
2545 call feedkeys(":cscope ret\<Tab>\<C-B>\"\<CR>", 'tx')
2546 call assert_equal('"cscope reset', @:)
2547 call feedkeys(":cscope re*t\<Tab>\<C-B>\"\<CR>", 'tx')
2548 call assert_equal('"cscope re*t', @:)
2549 endif
2550
2551 " :diffget/:diffput buffer name fuzzy completion
2552 new SomeBuffer
2553 diffthis
2554 new OtherBuffer
2555 diffthis
2556 set wildoptions&
2557 call feedkeys(":diffget sbuf\<Tab>\<C-B>\"\<CR>", 'tx')
2558 call assert_equal('"diffget sbuf', @:)
2559 call feedkeys(":diffput sbuf\<Tab>\<C-B>\"\<CR>", 'tx')
2560 call assert_equal('"diffput sbuf', @:)
2561 set wildoptions=fuzzy
2562 call feedkeys(":diffget sbuf\<Tab>\<C-B>\"\<CR>", 'tx')
2563 call assert_equal('"diffget SomeBuffer', @:)
2564 call feedkeys(":diffput sbuf\<Tab>\<C-B>\"\<CR>", 'tx')
2565 call assert_equal('"diffput SomeBuffer', @:)
2566 %bw!
2567
2568 " directory name fuzzy completion - NOT supported
2569
2570 " environment variable name fuzzy completion
2571 set wildoptions&
2572 call feedkeys(":echo $VUT\<Tab>\<C-B>\"\<CR>", 'tx')
2573 call assert_equal('"echo $VUT', @:)
2574 set wildoptions=fuzzy
2575 call feedkeys(":echo $VUT\<Tab>\<C-B>\"\<CR>", 'tx')
2576 call assert_equal('"echo $VIMRUNTIME', @:)
2577
2578 " autocmd event fuzzy completion
2579 set wildoptions&
2580 call feedkeys(":autocmd BWout\<Tab>\<C-B>\"\<CR>", 'tx')
2581 call assert_equal('"autocmd BWout', @:)
2582 set wildoptions=fuzzy
2583 call feedkeys(":autocmd BWout\<Tab>\<C-B>\"\<CR>", 'tx')
2584 call assert_equal('"autocmd BufWipeout', @:)
2585
2586 " vim expression fuzzy completion
2587 let g:PerPlaceCount = 10
2588 set wildoptions&
2589 call feedkeys(":let c = ppc\<Tab>\<C-B>\"\<CR>", 'tx')
2590 call assert_equal('"let c = ppc', @:)
2591 set wildoptions=fuzzy
2592 call feedkeys(":let c = ppc\<Tab>\<C-B>\"\<CR>", 'tx')
2593 call assert_equal('"let c = PerPlaceCount', @:)
2594
2595 " file name fuzzy completion - NOT supported
2596
2597 " files in path fuzzy completion - NOT supported
2598
2599 " filetype name fuzzy completion - NOT supported
2600
2601 " user defined function name completion
2602 set wildoptions&
2603 call feedkeys(":call Test_w_fuz\<Tab>\<C-B>\"\<CR>", 'tx')
2604 call assert_equal('"call Test_w_fuz', @:)
2605 set wildoptions=fuzzy
2606 call feedkeys(":call Test_w_fuz\<Tab>\<C-B>\"\<CR>", 'tx')
2607 call assert_equal('"call Test_wildoptions_fuzzy()', @:)
2608
2609 " user defined command name completion
2610 set wildoptions&
2611 call feedkeys(":MsFeat\<Tab>\<C-B>\"\<CR>", 'tx')
2612 call assert_equal('"MsFeat', @:)
2613 set wildoptions=fuzzy
2614 call feedkeys(":MsFeat\<Tab>\<C-B>\"\<CR>", 'tx')
2615 call assert_equal('"MissingFeature', @:)
2616
2617 " :help tag fuzzy completion - NOT supported
2618
2619 " highlight group name fuzzy completion
2620 set wildoptions&
2621 call feedkeys(":highlight SKey\<Tab>\<C-B>\"\<CR>", 'tx')
2622 call assert_equal('"highlight SKey', @:)
2623 call feedkeys(":highlight Sp*Key\<Tab>\<C-B>\"\<CR>", 'tx')
2624 call assert_equal('"highlight SpecialKey', @:)
2625 set wildoptions=fuzzy
2626 call feedkeys(":highlight SKey\<Tab>\<C-B>\"\<CR>", 'tx')
2627 call assert_equal('"highlight SpecialKey', @:)
2628 call feedkeys(":highlight Sp*Key\<Tab>\<C-B>\"\<CR>", 'tx')
2629 call assert_equal('"highlight Sp*Key', @:)
2630
2631 " :history suboptions fuzzy completion
2632 set wildoptions&
2633 call feedkeys(":history dg\<Tab>\<C-B>\"\<CR>", 'tx')
2634 call assert_equal('"history dg', @:)
2635 call feedkeys(":history se*h\<Tab>\<C-B>\"\<CR>", 'tx')
2636 call assert_equal('"history search', @:)
2637 set wildoptions=fuzzy
2638 call feedkeys(":history dg\<Tab>\<C-B>\"\<CR>", 'tx')
2639 call assert_equal('"history debug', @:)
2640 call feedkeys(":history se*h\<Tab>\<C-B>\"\<CR>", 'tx')
2641 call assert_equal('"history se*h', @:)
2642
2643 " :language locale name fuzzy completion
2644 if has('unix')
2645 set wildoptions&
2646 call feedkeys(":lang psx\<Tab>\<C-B>\"\<CR>", 'tx')
2647 call assert_equal('"lang psx', @:)
2648 set wildoptions=fuzzy
2649 call feedkeys(":lang psx\<Tab>\<C-B>\"\<CR>", 'tx')
2650 call assert_equal('"lang POSIX', @:)
2651 endif
2652
2653 " :mapclear buffer argument fuzzy completion
2654 set wildoptions&
2655 call feedkeys(":mapclear buf\<Tab>\<C-B>\"\<CR>", 'tx')
2656 call assert_equal('"mapclear buf', @:)
2657 set wildoptions=fuzzy
2658 call feedkeys(":mapclear buf\<Tab>\<C-B>\"\<CR>", 'tx')
2659 call assert_equal('"mapclear <buffer>', @:)
2660
2661 " map name fuzzy completion - NOT supported
2662
2663 " menu name fuzzy completion
2664 if has('gui_running')
2665 set wildoptions&
2666 call feedkeys(":menu pup\<Tab>\<C-B>\"\<CR>", 'tx')
2667 call assert_equal('"menu pup', @:)
2668 set wildoptions=fuzzy
2669 call feedkeys(":menu pup\<Tab>\<C-B>\"\<CR>", 'tx')
2670 call assert_equal('"menu PopUp.', @:)
2671 endif
2672
2673 " :messages suboptions fuzzy completion
2674 set wildoptions&
2675 call feedkeys(":messages clr\<Tab>\<C-B>\"\<CR>", 'tx')
2676 call assert_equal('"messages clr', @:)
2677 set wildoptions=fuzzy
2678 call feedkeys(":messages clr\<Tab>\<C-B>\"\<CR>", 'tx')
2679 call assert_equal('"messages clear', @:)
2680
2681 " :set option name fuzzy completion
2682 set wildoptions&
2683 call feedkeys(":set brkopt\<Tab>\<C-B>\"\<CR>", 'tx')
2684 call assert_equal('"set brkopt', @:)
2685 set wildoptions=fuzzy
2686 call feedkeys(":set brkopt\<Tab>\<C-B>\"\<CR>", 'tx')
2687 call assert_equal('"set breakindentopt', @:)
2688 set wildoptions&
2689 call feedkeys(":set fixeol\<Tab>\<C-B>\"\<CR>", 'tx')
2690 call assert_equal('"set fixendofline', @:)
2691 set wildoptions=fuzzy
2692 call feedkeys(":set fixeol\<Tab>\<C-B>\"\<CR>", 'tx')
2693 call assert_equal('"set fixendofline', @:)
2694
2695 " :set <term_option>
2696 set wildoptions&
2697 call feedkeys(":set t_E\<Tab>\<C-B>\"\<CR>", 'tx')
2698 call assert_equal('"set t_EC', @:)
2699 call feedkeys(":set <t_E\<Tab>\<C-B>\"\<CR>", 'tx')
2700 call assert_equal('"set <t_EC>', @:)
2701 set wildoptions=fuzzy
2702 call feedkeys(":set t_E\<Tab>\<C-B>\"\<CR>", 'tx')
2703 call assert_equal('"set t_EC', @:)
2704 call feedkeys(":set <t_E\<Tab>\<C-B>\"\<CR>", 'tx')
2705 call assert_equal('"set <t_EC>', @:)
2706
2707 " :packadd directory name fuzzy completion - NOT supported
2708
2709 " shell command name fuzzy completion - NOT supported
2710
2711 " :sign suboptions fuzzy completion
2712 set wildoptions&
2713 call feedkeys(":sign ufe\<Tab>\<C-B>\"\<CR>", 'tx')
2714 call assert_equal('"sign ufe', @:)
2715 set wildoptions=fuzzy
2716 call feedkeys(":sign ufe\<Tab>\<C-B>\"\<CR>", 'tx')
2717 call assert_equal('"sign undefine', @:)
2718
2719 " :syntax suboptions fuzzy completion
2720 set wildoptions&
2721 call feedkeys(":syntax kwd\<Tab>\<C-B>\"\<CR>", 'tx')
2722 call assert_equal('"syntax kwd', @:)
2723 set wildoptions=fuzzy
2724 call feedkeys(":syntax kwd\<Tab>\<C-B>\"\<CR>", 'tx')
2725 call assert_equal('"syntax keyword', @:)
2726
2727 " syntax group name fuzzy completion
2728 set wildoptions&
2729 call feedkeys(":syntax list mpar\<Tab>\<C-B>\"\<CR>", 'tx')
2730 call assert_equal('"syntax list mpar', @:)
2731 set wildoptions=fuzzy
2732 call feedkeys(":syntax list mpar\<Tab>\<C-B>\"\<CR>", 'tx')
2733 call assert_equal('"syntax list MatchParen', @:)
2734
2735 " :syntime suboptions fuzzy completion
2736 if has('profile')
2737 set wildoptions&
2738 call feedkeys(":syntime clr\<Tab>\<C-B>\"\<CR>", 'tx')
2739 call assert_equal('"syntime clr', @:)
2740 set wildoptions=fuzzy
2741 call feedkeys(":syntime clr\<Tab>\<C-B>\"\<CR>", 'tx')
2742 call assert_equal('"syntime clear', @:)
2743 endif
2744
2745 " tag name fuzzy completion - NOT supported
2746
2747 " tag name and file fuzzy completion - NOT supported
2748
2749 " user names fuzzy completion - how to test this functionality?
2750
2751 " user defined variable name fuzzy completion
2752 let g:SomeVariable=10
2753 set wildoptions&
2754 call feedkeys(":let SVar\<Tab>\<C-B>\"\<CR>", 'tx')
2755 call assert_equal('"let SVar', @:)
2756 set wildoptions=fuzzy
2757 call feedkeys(":let SVar\<Tab>\<C-B>\"\<CR>", 'tx')
2758 call assert_equal('"let SomeVariable', @:)
2759
2760 set wildoptions&
2761 %bw!
2762 endfunc
2763
2441 " vim: shiftwidth=2 sts=2 expandtab 2764 " vim: shiftwidth=2 sts=2 expandtab