Mercurial > vim
comparison src/message_test.c @ 24709:9d304d363ab6 v8.2.2893
patch 8.2.2893: multi-byte text in popup title shows up wrong
Commit: https://github.com/vim/vim/commit/bc869874fedf094129831836f131c64f10d98854
Author: Ralf Schandl <rakus@users.noreply.github.com>
Date: Fri May 28 14:12:14 2021 +0200
patch 8.2.2893: multi-byte text in popup title shows up wrong
Problem: Multi-byte text in popup title shows up wrong.
Solution: Use the character width instead of the byte length. (Ralf Schandl,
closes #8267, closes #8264)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 28 May 2021 14:15:03 +0200 |
parents | 0b1f5717dc4d |
children | 4dcccb2673fe |
comparison
equal
deleted
inserted
replaced
24708:46c0305949ee | 24709:9d304d363ab6 |
---|---|
114 | 114 |
115 buf = alloc(40); | 115 buf = alloc(40); |
116 s = vim_strsave((char_u *)"a text that nott fits"); | 116 s = vim_strsave((char_u *)"a text that nott fits"); |
117 trunc_string(s, buf, 20, 40); | 117 trunc_string(s, buf, 20, 40); |
118 assert(STRCMP(buf, "a text t...nott fits") == 0); | 118 assert(STRCMP(buf, "a text t...nott fits") == 0); |
119 vim_free(buf); | |
120 vim_free(s); | |
121 } | |
122 | |
123 /* | |
124 * Test trunc_string() with mbyte chars. | |
125 */ | |
126 static void | |
127 test_trunc_string_mbyte(void) | |
128 { | |
129 char_u *buf; // allocated every time to find uninit errors | |
130 char_u *s; | |
131 | |
132 buf = alloc(40); | |
133 s = vim_strsave((char_u *)"Ä text tha just fits"); | |
134 trunc_string(s, buf, 20, 40); | |
135 assert(STRCMP(buf, "Ä text tha just fits") == 0); | |
136 vim_free(buf); | |
137 vim_free(s); | |
138 | |
139 buf = alloc(40); | |
140 s = vim_strsave((char_u *)"a text ÄÖÜä nott fits"); | |
141 trunc_string(s, buf, 20, 40); | |
142 assert(STRCMP(buf, "a text Ä...nott fits") == 0); | |
143 vim_free(buf); | |
144 vim_free(s); | |
145 | |
146 buf = alloc(40); | |
147 s = vim_strsave((char_u *)"a text that not fitsÄ"); | |
148 trunc_string(s, buf, 20, 40); | |
149 assert(STRCMP(buf, "a text t...not fitsÄ") == 0); | |
119 vim_free(buf); | 150 vim_free(buf); |
120 vim_free(s); | 151 vim_free(s); |
121 } | 152 } |
122 | 153 |
123 /* | 154 /* |
284 common_init(¶ms); | 315 common_init(¶ms); |
285 | 316 |
286 set_option_value((char_u *)"encoding", 0, (char_u *)"utf-8", 0); | 317 set_option_value((char_u *)"encoding", 0, (char_u *)"utf-8", 0); |
287 init_chartab(); | 318 init_chartab(); |
288 test_trunc_string(); | 319 test_trunc_string(); |
320 test_trunc_string_mbyte(); | |
289 test_vim_snprintf(); | 321 test_vim_snprintf(); |
290 | 322 |
291 set_option_value((char_u *)"encoding", 0, (char_u *)"latin1", 0); | 323 set_option_value((char_u *)"encoding", 0, (char_u *)"latin1", 0); |
292 init_chartab(); | 324 init_chartab(); |
293 test_trunc_string(); | 325 test_trunc_string(); |