diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-07-03 14:48:15 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-07-03 14:48:15 +0200 |
commit | 972bfddc6b3f52ae0865ad8c0bf6089bc8a9883a (patch) | |
tree | dbd95dd25564d1c34c30fbfe22c130e6927c79d4 /src/getchar.c | |
parent | a8a60d0c6b292216e55f005cf9637789a771d34b (diff) | |
download | vim-git-972bfddc6b3f52ae0865ad8c0bf6089bc8a9883a.tar.gz |
patch 8.1.0140: recording into a register has focus eventsv8.1.0140
Problem: Recording into a register has focus events. (Michael Naumann)
Solution: Don't record K_FOCUSGAINED and K_FOCUSLOST. (closes #3143)
Diffstat (limited to 'src/getchar.c')
-rw-r--r-- | src/getchar.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/getchar.c b/src/getchar.c index ce7508c56..cc43ef24a 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -1246,27 +1246,43 @@ del_typebuf(int len, int offset) static void gotchars(char_u *chars, int len) { - char_u *s = chars; - int c; - char_u buf[2]; - int todo = len; - - /* remember how many chars were last recorded */ - if (reg_recording != 0) - last_recorded_len += len; + char_u *s = chars; + int i; + static char_u buf[4]; + static int buflen = 0; + int todo = len; - buf[1] = NUL; while (todo--) { + buf[buflen++] = *s++; + + // When receiving a special key sequence, store it until we have all + // the bytes and we can decide what to do with it. + if (buflen == 1 && buf[0] == K_SPECIAL) + continue; + if (buflen == 2) + continue; + if (buflen == 3 && buf[1] == KS_EXTRA + && (buf[2] == KE_FOCUSGAINED || buf[2] == KE_FOCUSLOST)) + { + // Drop K_FOCUSGAINED and K_FOCUSLOST, they are not useful in a + // recording. + buflen = 0; + continue; + } + /* Handle one byte at a time; no translation to be done. */ - c = *s++; - updatescript(c); + for (i = 0; i < buflen; ++i) + updatescript(buf[i]); if (reg_recording != 0) { - buf[0] = c; - add_buff(&recordbuff, buf, 1L); + buf[buflen] = NUL; + add_buff(&recordbuff, buf, (long)buflen); + /* remember how many chars were last recorded */ + last_recorded_len += buflen; } + buflen = 0; } may_sync_undo(); |