Browse Source

fix: prevent null startLine from causing unnecessary line append in CodeBuilder

Akeit0 7 months ago
parent
commit
3dc8e41fd1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/Lua.SourceGenerator/Utilities/CodeBuilder.cs

+ 2 - 2
src/Lua.SourceGenerator/Utilities/CodeBuilder.cs

@@ -11,7 +11,7 @@ internal sealed class CodeBuilder
         public IndentScope(CodeBuilder source, string? startLine = null)
         public IndentScope(CodeBuilder source, string? startLine = null)
         {
         {
             this.source = source;
             this.source = source;
-            source.AppendLine(startLine);
+            if(startLine!=null) source.AppendLine(startLine);
             source.IncreaseIndent();
             source.IncreaseIndent();
         }
         }
 
 
@@ -28,7 +28,7 @@ internal sealed class CodeBuilder
         public BlockScope(CodeBuilder source, string? startLine = null)
         public BlockScope(CodeBuilder source, string? startLine = null)
         {
         {
             this.source = source;
             this.source = source;
-            source.AppendLine(startLine);
+            if(startLine!=null) source.AppendLine(startLine);
             source.BeginBlock();
             source.BeginBlock();
         }
         }