diff --git a/src/vs/editor/common/model/textModelTokens.ts b/src/vs/editor/common/model/textModelTokens.ts index 65098e266a16478c40b34b586424ccce9bcf467a..c5f2e74f03405ab91d3a739531c2a803414ea1d8 100644 --- a/src/vs/editor/common/model/textModelTokens.ts +++ b/src/vs/editor/common/model/textModelTokens.ts @@ -11,7 +11,7 @@ import { Range } from 'vs/editor/common/core/range'; import { TokenizationResult2 } from 'vs/editor/common/core/token'; import { ITextBuffer } from 'vs/editor/common/model'; import { IModelTokensChangedEvent } from 'vs/editor/common/model/textModelEvents'; -import { ColorId, FontStyle, IState, ITokenizationSupport, LanguageId, LanguageIdentifier, MetadataConsts, StandardTokenType } from 'vs/editor/common/modes'; +import { ColorId, FontStyle, IState, ITokenizationSupport, LanguageId, LanguageIdentifier, MetadataConsts, StandardTokenType, TokenMetadata } from 'vs/editor/common/modes'; import { nullTokenize2 } from 'vs/editor/common/modes/nullMode'; function getDefaultMetadata(topLevelLanguageId: LanguageId): number { @@ -262,8 +262,15 @@ export class ModelLinesTokens { } if (lineTextLength === 0) { - target._lineTokens = EMPTY_LINE_TOKENS; - return; + let hasDifferentLanguageId = false; + if (tokens && tokens.length > 1) { + hasDifferentLanguageId = (TokenMetadata.getLanguageId(tokens[1]) !== topLevelLanguageId); + } + + if (!hasDifferentLanguageId) { + target._lineTokens = EMPTY_LINE_TOKENS; + return; + } } if (!tokens || tokens.length === 0) { diff --git a/src/vs/editor/contrib/comment/test/lineCommentCommand.test.ts b/src/vs/editor/contrib/comment/test/lineCommentCommand.test.ts index d9bec641e92381a9fdc26da5bdbe612526574d25..a32458d6abdd53f27620abb7b5b07baa6fe8bfa7 100644 --- a/src/vs/editor/contrib/comment/test/lineCommentCommand.test.ts +++ b/src/vs/editor/contrib/comment/test/lineCommentCommand.test.ts @@ -1056,21 +1056,4 @@ suite('Editor Contrib - Line Comment in mixed modes', () => { new Selection(2, 8, 2, 8), ); }); - - test.skip('issue #63822: Commenting code in JSX tag body from line 0', () => { - testLineCommentCommand( - [ - '