Skip to content

Commit 21f6e7c

Browse files
committed
Fixed corrupted text snippet report
Precalculate longest compiler name and use that value to ensure compiler table rows line up correctly.
1 parent ad9156e commit 21f6e7c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Src/UTextSnippetDoc.pas

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,21 @@ procedure TTextSnippetDoc.RenderActiveText(ActiveText: IActiveText);
123123
procedure TTextSnippetDoc.RenderCompilerInfo(const Heading: string;
124124
const Info: TCompileDocInfoArray);
125125
var
126-
Idx: Integer; // loops compiler information table
126+
MaxNameLength: Integer;
127+
CompilerInfo: TCompileDocInfo;
127128
begin
129+
// Calculate length of longest compiler name
130+
MaxNameLength := 0;
131+
for CompilerInfo in Info do
132+
if Length(CompilerInfo.Compiler) > MaxNameLength then
133+
MaxNameLength := Length(CompilerInfo.Compiler);
134+
// Write out compilers with results
128135
fWriter.WriteLine;
129136
fWriter.WriteLine(Heading);
130-
for Idx := Low(Info) to High(Info) do
131-
fWriter.WriteLine('%-20s%s', [Info[Idx].Compiler, Info[Idx].Result]);
137+
for CompilerInfo in Info do
138+
fWriter.WriteLine(
139+
'%-*s%s', [MaxNameLength + 4, CompilerInfo.Compiler, CompilerInfo.Result]
140+
);
132141
end;
133142

134143
procedure TTextSnippetDoc.RenderDBInfo(const Text: string);

0 commit comments

Comments
 (0)