diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-08-31 08:25:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-31 08:25:16 -0400 |
commit | 2bbbb34ce78ee30c1ee53a9cb3fd1e7608185716 (patch) | |
tree | 875713dfc511297f472fe6ffebb0ea4f14548420 /src/nvim/ex_cmds.c | |
parent | 24b5f69a4922e53baa46faf4f5e0b05da42cd2d5 (diff) | |
parent | 62ba227155b59c59f4d2d926bf2d4ed7168a0d97 (diff) | |
download | rneovim-2bbbb34ce78ee30c1ee53a9cb3fd1e7608185716.tar.gz rneovim-2bbbb34ce78ee30c1ee53a9cb3fd1e7608185716.tar.bz2 rneovim-2bbbb34ce78ee30c1ee53a9cb3fd1e7608185716.zip |
Merge pull request #12804 from janlazo/vim-8.1.1725
[RDY]vim-patch:8.1.{1694,1725,1776,1804,1806,1831,2041,2198,2206},8.2.{1033,1315,1548}
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 519978f4fb..2bac6cba58 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -326,14 +326,19 @@ static int linelen(int *has_tab) int save; int len; - /* find the first non-blank character */ + // Get the line. If it's empty bail out early (could be the empty string + // for an unloaded buffer). line = get_cursor_line_ptr(); + if (*line == NUL) { + return 0; + } + // find the first non-blank character first = skipwhite(line); - /* find the character after the last non-blank character */ + // find the character after the last non-blank character for (last = first + STRLEN(first); - last > first && ascii_iswhite(last[-1]); --last) - ; + last > first && ascii_iswhite(last[-1]); last--) { + } save = *last; *last = NUL; // Get line length. |