Skip to content

fix: resolve comment end confusion inside inline JavaScript (#151)#245

Open
maruthang wants to merge 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-151-comment-end-confusion-inline-js
Open

fix: resolve comment end confusion inside inline JavaScript (#151)#245
maruthang wants to merge 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-151-comment-end-confusion-inline-js

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

Summary

Fixes #151

Bug: --> inside JavaScript block comments within inline <script> tags was being incorrectly replaced, breaking intellisense.

Root Cause: The comment marker replacement logic did not track whether <!-- / --> markers were actually paired, so stray --> tokens (e.g., inside /* --> */) were incorrectly converted to */.

Fix: Added a new convertScriptContentToJavaScript utility function that uses depth tracking to only replace matched <!-- / --> pairs with /* / */. Unpaired --> markers are left untouched. The function is exported from the main entry point for consumers.

Changes

  • src/parser/htmlScanner.ts: Added convertScriptContentToJavaScript function with depth-based pair matching
  • src/htmlLanguageService.ts: Re-exported the new function from the public API surface
  • src/test/scanner.test.ts: Added 8 regression tests covering paired markers, unpaired -->, nested markers, empty content, and edge cases

Testing

  • Added 8 regression tests in src/test/scanner.test.ts verifying correct handling of paired and unpaired HTML comment markers
  • All 161 tests pass

…t#151)

Add convertScriptContentToJavaScript utility that uses depth tracking
to only replace paired <!-- / --> markers with JS block comments,
leaving unpaired --> (e.g. inside JS block comments) untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment end confusion inside inline Javascript intellisense

1 participant