Mercurial > vim
annotate src/testdir/test_getcwd.vim @ 16101:5c5d211bd5a8 v8.1.1055
patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
commit https://github.com/vim/vim/commit/75bf3d22f42684beecd977f3185e98045b5c33d9
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Mar 26 22:46:05 2019 +0100
patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Problem: CTRL-G U in Insert mode doesn't work to avoid splitting the undo
sequence for shift-left and shift-right.
Solution: Also check dont_sync_undo for shifted cursor keys. (Christian
Brabandt)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Mar 2019 23:00:06 +0100 |
parents | 63b02fcf1361 |
children | 8c3a1bd270bb |
rev | line source |
---|---|
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
1 func GetCwdInfo(win, tab) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
2 let tab_changed = 0 |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
3 let mod = ":t" |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
4 if a:tab > 0 && a:tab != tabpagenr() |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
5 let tab_changed = 1 |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
6 exec "tabnext " . a:tab |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
7 endif |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
8 let bufname = fnamemodify(bufname(winbufnr(a:win)), mod) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
9 if tab_changed |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
10 tabprevious |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
11 endif |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
12 if a:win == 0 && a:tab == 0 |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
13 let dirname = fnamemodify(getcwd(), mod) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
14 let lflag = haslocaldir() |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
15 elseif a:tab == 0 |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
16 let dirname = fnamemodify(getcwd(a:win), mod) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
17 let lflag = haslocaldir(a:win) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
18 else |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
19 let dirname = fnamemodify(getcwd(a:win, a:tab), mod) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
20 let lflag = haslocaldir(a:win, a:tab) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
21 endif |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
22 return bufname . ' ' . dirname . ' ' . lflag |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
23 endfunc |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 " Do all test in a separate window to avoid E211 when we recursively |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " delete the Xtopdir directory during cleanup |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 function SetUp() |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
28 set visualbell |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
29 set nocp viminfo+=nviminfo |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
31 " On windows a swapfile in Xtopdir prevents it from being cleaned up. |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
32 set noswapfile |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
34 " On windows a stale "Xtopdir" directory may exist, remove it so that |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
35 " we start from a clean state. |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
36 call delete("Xtopdir", "rf") |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
37 new |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
38 call mkdir('Xtopdir') |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
39 cd Xtopdir |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
40 let g:topdir = getcwd() |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
41 call mkdir('Xdir1') |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
42 call mkdir('Xdir2') |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
43 call mkdir('Xdir3') |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 endfunction |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 let g:cwd=getcwd() |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 function TearDown() |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
48 q |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
49 exec "cd " . g:cwd |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
50 call delete("Xtopdir", "rf") |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 endfunction |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 function Test_GetCwd() |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
54 new a |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
55 new b |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
56 new c |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
57 3wincmd w |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
58 lcd Xdir1 |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
59 call assert_equal("a Xdir1 1", GetCwdInfo(0, 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
60 call assert_equal(g:topdir, getcwd(-1)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
61 wincmd W |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
62 call assert_equal("b Xtopdir 0", GetCwdInfo(0, 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
63 call assert_equal(g:topdir, getcwd(-1)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
64 wincmd W |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
65 lcd Xdir3 |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
66 call assert_equal("c Xdir3 1", GetCwdInfo(0, 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
67 call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
68 call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
69 call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
70 call assert_equal(g:topdir, getcwd(-1)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
71 wincmd W |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
72 call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr())) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
73 call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), tabpagenr())) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
74 call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr())) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
75 call assert_equal(g:topdir, getcwd(-1)) |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
77 tabnew x |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
78 new y |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
79 new z |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
80 3wincmd w |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
81 call assert_equal("x Xtopdir 0", GetCwdInfo(0, 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
82 call assert_equal(g:topdir, getcwd(-1)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
83 wincmd W |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
84 lcd Xdir2 |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
85 call assert_equal("y Xdir2 1", GetCwdInfo(0, 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
86 call assert_equal(g:topdir, getcwd(-1)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
87 wincmd W |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
88 lcd Xdir3 |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
89 call assert_equal("z Xdir3 1", GetCwdInfo(0, 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
90 call assert_equal("x Xtopdir 0", GetCwdInfo(bufwinnr("x"), 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
91 call assert_equal("y Xdir2 1", GetCwdInfo(bufwinnr("y"), 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
92 call assert_equal("z Xdir3 1", GetCwdInfo(bufwinnr("z"), 0)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
93 call assert_equal(g:topdir, getcwd(-1)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
94 let tp_nr = tabpagenr() |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
95 tabrewind |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
96 call assert_equal("x Xtopdir 0", GetCwdInfo(3, tp_nr)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
97 call assert_equal("y Xdir2 1", GetCwdInfo(2, tp_nr)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
98 call assert_equal("z Xdir3 1", GetCwdInfo(1, tp_nr)) |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
99 call assert_equal(g:topdir, getcwd(-1)) |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 endfunc |
14834
ae62baca938c
patch 8.1.0429: no test for :lcd with 'shellslash'
Christian Brabandt <cb@256bit.org>
parents:
13229
diff
changeset
|
101 |
ae62baca938c
patch 8.1.0429: no test for :lcd with 'shellslash'
Christian Brabandt <cb@256bit.org>
parents:
13229
diff
changeset
|
102 function Test_GetCwd_lcd_shellslash() |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
103 new |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
104 let root = fnamemodify('/', ':p') |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
105 exe 'lcd '.root |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
106 let cwd = getcwd() |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
107 if !exists('+shellslash') || &shellslash |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
108 call assert_equal(cwd[-1:], '/') |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
109 else |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
110 call assert_equal(cwd[-1:], '\') |
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14834
diff
changeset
|
111 endif |
14834
ae62baca938c
patch 8.1.0429: no test for :lcd with 'shellslash'
Christian Brabandt <cb@256bit.org>
parents:
13229
diff
changeset
|
112 endfunc |