提交 eec57b4f 编写于 作者: M Martin Aeschlimann

[html] filter empty lines in virtual documents

上级 5bacd045
......@@ -44,12 +44,28 @@ export function getEmbeddedContent(languageService: LanguageService, document: T
}
function substituteWithWhitespace(result, start, end, oldContent) {
let accumulatedWS = 0;
for (let i = start; i < end; i++) {
let ch = oldContent[i];
if (ch !== '\n' && ch !== '\r') {
ch = ' ';
if (ch === '\n' || ch === '\r') {
// only write new lines, skip the whitespace
accumulatedWS = 0;
result += ch;
} else {
accumulatedWS++;
}
result += ch;
}
result = append(result, ' ', accumulatedWS);
return result;
}
function append(result: string, str: string, n: number): string {
while (n) {
if (n & 1) {
result += str;
}
n >>= 1;
str += str;
}
return result;
}
......
......@@ -52,6 +52,8 @@ suite('HTML Embedded Support', () => {
assertEmbeddedLanguageContent('<html><style>foo { }</style></html>', 'css', ' foo { } ');
assertEmbeddedLanguageContent('<html><script>var i = 0;</script></html>', 'css', ' ');
assertEmbeddedLanguageContent('<html><style>foo { }</style>Hello<style>foo { }</style></html>', 'css', ' foo { } foo { } ');
assertEmbeddedLanguageContent('<html>\n <style>\n foo { } \n </style>\n</html>\n', 'css', '\n \n foo { } \n \n\n');
});
test('Scripts', function (): any {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册