Mercurial > vim
comparison src/testdir/test_registers.vim @ 20743:a672feb8fc4f v8.2.0924
patch 8.2.0924: cannot save and restore a register properly
Commit: https://github.com/vim/vim/commit/bb861e293e0170455184079fa537278754b07911
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 7 18:16:36 2020 +0200
patch 8.2.0924: cannot save and restore a register properly
Problem: Cannot save and restore a register properly.
Solution: Add getreginfo() and make setreg() accept a dictionary. (Andy
Massimino, closes #3370)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 07 Jun 2020 18:30:03 +0200 |
parents | 2fb397573541 |
children | e6a5a5ef4034 |
comparison
equal
deleted
inserted
replaced
20742:8c304b9fcb1a | 20743:a672feb8fc4f |
---|---|
414 | 414 |
415 " cannot execute a register in operator pending mode | 415 " cannot execute a register in operator pending mode |
416 call assert_beeps('normal! c@r') | 416 call assert_beeps('normal! c@r') |
417 endfunc | 417 endfunc |
418 | 418 |
419 " Test for getting register info | |
420 func Test_get_reginfo() | |
421 enew | |
422 call setline(1, ['foo', 'bar']) | |
423 | |
424 exe 'norm! "zyy' | |
425 let info = getreginfo('"') | |
426 call assert_equal('z', info.points_to) | |
427 call setreg('y', 'baz') | |
428 call assert_equal('z', getreginfo('').points_to) | |
429 call setreg('y', { 'isunnamed': v:true }) | |
430 call assert_equal('y', getreginfo('"').points_to) | |
431 | |
432 exe '$put' | |
433 call assert_equal(getreg('y'), getline(3)) | |
434 call setreg('', 'qux') | |
435 call assert_equal('0', getreginfo('').points_to) | |
436 call setreg('x', 'quux') | |
437 call assert_equal('0', getreginfo('').points_to) | |
438 | |
439 let info = getreginfo('') | |
440 call assert_equal(getreg('', 1, 1), info.regcontents) | |
441 call assert_equal(getregtype(''), info.regtype) | |
442 | |
443 exe "norm! 0\<c-v>e" .. '"zy' | |
444 let info = getreginfo('z') | |
445 call assert_equal(getreg('z', 1, 1), info.regcontents) | |
446 call assert_equal(getregtype('z'), info.regtype) | |
447 call assert_equal(1, +info.isunnamed) | |
448 | |
449 let info = getreginfo('"') | |
450 call assert_equal('z', info.points_to) | |
451 | |
452 bwipe! | |
453 endfunc | |
454 | |
455 " Test for restoring register with dict from getreginfo | |
456 func Test_set_register_dict() | |
457 enew! | |
458 | |
459 call setreg('"', #{ regcontents: ['one', 'two'], | |
460 \ regtype: 'V', points_to: 'z' }) | |
461 call assert_equal(['one', 'two'], getreg('"', 1, 1)) | |
462 let info = getreginfo('"') | |
463 call assert_equal('z', info.points_to) | |
464 call assert_equal('V', info.regtype) | |
465 call assert_equal(1, +getreginfo('z').isunnamed) | |
466 | |
467 call setreg('x', #{ regcontents: ['three', 'four'], | |
468 \ regtype: 'v', isunnamed: v:true }) | |
469 call assert_equal(['three', 'four'], getreg('"', 1, 1)) | |
470 let info = getreginfo('"') | |
471 call assert_equal('x', info.points_to) | |
472 call assert_equal('v', info.regtype) | |
473 call assert_equal(1, +getreginfo('x').isunnamed) | |
474 | |
475 call setreg('y', #{ regcontents: 'five', | |
476 \ regtype: "\<c-v>", isunnamed: v:false }) | |
477 call assert_equal("\<c-v>4", getreginfo('y').regtype) | |
478 call assert_equal(0, +getreginfo('y').isunnamed) | |
479 call assert_equal(['three', 'four'], getreg('"', 1, 1)) | |
480 call assert_equal('x', getreginfo('"').points_to) | |
481 | |
482 call setreg('"', #{ regcontents: 'six' }) | |
483 call assert_equal('0', getreginfo('"').points_to) | |
484 call assert_equal(1, +getreginfo('0').isunnamed) | |
485 call assert_equal(['six'], getreginfo('0').regcontents) | |
486 call assert_equal(['six'], getreginfo('"').regcontents) | |
487 | |
488 bwipe! | |
489 endfunc | |
490 | |
419 " vim: shiftwidth=2 sts=2 expandtab | 491 " vim: shiftwidth=2 sts=2 expandtab |