diff options
author | Tom Lane | 2017-06-20 20:50:22 +0000 |
---|---|---|
committer | Tom Lane | 2017-06-20 20:50:22 +0000 |
commit | 1c64f6883442e8e5f9ede00002dbeb7af073e90f (patch) | |
tree | a34309883bacb2a296d6410efbf13919b5e8c49a | |
parent | b3b581502dbf2804bc16fc99089d53811f5ef7ee (diff) |
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.
-rw-r--r-- | pr_comment.c | 4 |
1 files changed, 3 insertions, 1 deletions
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; |