Skip to content

Commit

Permalink
Merge pull request ExtendRealityLtd#1343 from bddckr/fix/UpdatePrompt…
Browse files Browse the repository at this point in the history
…-unnecessary-pagination

fix(UpdatePrompt): unnecessary pagination
  • Loading branch information
thestonefox authored Jul 6, 2017
2 parents ba3930e + 5113b19 commit e75fc1e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Assets/VRTK/Editor/VRTK_UpdatePrompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,26 @@ public static LatestRelease CreateFromJSON(string json)
const int textLengthLimit = 65536 / 4 - 100;
latestRelease.changelogPages = new List<string>((int)Mathf.Ceil(changelog.Length / (float)textLengthLimit));

while (changelog.Length > 0)
while (true)
{
int lastIndexOf = changelog.LastIndexOf("\n", Math.Min(changelog.Length, textLengthLimit), StringComparison.Ordinal);
if (lastIndexOf == -1)
if (changelog.Length > textLengthLimit)
{
lastIndexOf = changelog.Length;
}
int startIndex = Math.Min(changelog.Length, textLengthLimit);
int lastIndexOf = changelog.LastIndexOf("\n", startIndex, StringComparison.Ordinal);

if (lastIndexOf == -1)
{
lastIndexOf = startIndex;
}

latestRelease.changelogPages.Add(changelog.Substring(0, lastIndexOf));
changelog = changelog.Substring(lastIndexOf).TrimStart('\n', '\r');
latestRelease.changelogPages.Add(changelog.Substring(0, lastIndexOf));
changelog = changelog.Substring(lastIndexOf).TrimStart('\n', '\r');
}
else
{
latestRelease.changelogPages.Add(changelog);
break;
}
}

return latestRelease;
Expand Down

0 comments on commit e75fc1e

Please sign in to comment.