diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-02-10 19:02:12 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-02-10 19:02:12 +0100 |
| commit | 99a1e191b639487588b846471dc2c7d4a5b2f3a7 (patch) | |
| tree | 7d1335eaf6b822aa533f0a7627172318fbf0cf1a /main.c | |
| parent | da0241ba3981d7fac30d388af3ecf728bc65ee02 (diff) | |
| download | vis-99a1e191b639487588b846471dc2c7d4a5b2f3a7.tar.gz vis-99a1e191b639487588b846471dc2c7d4a5b2f3a7.tar.xz | |
vis: make r handle special keys like <Tab>
Unlike vim we do not respect `:set expandtab` here.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -1653,15 +1653,11 @@ static const char *replace(Vis *vis, const char *keys, const Arg *arg) { if (!next) return NULL; - char replacement[64]; - size_t len = next - keys; - if (len >= sizeof(replacement)) + char replacement[UTFmax+1]; + if (!vis_keys_utf8(vis, keys, replacement)) return next; - memcpy(replacement, keys, len); - replacement[len] = '\0'; - - if (strcmp("<Escape>", replacement) == 0) + if (replacement[0] == 0x1b) /* <Escape> */ return next; if (vis_mode_get(vis) == VIS_MODE_NORMAL) { @@ -1669,7 +1665,7 @@ static const char *replace(Vis *vis, const char *keys, const Arg *arg) { vis_operator(vis, VIS_OP_CHANGE); vis_motion(vis, VIS_MOVE_CHAR_NEXT); for (; count > 0; count--) - vis_keys_feed(vis, replacement); + vis_keys_feed(vis, replacement[0] == '\n' ? "<Enter>" : replacement); } else { vis_operator(vis, VIS_OP_REPLACE, replacement); } |
