Mercurial > vim
comparison src/getchar.c @ 14247:381b01f77461 v8.1.0140
patch 8.1.0140: recording into a register has focus events
commit https://github.com/vim/vim/commit/972bfddc6b3f52ae0865ad8c0bf6089bc8a9883a
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 3 14:48:15 2018 +0200
patch 8.1.0140: recording into a register has focus events
Problem: Recording into a register has focus events. (Michael Naumann)
Solution: Don't record K_FOCUSGAINED and K_FOCUSLOST. (closes https://github.com/vim/vim/issues/3143)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 03 Jul 2018 15:00:09 +0200 |
parents | bc91de20ba43 |
children | e29cbac5e8f6 |
comparison
equal
deleted
inserted
replaced
14246:bdcaa04baead | 14247:381b01f77461 |
---|---|
1244 * If recording is on put the character in the recordbuffer. | 1244 * If recording is on put the character in the recordbuffer. |
1245 */ | 1245 */ |
1246 static void | 1246 static void |
1247 gotchars(char_u *chars, int len) | 1247 gotchars(char_u *chars, int len) |
1248 { | 1248 { |
1249 char_u *s = chars; | 1249 char_u *s = chars; |
1250 int c; | 1250 int i; |
1251 char_u buf[2]; | 1251 static char_u buf[4]; |
1252 int todo = len; | 1252 static int buflen = 0; |
1253 | 1253 int todo = len; |
1254 /* remember how many chars were last recorded */ | 1254 |
1255 if (reg_recording != 0) | |
1256 last_recorded_len += len; | |
1257 | |
1258 buf[1] = NUL; | |
1259 while (todo--) | 1255 while (todo--) |
1260 { | 1256 { |
1257 buf[buflen++] = *s++; | |
1258 | |
1259 // When receiving a special key sequence, store it until we have all | |
1260 // the bytes and we can decide what to do with it. | |
1261 if (buflen == 1 && buf[0] == K_SPECIAL) | |
1262 continue; | |
1263 if (buflen == 2) | |
1264 continue; | |
1265 if (buflen == 3 && buf[1] == KS_EXTRA | |
1266 && (buf[2] == KE_FOCUSGAINED || buf[2] == KE_FOCUSLOST)) | |
1267 { | |
1268 // Drop K_FOCUSGAINED and K_FOCUSLOST, they are not useful in a | |
1269 // recording. | |
1270 buflen = 0; | |
1271 continue; | |
1272 } | |
1273 | |
1261 /* Handle one byte at a time; no translation to be done. */ | 1274 /* Handle one byte at a time; no translation to be done. */ |
1262 c = *s++; | 1275 for (i = 0; i < buflen; ++i) |
1263 updatescript(c); | 1276 updatescript(buf[i]); |
1264 | 1277 |
1265 if (reg_recording != 0) | 1278 if (reg_recording != 0) |
1266 { | 1279 { |
1267 buf[0] = c; | 1280 buf[buflen] = NUL; |
1268 add_buff(&recordbuff, buf, 1L); | 1281 add_buff(&recordbuff, buf, (long)buflen); |
1269 } | 1282 /* remember how many chars were last recorded */ |
1283 last_recorded_len += buflen; | |
1284 } | |
1285 buflen = 0; | |
1270 } | 1286 } |
1271 may_sync_undo(); | 1287 may_sync_undo(); |
1272 | 1288 |
1273 #ifdef FEAT_EVAL | 1289 #ifdef FEAT_EVAL |
1274 /* output "debug mode" message next time in debug mode */ | 1290 /* output "debug mode" message next time in debug mode */ |