Mercurial > vim
comparison src/testdir/test_popupwin.vim @ 17946:ec4248c4b92c v8.1.1969
patch 8.1.1969: popup window filter is used in all modes
Commit: https://github.com/vim/vim/commit/581ba39aefe837298a9943b04a1dab13a7ec6772
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 3 22:08:33 2019 +0200
patch 8.1.1969: popup window filter is used in all modes
Problem: Popup window filter is used in all modes.
Solution: Add the "filtermode" property.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 03 Sep 2019 22:15:03 +0200 |
parents | 664cc72f50c5 |
children | a170c48e0f91 |
comparison
equal
deleted
inserted
replaced
17945:dffad5c9361e | 17946:ec4248c4b92c |
---|---|
1890 | 1890 |
1891 call popup_close(winid) | 1891 call popup_close(winid) |
1892 delfunc MyPopupFilter | 1892 delfunc MyPopupFilter |
1893 endfunc | 1893 endfunc |
1894 | 1894 |
1895 func Test_popupwin_filter_mode() | |
1896 func MyPopupFilter(winid, c) | |
1897 let s:typed = a:c | |
1898 if a:c == ':' || a:c == "\r" || a:c == 'v' | |
1899 " can start cmdline mode, get out, and start/stop Visual mode | |
1900 return 0 | |
1901 endif | |
1902 return 1 | |
1903 endfunc | |
1904 | |
1905 " Normal, Visual and Insert mode | |
1906 let winid = popup_create('something', #{filter: 'MyPopupFilter', filtermode: 'nvi'}) | |
1907 redraw | |
1908 call feedkeys('x', 'xt') | |
1909 call assert_equal('x', s:typed) | |
1910 | |
1911 call feedkeys(":let g:foo = 'foo'\<CR>", 'xt') | |
1912 call assert_equal(':', s:typed) | |
1913 call assert_equal('foo', g:foo) | |
1914 | |
1915 let @x = 'something' | |
1916 call feedkeys('v$"xy', 'xt') | |
1917 call assert_equal('y', s:typed) | |
1918 call assert_equal('something', @x) " yank command is filtered out | |
1919 call feedkeys('v', 'xt') " end Visual mode | |
1920 | |
1921 call popup_close(winid) | |
1922 | |
1923 " only Normal mode | |
1924 let winid = popup_create('something', #{filter: 'MyPopupFilter', filtermode: 'n'}) | |
1925 redraw | |
1926 call feedkeys('x', 'xt') | |
1927 call assert_equal('x', s:typed) | |
1928 | |
1929 call feedkeys(":let g:foo = 'foo'\<CR>", 'xt') | |
1930 call assert_equal(':', s:typed) | |
1931 call assert_equal('foo', g:foo) | |
1932 | |
1933 let @x = 'something' | |
1934 call feedkeys('v$"xy', 'xt') | |
1935 call assert_equal('v', s:typed) | |
1936 call assert_notequal('something', @x) | |
1937 | |
1938 call popup_close(winid) | |
1939 | |
1940 " default: all modes | |
1941 let winid = popup_create('something', #{filter: 'MyPopupFilter'}) | |
1942 redraw | |
1943 call feedkeys('x', 'xt') | |
1944 call assert_equal('x', s:typed) | |
1945 | |
1946 let g:foo = 'bar' | |
1947 call feedkeys(":let g:foo = 'foo'\<CR>", 'xt') | |
1948 call assert_equal("\r", s:typed) | |
1949 call assert_equal('bar', g:foo) | |
1950 | |
1951 let @x = 'something' | |
1952 call feedkeys('v$"xy', 'xt') | |
1953 call assert_equal('y', s:typed) | |
1954 call assert_equal('something', @x) " yank command is filtered out | |
1955 call feedkeys('v', 'xt') " end Visual mode | |
1956 | |
1957 call popup_close(winid) | |
1958 delfunc MyPopupFilter | |
1959 endfunc | |
1960 | |
1895 func Test_popupwin_with_buffer() | 1961 func Test_popupwin_with_buffer() |
1896 call writefile(['some text', 'in a buffer'], 'XsomeFile') | 1962 call writefile(['some text', 'in a buffer'], 'XsomeFile') |
1897 let buf = bufadd('XsomeFile') | 1963 let buf = bufadd('XsomeFile') |
1898 call assert_equal(0, bufloaded(buf)) | 1964 call assert_equal(0, bufloaded(buf)) |
1899 | 1965 |