comparison src/testdir/test_options.vim @ 32962:7771cb060685 v9.0.1781

patch 9.0.1781: Problems when setting bin/paste option Commit: https://github.com/vim/vim/commit/757593c07a4f4ac43eb6c6e52fc299abc9bc08bc Author: Christian Brabandt <cb@256bit.org> Date: Tue Aug 22 21:44:10 2023 +0200 patch 9.0.1781: Problems when setting bin/paste option Problem: Problems when setting bin/paste option Solution: When setting binary/paste, remember that this also affects depending options, so that :verbose set returns the right location. Mention if depending options for 'binary' or 'paste' have been reset indirectly. Add a test to verify it works. Also noticed as small bug, that the global option value for expandtab was not reset when paste option is set, so fix that while at it. closes: #12837 closes: #12879 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author Christian Brabandt <cb@256bit.org>
date Tue, 22 Aug 2023 22:00:03 +0200
parents 80152cf7ce63
children ccfca4f03a2b
comparison
equal deleted inserted replaced
32961:db0e12cf833e 32962:7771cb060685
1772 exe 'let &g:' .. opt .. '=' .. default 1772 exe 'let &g:' .. opt .. '=' .. default
1773 endfor 1773 endfor
1774 bw! 1774 bw!
1775 endfunc 1775 endfunc
1776 1776
1777 func Test_paste_depending_options()
1778 " setting the paste option, resets all dependent options
1779 " and will be reported correctly using :verbose set <option>?
1780 let lines =<< trim [CODE]
1781 " set paste test
1782 set autoindent
1783 set expandtab
1784 " disabled, because depends on compiled feature set
1785 " set hkmap
1786 " set revins
1787 " set varsofttabstop=8,32,8
1788 set ruler
1789 set showmatch
1790 set smarttab
1791 set softtabstop=4
1792 set textwidth=80
1793 set wrapmargin=10
1794
1795 source Xvimrc_paste2
1796
1797 redir > Xoutput_paste
1798 verbose set expandtab?
1799 verbose setg expandtab?
1800 verbose setl expandtab?
1801 redir END
1802
1803 qall!
1804 [CODE]
1805
1806 call writefile(lines, 'Xvimrc_paste', 'D')
1807 call writefile(['set paste'], 'Xvimrc_paste2', 'D')
1808 if !RunVim([], lines, '--clean')
1809 return
1810 endif
1811
1812 let result = readfile('Xoutput_paste')->filter('!empty(v:val)')
1813 call assert_equal('noexpandtab', result[0])
1814 call assert_match("^ Last set from .*Xvimrc_paste2 line 1$", result[1])
1815 call assert_equal('noexpandtab', result[2])
1816 call assert_match("^ Last set from .*Xvimrc_paste2 line 1$", result[3])
1817 call assert_equal('noexpandtab', result[4])
1818 call assert_match("^ Last set from .*Xvimrc_paste2 line 1$", result[5])
1819
1820 call delete('Xoutput_paste')
1821 endfunc
1822
1823 func Test_binary_depending_options()
1824 " setting the paste option, resets all dependent options
1825 " and will be reported correctly using :verbose set <option>?
1826 let lines =<< trim [CODE]
1827 " set binary test
1828 set expandtab
1829
1830 source Xvimrc_bin2
1831
1832 redir > Xoutput_bin
1833 verbose set expandtab?
1834 verbose setg expandtab?
1835 verbose setl expandtab?
1836 redir END
1837
1838 qall!
1839 [CODE]
1840
1841 call writefile(lines, 'Xvimrc_bin', 'D')
1842 call writefile(['set binary'], 'Xvimrc_bin2', 'D')
1843 if !RunVim([], lines, '--clean')
1844 return
1845 endif
1846
1847 let result = readfile('Xoutput_bin')->filter('!empty(v:val)')
1848 call assert_equal('noexpandtab', result[0])
1849 call assert_match("^ Last set from .*Xvimrc_bin2 line 1$", result[1])
1850 call assert_equal('noexpandtab', result[2])
1851 call assert_match("^ Last set from .*Xvimrc_bin2 line 1$", result[3])
1852 call assert_equal('noexpandtab', result[4])
1853 call assert_match("^ Last set from .*Xvimrc_bin2 line 1$", result[5])
1854
1855 call delete('Xoutput_bin')
1856 endfunc
1857
1777 " vim: shiftwidth=2 sts=2 expandtab 1858 " vim: shiftwidth=2 sts=2 expandtab