Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added files via upload #20

Merged
merged 1 commit into from
Mar 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ViewMinifier/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ private static string ReArrangeDeclaration(string fileContents, string declarati
MatchCollection matches = Regex.Matches(fileContents, declaration);

// Loop through the matches
bool alreadyMatched = false;
int alreadyMatched = 0;
foreach (Match match in matches)
{
int position = declaration.Length;
int declarationPosition = match.Index;

// If we have more than one match, we need to keep the counter moving everytime we add a new line
if (matches.Count > 1 && alreadyMatched)
if (matches.Count > 1 && alreadyMatched > 0)
{
// Cos we added a new line break \n\r
declarationPosition += 2;
// Cos we added one or more new line break \n\r
declarationPosition += (2 * alreadyMatched);
}

while (declarationPosition >= 0)
Expand All @@ -183,7 +183,7 @@ private static string ReArrangeDeclaration(string fileContents, string declarati
{
// Add a line break afterwards
fileContents = fileContents.Replace(substring, substring + Environment.NewLine);
alreadyMatched = true;
alreadyMatched++;
break;
}
}
Expand Down