Skip to content

Commit

Permalink
Don't crash if input line exceeds max padding
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPa committed Jun 2, 2021
1 parent b564644 commit b511cd2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ClangFormatEditor/ClangFormatEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Authors>Caphyon</Authors>
<Product>Clang-Format Editor</Product>
<RepositoryUrl>https://github.com/Caphyon/clang-format-detector</RepositoryUrl>
<Version>7.3.0</Version>
<Version>7.3.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions ClangFormatEditor/DiffStyle/DiffMatchPatchWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ private int GetMaxLineWidth(List<string> lines)
private static string AddPadding(string text, int targetPadding, bool isNewLine)
{
var paddingCount = targetPadding - text.Length;
// if too long, then don't pad at all!
if (paddingCount < 0)
{
paddingCount = 0;
}
if (isNewLine)
{
return new string(' ', paddingCount) + text;
Expand Down
4 changes: 2 additions & 2 deletions ClangFormatEditor/MVVM/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@
<TextBlock
Grid.Row="8"
Grid.Column="4"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="10"
Foreground="White"
Text="{Binding Version}" />
Expand Down

0 comments on commit b511cd2

Please sign in to comment.