mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
vim-patch:8.2.3615: wrong indent in first line if re-formatting with indent expr
Problem: When re-formatting with an indent expression the first line of a
paragraph may get the wrong indent. (Martin F. Krafft)
Solution: Apply the correct indenting function for the first line.
(Christian Brabandt, closes vim/vim#9150, closes vim/vim#9056)
818ff25cd1
This commit is contained in:
@@ -4547,9 +4547,20 @@ void format_lines(linenr_T line_count, int avoid_fex)
|
||||
*/
|
||||
if (is_end_par || force_format) {
|
||||
if (need_set_indent) {
|
||||
int indent = 0; // amount of indent needed
|
||||
|
||||
// replace indent in first line with minimal number of
|
||||
// tabs and spaces, according to current options
|
||||
(void)set_indent(get_indent(), SIN_CHANGED);
|
||||
if (curbuf->b_p_lisp) {
|
||||
indent = get_lisp_indent();
|
||||
} else {
|
||||
if (cindent_on()) {
|
||||
indent = *curbuf->b_p_inde != NUL ? get_expr_indent() : get_c_indent();
|
||||
} else {
|
||||
indent = get_indent();
|
||||
}
|
||||
}
|
||||
(void)set_indent(indent, SIN_CHANGED);
|
||||
}
|
||||
|
||||
// put cursor on last non-space
|
||||
|
Reference in New Issue
Block a user