Mercurial > vim
comparison src/testdir/test_vartabs.vim @ 15062:3a94f7918980 v8.1.0542
patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
commit https://github.com/vim/vim/commit/f951416a8396a54bbbe21de1a8b16716428549f2
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 22 03:08:29 2018 +0100
patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Problem: shiftwidth() does not take 'vartabstop' into account.
Solution: Use the cursor position or a position explicitly passed.
Also make >> and << work better with 'vartabstop'. (Christian
Brabandt)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 22 Nov 2018 03:15:10 +0100 |
parents | dc54785f9a1d |
children | 63b02fcf1361 |
comparison
equal
deleted
inserted
replaced
15061:0572862c3162 | 15062:3a94f7918980 |
---|---|
295 bw! | 295 bw! |
296 bw! | 296 bw! |
297 set nolist listchars&vim | 297 set nolist listchars&vim |
298 endfunc | 298 endfunc |
299 | 299 |
300 func Test_vartabs_shiftwidth() | |
301 "return | |
302 if winwidth(0) < 40 | |
303 return | |
304 endif | |
305 new | |
306 40vnew | |
307 %d | |
308 " setl varsofttabstop=10,20,30,40 | |
309 setl shiftwidth=0 vartabstop=10,20,30,40 | |
310 call setline(1, "x") | |
311 | |
312 " Check without any change. | |
313 let expect = ['x '] | |
314 let lines = ScreenLines(1, winwidth(0)) | |
315 call s:compare_lines(expect, lines) | |
316 " Test 1: | |
317 " shiftwidth depends on the indent, first check with cursor at the end of the | |
318 " line (which is the same as the start of the line, since there is only one | |
319 " character). | |
320 norm! $>> | |
321 let expect1 = [' x '] | |
322 let lines = ScreenLines(1, winwidth(0)) | |
323 call s:compare_lines(expect1, lines) | |
324 call assert_equal(10, shiftwidth()) | |
325 call assert_equal(10, shiftwidth(1)) | |
326 call assert_equal(20, shiftwidth(virtcol('.'))) | |
327 norm! $>> | |
328 let expect2 = [' x ', '~ '] | |
329 let lines = ScreenLines([1, 2], winwidth(0)) | |
330 call s:compare_lines(expect2, lines) | |
331 call assert_equal(20, shiftwidth(virtcol('.')-2)) | |
332 call assert_equal(30, shiftwidth(virtcol('.'))) | |
333 norm! $>> | |
334 let expect3 = [' ', ' x ', '~ '] | |
335 let lines = ScreenLines([1, 3], winwidth(0)) | |
336 call s:compare_lines(expect3, lines) | |
337 call assert_equal(30, shiftwidth(virtcol('.')-2)) | |
338 call assert_equal(40, shiftwidth(virtcol('.'))) | |
339 norm! $>> | |
340 let expect4 = [' ', ' ', ' x '] | |
341 let lines = ScreenLines([1, 3], winwidth(0)) | |
342 call assert_equal(40, shiftwidth(virtcol('.'))) | |
343 call s:compare_lines(expect4, lines) | |
344 | |
345 " Test 2: Put the cursor at the first column, result should be the same | |
346 call setline(1, "x") | |
347 norm! 0>> | |
348 let lines = ScreenLines(1, winwidth(0)) | |
349 call s:compare_lines(expect1, lines) | |
350 norm! 0>> | |
351 let lines = ScreenLines([1, 2], winwidth(0)) | |
352 call s:compare_lines(expect2, lines) | |
353 norm! 0>> | |
354 let lines = ScreenLines([1, 3], winwidth(0)) | |
355 call s:compare_lines(expect3, lines) | |
356 norm! 0>> | |
357 let lines = ScreenLines([1, 3], winwidth(0)) | |
358 call s:compare_lines(expect4, lines) | |
359 | |
360 " cleanup | |
361 bw! | |
362 bw! | |
363 endfunc | |
364 | |
300 func Test_vartabs_failures() | 365 func Test_vartabs_failures() |
301 call assert_fails('set vts=8,') | 366 call assert_fails('set vts=8,') |
302 call assert_fails('set vsts=8,') | 367 call assert_fails('set vsts=8,') |
303 call assert_fails('set vts=8,,8') | 368 call assert_fails('set vts=8,,8') |
304 call assert_fails('set vsts=8,,8') | 369 call assert_fails('set vsts=8,,8') |