fix problems with html style comments in embedded code (#160981)

* fix problems with html style comments in embedded code

* add spacings to the replaced characters

add same amount of characters, in the replacements so that all offsets stays the same

* revert javascriptMode.ts

* add replace characters in embeddedSupport.ts instead

* added few more tests with javascript

more testcases with js code before and after the comments

* polish

Co-authored-by: UwUeeb <106700035+UwUeeb@users.noreply.github.com>
Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
This commit is contained in:
w1redch4d
2022-10-26 14:11:05 +05:30
committed by GitHub
parent a887d72e8d
commit 70328b1b48
2 changed files with 10 additions and 1 deletions

View File

@@ -119,7 +119,10 @@ suite('HTML Embedded Support', () => {
test('Script content', function (): any {
assertEmbeddedLanguageContent('<html><script>var i = 0;</script></html>', 'javascript', ' var i = 0; ');
assertEmbeddedLanguageContent('<script type="text/javascript">var i = 0;</script>', 'javascript', ' var i = 0; ');
assertEmbeddedLanguageContent('<script><!--this comment should not give error--></script>', 'javascript', ' /* this comment should not give error */ ');
assertEmbeddedLanguageContent('<script><!--this comment should not give error--> console.log("logging");</script>', 'javascript', ' /* this comment should not give error */ console.log("logging"); ');
assertEmbeddedLanguageContent('<script>var data=100; <!--this comment should not give error--> </script>', 'javascript', ' var data=100; /* this comment should not give error */ ');
assertEmbeddedLanguageContent('<div onKeyUp="foo()" onkeydown="bar()"/>', 'javascript', ' foo(); bar(); ');
assertEmbeddedLanguageContent('<div onKeyUp="return"/>', 'javascript', ' return; ');
assertEmbeddedLanguageContent('<div onKeyUp=return\n/><script>foo();</script>', 'javascript', ' return;\n foo(); ');