On Thu, Nov 15, 2018 at 7:46 AM Christian Brabandt <[email protected]>
wrote:

>
> ...
> Thanks for contributing. Could you please also add a test for the
> changed behaviour?
>
>
I am sending some basic test for visual block yanking and deleting with
linebreak. Kind of fundamental specification of the feature. Can this be
agreed on? In particular what is yanked and what is deleted in each case?
BTW, I've found that there are still bugs in my patch. So the tests are
failing both withithout and with the patch. But there is no sense to fix it
until we agree that this is how we want VIM to behave. So please review the
test code in the text or in the attachment (same content). Note that the
suggested behaviour seems to be in contradiction with Test_virtual_block()
in test_listlbr.vim. But I suspect the current state is a bug. It is not
consistent with how e.g. tab is treated when half of its width is to be
deleted.  Let me know what you think.
Thanks.

Tom

func! Test_lbr_visual_block_space()  " SCREEN:  " with nolbr:  "
|12345678901234567890|  " 1|_0_____a___________d|  "  |_e
    |  " 2|_x suffix_too_wide_f| (space)  "  |or_window           |  "
 " with lbr: 'real' tab is 6 vcols, 'virtual' is 18 vcols  " 2|_x
            |  "  |suffix_too_wide_for_|  "  |window              |

  20vnew
  set sbr=
  setl lbr
  let l:expected = {}
  let l:lines = [    \ "_0_____a___________d_e",    \ "_x
suffix_too_wide_for_window",    \ ]
  " data in 'expected[x]' are values for: [  " \ "yanked part of line
1"  " \ "yanked part of line 2"  " \ "result buffer line 1"  " \
"result buffer line 2"  " ]
  " TEST CASES: horizontally the block takes ...  " ... only the real
space, for yank/del of vcol 0
  let l:expected['0'] = [    \ "0",    \ "x",    \
"______a___________d_e",    \ "_
suffix_too_wide_for_window",    \ ]  " ... the real space + a few of
lbr-added spaces, for yank/del up to vcol a
  let l:expected['a'] = [    \ "0_____a",    \ "x      ",    \
"____________d_e",    \ "_            suffix_too_wide_for_window",
\ ]  " ... the real space + all lbr-added spaces (whole virtual
space), for y/d to d
  let l:expected['d'] = [    \ "0_____a___________d",    \ "x
        ",    \ "__e",    \ "_suffix_too_wide_for_window",    \ ]  "
... whole virtual space + two more cols, for yank/del up to vcol e
  let l:expected['e'] = [    \ "0_____a___________d_e",    \ "_
            ",    \ "_",    \ "_ffix_too_wide_for_window",    \ ]
  " DO TESTS:
  let l:begin_sel = "ggj0fx\<C-V>k0f"  " will start visual block selection
  for l:column in keys(l:expected)
    call setline(1, l:lines)    " yank: correct text yanked?
    exe "normal " . l:begin_sel . l:column . "y"
    let l:expect = join(l:expected[l:column][0:1], "\n")
    call assert_equal(l:expect, @")    " delete: correct text yanked?
    exe "normal " . l:begin_sel . l:column . "d"
    call assert_equal(l:expect, @")    " delete: correctly changed buffer?
    let l:expect = l:expected[l:column][2:3]
    call assert_equal(l:expect, getline(1, '$'))
  endfor
  %bwipeout!endfunc
func! Test_lbr_visual_block_tab()  " SCREEN:  " with nolbr:  "
|12345678901234567890|  " 1|_0__a__b__c________d|  "  |_e
    |  " 2|_x      suffix_too_w| (tab)  "  |ide_for_window      |  "
" with lbr: 'real' tab is 6 vcols, 'virtual' is 18 vcols  " 2|_x
           |  "  |suffix_too_wide_for_|  "  |window              |

  20vnew
  set sbr=
  set lbr
  let l:expected = {}
  let l:lines = [    \ "_0__a__b__c________d_e",    \ "_x
suffix_too_wide_for_window"]
  " data in 'expected[x]' are values for: [  " \ "yanked part of line
1"  " \ "yanked part of line 2"  " \ "result buffer line 1"  " \
"result buffer line 2"  " ]
  " TEST CASES: horizontally the block takes ...  " ... a single
column, for yank/del of vcol 0
  let l:expected['0'] = [    \ "0",    \ "x",    \
"___a__b__c________d_e",    \ "_
suffix_too_wide_for_window",    \ ]  " ... part of the real tab, for
yank/del up to vcol a
  let l:expected['a'] = [    \ "0__a",    \ "x   ",    \
"___b__c________d_e",    \ "_
suffix_too_wide_for_window",    \ ]  " ... whole real tab, for
yank/del up to vcol b
  let l:expected['b'] = [    \ "0__a__b",    \ "x      ",    \
"___c________d_e",    \ "_            suffix_too_wide_for_window",
\ ]  " ... real tab + a few of lbr-added spaces, for y/d up to vcol c
  let l:expected['c'] = [    \ "0__a__b__c",    \ "x         ",    \
"_________d_e",    \ "_         suffix_too_wide_for_window",    \ ]  "
... real tab + all lbr-added spaces (= whole virtual tab), for y/d to
vcol d
  let l:expected['d'] = [    \ "0__a__b__c________d",    \ "x\t",    \
"__e",    \ "_suffix_too_wide_for_window",    \ ]  " ... whole virtual
tab space + two more vcols, for y/d up to vcol e
  let l:expected['e'] = [    \ "0__a__b__c________d_e",    \ "x\tsu",
  \ "_",    \ "_ffix_too_wide_for_window",    \ ]
  " DO TESTS:
  let l:begin_sel = "ggj0fx\<C-V>k0f"  " will start visual block selection
  for l:column in keys(l:expected)
    call setline(1, l:lines)    " yank: correct text yanked?
    exe "normal " . l:begin_sel . l:column . "y"
    let l:expect = join(l:expected[l:column][0:1], "\n")
    call assert_equal(l:expect, @")    " delete: correct text yanked?
    exe "normal " . l:begin_sel . l:column . "d"
    call assert_equal(l:expect, @")    " delete: correctly changed buffer?
    let l:expect = l:expected[l:column][2:3]
    call assert_equal(l:expect, getline(1, '$'))
  endfor
  %bwipeout!endfunc

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: test_lbr_visual_block_yank_delete.vim
Description: Binary data

Raspunde prin e-mail lui