Fix example code just showing endless spinner when deployed from Windows (#14878)

* If example code is not found, render a message instead of an endless spinner
* Trim codeTags to avoid lookup issues with windows carriage returns
* Trim \r on Windows off the end of code blocks so they're consistently \n
* Add a test to ensure sample code parses if built on Windows
* Add a comment about why we trimRight()

Fixes #14820.
This commit is contained in:
Danny Tuppeny
2018-02-28 20:39:48 +00:00
committed by GitHub
parent e0956cbdb7
commit ae9fdefa4f
3 changed files with 10 additions and 3 deletions

View File

@@ -33,7 +33,7 @@ Future<Null> _parseExampleCode(AssetBundle bundle) async {
if (line.startsWith(_kStartTag)) {
// Starting a new code block.
codeBlock = <String>[];
codeTag = line.substring(_kStartTag.length);
codeTag = line.substring(_kStartTag.length).trim();
} else {
// Just skipping the line.
}
@@ -46,7 +46,9 @@ Future<Null> _parseExampleCode(AssetBundle bundle) async {
codeTag = null;
} else {
// Add to the current block
codeBlock.add(line);
// trimRight() to remove any \r on Windows
// without removing any useful indentation
codeBlock.add(line.trimRight());
}
}
}