From 84241189f6a68611f79e9a3d78fc0192e1008cb1 Mon Sep 17 00:00:00 2001
From: Alex Turbov <i.zaufi@gmail.com>
Date: Tue, 23 Aug 2022 10:00:53 +0400
Subject: cmDocumentationFormatter: Prevent indentation reset side effect

Fix `cmDocumentationFormatter::PrintColumn()` method to eliminate
an indentation reset side effect.
---
 Source/cmDocumentationFormatter.cxx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx
index e2c521d..8f0976c 100644
--- a/Source/cmDocumentationFormatter.cxx
+++ b/Source/cmDocumentationFormatter.cxx
@@ -153,8 +153,6 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text)
 void cmDocumentationFormatter::PrintSection(
   std::ostream& os, cmDocumentationSection const& section)
 {
-  os << section.GetName() << '\n';
-
   const std::size_t PREFIX_SIZE =
     sizeof(cmDocumentationEntry::CustomNamePrefix) + 1u;
   // length of the "= " literal (see below)
@@ -165,6 +163,10 @@ void cmDocumentationFormatter::PrintSection(
   const std::size_t PADDING_SIZE = PREFIX_SIZE + SUFFIX_SIZE;
   const std::size_t TITLE_SIZE = NAME_SIZE + PADDING_SIZE;
 
+  const auto savedIndent = this->TextIndent;
+
+  os << section.GetName() << '\n';
+
   for (cmDocumentationEntry const& entry : section.GetEntries()) {
     if (!entry.Name.empty()) {
       this->TextIndent = TITLE_SIZE;
@@ -183,5 +185,8 @@ void cmDocumentationFormatter::PrintSection(
       this->PrintFormatted(os, entry.Brief.c_str());
     }
   }
+
   os << '\n';
+
+  this->TextIndent = savedIndent;
 }
-- 
cgit v0.12