Mercurial > vim
comparison src/testdir/test_edit.vim @ 34636:c94ef9458309 v9.1.0204
patch 9.1.0204: Backspace inserts spaces with virtual text and 'smarttab'
Commit: https://github.com/vim/vim/commit/0185c7701434f1fbbf83fecd6384a19c1d2fc44e
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon Mar 25 16:34:51 2024 +0100
patch 9.1.0204: Backspace inserts spaces with virtual text and 'smarttab'
Problem: Backspace inserts spaces with virtual text and 'smarttab'.
Solution: Ignore virtual text and wrapping when backspacing.
(zeertzjq)
related: neovim/neovim#28005
closes: #14296
Co-authored-by: VanaIgr <vanaigranov@gmail.com>
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 25 Mar 2024 16:45:04 +0100 |
parents | 8687845c326c |
children | 8079960136db |
comparison
equal
deleted
inserted
replaced
34635:5bacfe383131 | 34636:c94ef9458309 |
---|---|
4 let &t_kD="[3;*~" | 4 let &t_kD="[3;*~" |
5 endif | 5 endif |
6 | 6 |
7 source check.vim | 7 source check.vim |
8 source screendump.vim | 8 source screendump.vim |
9 | |
10 " Needed for testing basic rightleft: Test_edit_rightleft | |
11 source view_util.vim | 9 source view_util.vim |
12 | 10 |
13 " Needs to come first until the bug in getchar() is | 11 " Needs to come first until the bug in getchar() is |
14 " fixed: https://groups.google.com/d/msg/vim_dev/fXL9yme4H4c/bOR-U6_bAQAJ | 12 " fixed: https://groups.google.com/d/msg/vim_dev/fXL9yme4H4c/bOR-U6_bAQAJ |
15 func Test_edit_00b() | 13 func Test_edit_00b() |
2156 autocmd! InsertCharPre | 2154 autocmd! InsertCharPre |
2157 unlet g:triggered | 2155 unlet g:triggered |
2158 bwipe! | 2156 bwipe! |
2159 endfunc | 2157 endfunc |
2160 | 2158 |
2159 func s:check_backspace(expected) | |
2160 let g:actual = [] | |
2161 inoremap <buffer> <F2> <Cmd>let g:actual += [getline('.')]<CR> | |
2162 set backspace=indent,eol,start | |
2163 | |
2164 exe "normal $i" .. repeat("\<BS>\<F2>", len(a:expected)) | |
2165 call assert_equal(a:expected, g:actual) | |
2166 | |
2167 set backspace& | |
2168 iunmap <buffer> <F2> | |
2169 unlet g:actual | |
2170 endfunc | |
2171 | |
2172 " Test that backspace works with 'smarttab' and mixed Tabs and spaces. | |
2173 func Test_edit_backspace_smarttab_mixed() | |
2174 call NewWindow(1, 30) | |
2175 setlocal smarttab tabstop=4 shiftwidth=4 | |
2176 call setline(1, "\t \t \t a") | |
2177 call s:check_backspace([ | |
2178 \ "\t \t \ta", | |
2179 \ "\t \t a", | |
2180 \ "\t \t a", | |
2181 \ "\t \ta", | |
2182 \ "\t a", | |
2183 \ "\ta", | |
2184 \ "a", | |
2185 \ ]) | |
2186 | |
2187 call CloseWindow() | |
2188 endfunc | |
2189 | |
2190 " Test that backspace works with 'smarttab' and 'varsofttabstop'. | |
2191 func Test_edit_backspace_smarttab_varsofttabstop() | |
2192 CheckFeature vartabs | |
2193 | |
2194 call NewWindow(1, 30) | |
2195 setlocal smarttab tabstop=8 varsofttabstop=6,2,5,3 | |
2196 call setline(1, "a\t \t a") | |
2197 call s:check_backspace([ | |
2198 \ "a\t \ta", | |
2199 \ "a\t a", | |
2200 \ "a\ta", | |
2201 \ "a a", | |
2202 \ "aa", | |
2203 \ "a", | |
2204 \ ]) | |
2205 | |
2206 call CloseWindow() | |
2207 endfunc | |
2208 | |
2209 " Test that backspace works with 'smarttab' when a Tab is shown as "^I". | |
2210 func Test_edit_backspace_smarttab_list() | |
2211 call NewWindow(1, 30) | |
2212 setlocal smarttab tabstop=4 shiftwidth=4 list listchars= | |
2213 call setline(1, "\t \t \t a") | |
2214 call s:check_backspace([ | |
2215 \ "\t \t a", | |
2216 \ "\t \t a", | |
2217 \ "\t \ta", | |
2218 \ "\t a", | |
2219 \ "a", | |
2220 \ ]) | |
2221 | |
2222 call CloseWindow() | |
2223 endfunc | |
2224 | |
2225 " Test that backspace works with 'smarttab' and 'breakindent'. | |
2226 func Test_edit_backspace_smarttab_breakindent() | |
2227 CheckFeature linebreak | |
2228 | |
2229 call NewWindow(3, 17) | |
2230 setlocal smarttab tabstop=4 shiftwidth=4 breakindent breakindentopt=min:5 | |
2231 call setline(1, "\t \t \t a") | |
2232 call s:check_backspace([ | |
2233 \ "\t \t \ta", | |
2234 \ "\t \t a", | |
2235 \ "\t \t a", | |
2236 \ "\t \ta", | |
2237 \ "\t a", | |
2238 \ "\ta", | |
2239 \ "a", | |
2240 \ ]) | |
2241 | |
2242 call CloseWindow() | |
2243 endfunc | |
2244 | |
2245 " Test that backspace works with 'smarttab' and virtual text. | |
2246 func Test_edit_backspace_smarttab_virtual_text() | |
2247 CheckFeature textprop | |
2248 | |
2249 call NewWindow(1, 50) | |
2250 setlocal smarttab tabstop=4 shiftwidth=4 | |
2251 call setline(1, "\t \t \t a") | |
2252 call prop_type_add('theprop', {}) | |
2253 call prop_add(1, 3, {'type': 'theprop', 'text': 'text'}) | |
2254 call s:check_backspace([ | |
2255 \ "\t \t \ta", | |
2256 \ "\t \t a", | |
2257 \ "\t \t a", | |
2258 \ "\t \ta", | |
2259 \ "\t a", | |
2260 \ "\ta", | |
2261 \ "a", | |
2262 \ ]) | |
2263 | |
2264 call CloseWindow() | |
2265 call prop_type_delete('theprop') | |
2266 endfunc | |
2267 | |
2161 " vim: shiftwidth=2 sts=2 expandtab | 2268 " vim: shiftwidth=2 sts=2 expandtab |