Mercurial > vim
annotate src/kword_test.c @ 16666:978bcd70883d v8.1.1335
patch 8.1.1335: listener callback is called after inserting text
commit https://github.com/vim/vim/commit/dda4144d39a9d685b8dda830978e7410bd372c40
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu May 16 22:11:47 2019 +0200
patch 8.1.1335: listener callback is called after inserting text
Problem: Listener callback is called after inserting text.
Solution: Flush the changes before inserting or deleting a line. Store
changes per buffer.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 16 May 2019 22:15:06 +0200 |
parents | 536dd2bc5ac9 |
children | f41b55f9357c |
rev | line source |
---|---|
10724
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 * |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 * |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 */ |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 /* |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 * kword_test.c: Unittests for vim_iswordc() and vim_iswordp(). |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 */ |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 #undef NDEBUG |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 #include <assert.h> |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 /* Must include main.c because it contains much more than just main() */ |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 #define NO_VIM_MAIN |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 #include "main.c" |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 /* This file has to be included because the tested functions are static */ |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 #include "charset.c" |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 /* |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 * Test the results of vim_iswordc() and vim_iswordp() are matched. |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 */ |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 static void |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 test_isword_funcs_utf8(void) |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 { |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 buf_T buf; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 int c; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 vim_memset(&buf, 0, sizeof(buf)); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 p_enc = (char_u *)"utf-8"; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 p_isi = (char_u *)""; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 p_isp = (char_u *)""; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 p_isf = (char_u *)""; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 buf.b_p_isk = (char_u *)"@,48-57,_,128-167,224-235"; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 curbuf = &buf; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 mb_init(); /* calls init_chartab() */ |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 for (c = 0; c < 0x10000; ++c) |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 { |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 char_u p[4] = {0}; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 int c1; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 int retc; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 int retp; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 utf_char2bytes(c, p); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 c1 = utf_ptr2char(p); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 if (c != c1) |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 { |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 fprintf(stderr, "Failed: "); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 fprintf(stderr, |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 "[c = %#04x, p = {%#02x, %#02x, %#02x}] ", |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 c, p[0], p[1], p[2]); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 fprintf(stderr, "c != utf_ptr2char(p) (=%#04x)\n", c1); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 abort(); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 } |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 retc = vim_iswordc_buf(c, &buf); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 retp = vim_iswordp_buf(p, &buf); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 if (retc != retp) |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 { |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 fprintf(stderr, "Failed: "); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 fprintf(stderr, |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 "[c = %#04x, p = {%#02x, %#02x, %#02x}] ", |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 c, p[0], p[1], p[2]); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 fprintf(stderr, "vim_iswordc(c) (=%d) != vim_iswordp(p) (=%d)\n", |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 retc, retp); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 abort(); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 } |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 } |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 } |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 int |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 main(void) |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 { |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 test_isword_funcs_utf8(); |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 return 0; |
ae1c6bf22e5f
patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 } |