diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-01-20 13:11:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-20 13:11:26 +0100 |
commit | 4b2759b6dadced6648a53f3ba9f3bd039ecbbd8f (patch) | |
tree | 4c985a71ecd386a8492e31ee41e05cab831d6751 /src/nvim/message.c | |
parent | e7de3b5f841ec25fa9158380ca4ac54403003bc0 (diff) | |
parent | 0060974b2bdd28edf9d34a53daa7862ce55b1f43 (diff) | |
download | rneovim-4b2759b6dadced6648a53f3ba9f3bd039ecbbd8f.tar.gz rneovim-4b2759b6dadced6648a53f3ba9f3bd039ecbbd8f.tar.bz2 rneovim-4b2759b6dadced6648a53f3ba9f3bd039ecbbd8f.zip |
vim-patch:7.4.2049,7.4.2050,7.4.2064,7.4.2067,7.4.2081 (#5969)
vim-patch:7.4.2049,7.4.2050,7.4.2064,7.4.2067,7.4.2081
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 2f8feda6ec..749fa8a706 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -297,8 +297,22 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen) len += n; } - /* Set the middle and copy the last part. */ - if (e + 3 < buflen) { + if (i <= e + 3) { + // text fits without truncating + if (s != buf) { + len = STRLEN(s); + if (len >= buflen) { + len = buflen - 1; + } + len = len - e + 1; + if (len < 1) { + buf[e - 1] = NUL; + } else { + memmove(buf + e, s + e, len); + } + } + } else if (e + 3 < buflen) { + // set the middle and copy the last part memmove(buf + e, "...", (size_t)3); len = (int)STRLEN(s + i) + 1; if (len >= buflen - e - 3) @@ -306,7 +320,8 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen) memmove(buf + e + 3, s + i, len); buf[e + 3 + len - 1] = NUL; } else { - buf[e - 1] = NUL; /* make sure it is truncated */ + // can't fit in the "...", just truncate it + buf[e - 1] = NUL; } } |