Mercurial > vim
annotate src/testdir/test_ex_mode.vim @ 18924:a18d7782b80f v8.2.0023
patch 8.2.0023: command line editing not sufficiently tested
Commit: https://github.com/vim/vim/commit/59cb041d0a56d8555857da7e063ec61504ee1fa7
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 18 22:26:31 2019 +0100
patch 8.2.0023: command line editing not sufficiently tested
Problem: Command line editing not sufficiently tested.
Solution: Add more tests. (Dominique Pelle, closes https://github.com/vim/vim/issues/5374)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 18 Dec 2019 22:30:03 +0100 |
parents | |
children | 2f0f308c069c |
rev | line source |
---|---|
18924
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test editing line in Ex mode (see :help Q and :help gQ). |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 " Helper function to test editing line in Q Ex mode |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 func Ex_Q(cmd) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 " Is there a simpler way to test editing Ex line? |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 call feedkeys("Q" |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 \ .. "let s:test_ex =<< END\<CR>" |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 \ .. a:cmd .. "\<CR>" |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 \ .. "END\<CR>" |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 \ .. "visual\<CR>", 'tx') |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 return s:test_ex[0] |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 endfunc |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 " Helper function to test editing line in gQ Ex mode |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 func Ex_gQ(cmd) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 call feedkeys("gQ" .. a:cmd .. "\<C-b>\"\<CR>", 'tx') |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 let ret = @:[1:] " Remove leading quote. |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 call feedkeys("visual\<CR>", 'tx') |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 return ret |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 endfunc |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 " Helper function to test editing line with both Q and gQ Ex mode. |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 func Ex(cmd) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 return [Ex_Q(a:cmd), Ex_gQ(a:cmd)] |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 endfunc |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 " Test editing line in Ex mode (both Q and gQ) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 func Test_ex_mode() |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 let encoding_save = &encoding |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 set sw=2 |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 for e in ['utf8', 'latin1'] |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 exe 'set encoding=' . e |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 call assert_equal(['bar', 'bar'], Ex("foo bar\<C-u>bar"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 call assert_equal(["1\<C-u>2", "1\<C-u>2"], Ex("1\<C-v>\<C-u>2"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 call assert_equal(["1\<C-b>2\<C-e>3", '213'], Ex("1\<C-b>2\<C-e>3"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 call assert_equal(['0123', '2013'], Ex("01\<Home>2\<End>3"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 call assert_equal(['0123', '0213'], Ex("01\<Left>2\<Right>3"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 call assert_equal(['01234', '0342'], Ex("012\<Left>\<Left>\<Insert>3\<Insert>4"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 call assert_equal(["foo bar\<C-w>", 'foo '], Ex("foo bar\<C-w>"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 call assert_equal(['foo', 'foo'], Ex("fooba\<Del>\<Del>"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 call assert_equal(["foo\tbar", 'foobar'], Ex("foo\<Tab>bar"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 call assert_equal(["abbrev\t", 'abbreviate'], Ex("abbrev\<Tab>"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 call assert_equal([' 1', "1\<C-t>\<C-t>"], Ex("1\<C-t>\<C-t>"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 call assert_equal([' 1', "1\<C-t>\<C-t>"], Ex("1\<C-t>\<C-t>\<C-d>"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 call assert_equal([' foo', ' foo'], Ex(" foo\<C-d>"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 call assert_equal(['foo', ' foo0'], Ex(" foo0\<C-d>"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 call assert_equal(['foo', ' foo^'], Ex(" foo^\<C-d>"), e) |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 endfor |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 set sw& |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 let &encoding = encoding_save |
a18d7782b80f
patch 8.2.0023: command line editing not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 endfunc |