mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
[html] filter empty lines in virtual documents
This commit is contained in:
parent
5bacd045c0
commit
eec57b4f9d
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue