Singularity/Library/PackageCache/com.unity.shadergraph@12.1.11/Editor/Utilities/StringBuilderExtensions.cs

34 lines
951 B
C#
Raw Normal View History

2024-05-06 14:45:45 -04:00
using System;
using System.Text;
namespace UnityEditor.ShaderGraph
{
static class StringBuilderExtensions
{
public static void AppendIndentedLines(this StringBuilder sb, string lines, string indentation)
{
sb.EnsureCapacity(sb.Length + lines.Length);
var charIndex = 0;
while (charIndex < lines.Length)
{
var nextNewLineIndex = lines.IndexOf(Environment.NewLine, charIndex, StringComparison.Ordinal);
if (nextNewLineIndex == -1)
{
nextNewLineIndex = lines.Length;
}
sb.Append(indentation);
for (var i = charIndex; i < nextNewLineIndex; i++)
{
sb.Append(lines[i]);
}
sb.AppendLine();
charIndex = nextNewLineIndex + Environment.NewLine.Length;
}
}
}
}