diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2015-04-26 23:48:01 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-04-26 23:48:01 -0400 |
commit | b85db92d7f88aa9636bdc5b49d0f4d7d50eba389 (patch) | |
tree | 644861fc86c3477e45143223a9780122b1d5b84d | |
parent | e692930af2e400a456299695fbcd44176c0ab475 (diff) | |
parent | 86e2d59b8d7b8d51e4970f685f2ce0104d354344 (diff) | |
download | rneovim-b85db92d7f88aa9636bdc5b49d0f4d7d50eba389.tar.gz rneovim-b85db92d7f88aa9636bdc5b49d0f4d7d50eba389.tar.bz2 rneovim-b85db92d7f88aa9636bdc5b49d0f4d7d50eba389.zip |
Merge #2319 'ex_getln: Fixes for getexmodeline()'
-rw-r--r-- | src/nvim/ex_getln.c | 37 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
2 files changed, 27 insertions, 12 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e4c02a0c30..65d6dd676f 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1781,24 +1781,29 @@ getexmodeline ( msg_col = startcol; msg_clr_eos(); line_ga.ga_len = 0; - continue; + goto redraw; } + int num_spaces; if (c1 == Ctrl_T) { int sw = get_sw_value(curbuf); p = (char_u *)line_ga.ga_data; p[line_ga.ga_len] = NUL; indent = get_indent_str(p, 8, FALSE); - indent += sw - indent % sw; + num_spaces = sw - indent % sw; + indent += num_spaces; add_indent: - while (get_indent_str(p, 8, FALSE) < indent) { + if (num_spaces > 0) { + ga_grow(&line_ga, num_spaces + 1); + p = (char_u *)line_ga.ga_data; char_u *s = skipwhite(p); - ga_grow(&line_ga, 1); - memmove(s + 1, s, line_ga.ga_len - (s - p) + 1); - *s = ' '; - ++line_ga.ga_len; + // Insert spaces after leading whitespaces. + memmove(s + num_spaces, s, line_ga.ga_len - (s - p) + 1); + memset(s, ' ', num_spaces); + + line_ga.ga_len += num_spaces; } redraw: /* redraw the line */ @@ -1835,15 +1840,25 @@ redraw: } else { p[line_ga.ga_len] = NUL; indent = get_indent_str(p, 8, FALSE); + if (indent == 0) { + continue; + } --indent; indent -= indent % get_sw_value(curbuf); } - while (get_indent_str(p, 8, FALSE) > indent) { - char_u *s = skipwhite(p); - memmove(s - 1, s, line_ga.ga_len - (s - p) + 1); - --line_ga.ga_len; + // reduce the line's indentation + char_u *from = skipwhite(p); + char_u *to = from; + int old_indent; + while ((old_indent = get_indent_str(p, 8, FALSE)) > indent) { + *--to = NUL; } + memmove(to, from, line_ga.ga_len - (from - p) + 1); + line_ga.ga_len -= from - to; + + // Removed to much indentation, fix it before redrawing. + num_spaces = indent - old_indent; goto add_indent; } diff --git a/src/nvim/version.c b/src/nvim/version.c index d292039cc7..44adad70e0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -79,7 +79,7 @@ static int included_patches[] = { //693, //692, //691, - //690, + 690, //689, //688, //687, |