annotate src/testdir/test_backup.vim @ 34686:83875247fbc0 v9.1.0224

patch 9.1.0224: cursor may move too many lines over "right" & "below" virt text Commit: https://github.com/vim/vim/commit/515f734e687f28f7199b2a8042197624d9f3ec15 Author: Dylan Thacker-Smith <dylan.ah.smith@gmail.com> Date: Thu Mar 28 12:01:14 2024 +0100 patch 9.1.0224: cursor may move too many lines over "right" & "below" virt text Problem: If a line has "right" & "below" virtual text properties, where the "below" property may be stored first due to lack of ordering between them, then the line height is calculated to be 1 more and causes the cursor to far over the line. Solution: Remove some unnecessary setting of a `next_right_goes_below = TRUE` flag for "below" and "above" text properties. (Dylan Thacker-Smith) I modified a regression test I recently added to cover this case, leveraging the fact that "after", "right" & "below" text properties are being stored in the reverse of the order they are added in. The previous version of this regression test was crafted to workaround this issue so it can be addressed by this separate patch. closes: #14317 Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Thu, 28 Mar 2024 12:15:03 +0100
parents ba5ca7c7d44c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the backup function
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
20812
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
3 source check.vim
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
4
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_backup()
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
6 set backup backupdir=. backupskip=
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 new
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 call setline(1, ['line1', 'line2'])
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 :f Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 " backup file is only created after
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " writing a second time (before overwriting)
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 let l = readfile('Xbackup.txt~')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal(['line1', 'line2'], l)
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 bw!
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
17 set backup&vim backupdir&vim backupskip&vim
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call delete('Xbackup.txt')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call delete('Xbackup.txt~')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 endfunc
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
21580
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
22 func Test_backup_backupskip()
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
23 set backup backupdir=. backupskip=*.txt
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
24 new
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
25 call setline(1, ['line1', 'line2'])
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
26 :f Xbackup.txt
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
27 :w! Xbackup.txt
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
28 " backup file is only created after
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
29 " writing a second time (before overwriting)
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
30 :w! Xbackup.txt
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
31 call assert_false(filereadable('Xbackup.txt~'))
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
32 bw!
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
33 set backup&vim backupdir&vim backupskip&vim
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
34 call delete('Xbackup.txt')
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
35 call delete('Xbackup.txt~')
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
36 endfunc
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
37
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 func Test_backup2()
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
39 set backup backupdir=.// backupskip=
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 new
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call setline(1, ['line1', 'line2', 'line3'])
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 :f Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 " backup file is only created after
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " writing a second time (before overwriting)
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 sp *Xbackup.txt~
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
21580
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
49 let f = expand('%')
14483
7fd8cb54da4a patch 8.1.0255: backup test fails when using shadow directory
Christian Brabandt <cb@256bit.org>
parents: 14475
diff changeset
50 call assert_match('%testdir%Xbackup.txt\~', f)
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 bw!
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 bw!
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 call delete('Xbackup.txt')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 call delete(f)
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
55 set backup&vim backupdir&vim backupskip&vim
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endfunc
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 func Test_backup2_backupcopy()
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
59 set backup backupdir=.// backupcopy=yes backupskip=
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 new
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 call setline(1, ['line1', 'line2', 'line3'])
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 :f Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 " backup file is only created after
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 " writing a second time (before overwriting)
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 sp *Xbackup.txt~
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
21580
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
69 let f = expand('%')
14483
7fd8cb54da4a patch 8.1.0255: backup test fails when using shadow directory
Christian Brabandt <cb@256bit.org>
parents: 14475
diff changeset
70 call assert_match('%testdir%Xbackup.txt\~', f)
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 bw!
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 bw!
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call delete('Xbackup.txt')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 call delete(f)
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
75 set backup&vim backupdir&vim backupcopy&vim backupskip&vim
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 endfunc
20812
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
77
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
78 " Test for using a non-existing directory as a backup directory
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
79 func Test_non_existing_backupdir()
21580
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
80 set backupdir=./non_existing_dir backupskip=
30110
ba5ca7c7d44c patch 9.0.0391: using separate delete() call instead of writefile() 'D' flag
Bram Moolenaar <Bram@vim.org>
parents: 29950
diff changeset
81 call writefile(['line1'], 'Xbackupdir', 'D')
29950
c8b1a683323c patch 9.0.0313: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 21580
diff changeset
82 new Xbackupdir
20812
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
83 call assert_fails('write', 'E510:')
30110
ba5ca7c7d44c patch 9.0.0391: using separate delete() call instead of writefile() 'D' flag
Bram Moolenaar <Bram@vim.org>
parents: 29950
diff changeset
84
21580
93dae47699fb patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 20812
diff changeset
85 set backupdir&vim backupskip&vim
20812
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
86 endfunc
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
87
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
88 " vim: shiftwidth=2 sts=2 expandtab