From: Tom Lane Date: Tue, 20 Jun 2017 20:50:22 +0000 (-0400) Subject: Tweak comment indentation to preserve 8-column-at-a-time rule. X-Git-Tag: REL_2_1_1~9 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=1c64f6883442e8e5f9ede00002dbeb7af073e90f;p=pg_bsd_indent.git Tweak comment indentation to preserve 8-column-at-a-time rule. BSD indent places comments that follow code on a line in column 33 (or whatever -c selects), or as many tab stops to the right of that as are needed to clear the code. In PG's old pgindent implementation, indent believed it was working with 8-column tabs so that's where such comments got placed. In the new implementation, indent knows it's working with 4-column tab stops, so that affects the placement of such comments. That's an improvement, since it often allows more comment text on a line. However, I'd like to absorb that change separately from all the other ones, just to keep the diffs a bit more reviewable. Hence, temporarily hack the comment indent logic so that it does 8-column indents regardless of the -ts setting. This hack also preserves (more or less) some odd behavior right at the boundary. --- diff --git a/pr_comment.c b/pr_comment.c index b0eacac..8f90b8f 100644 --- a/pr_comment.c +++ b/pr_comment.c @@ -147,7 +147,9 @@ pr_comment(void) else ps.com_col = ps.decl_on_line || ps.ind_level == 0 ? ps.decl_com_ind : ps.com_ind; - if (ps.com_col <= target_col) + if (ps.com_col < target_col) + ps.com_col = 8 * (1 + (target_col - 1) / 8) + 1; + else if (ps.com_col == target_col) ps.com_col = tabsize * (1 + (target_col - 1) / tabsize) + 1; if (ps.com_col + 24 > adj_max_col) adj_max_col = ps.com_col + 24;