mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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 #9150, closes #9056)
This commit is contained in:
committed by
Bram Moolenaar
parent
6555500bcf
commit
818ff25cd1
@@ -1070,9 +1070,32 @@ format_lines(
|
||||
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);
|
||||
# ifdef FEAT_LISP
|
||||
if (curbuf->b_p_lisp)
|
||||
indent = get_lisp_indent();
|
||||
else
|
||||
# endif
|
||||
{
|
||||
#ifdef FEAT_CINDENT
|
||||
if (cindent_on())
|
||||
{
|
||||
indent =
|
||||
# ifdef FEAT_EVAL
|
||||
*curbuf->b_p_inde != NUL ? get_expr_indent() :
|
||||
# endif
|
||||
get_c_indent();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
indent = get_indent();
|
||||
}
|
||||
(void)set_indent(indent, SIN_CHANGED);
|
||||
}
|
||||
|
||||
// put cursor on last non-space
|
||||
State = NORMAL; // don't go past end-of-line
|
||||
|
Reference in New Issue
Block a user