@@ -418,6 +418,36 @@ function diagnosticsRegularExpressionErrors(diagnostics: Diagnostic[], document:
418418 const trees = getTrees ( document ) ;
419419 const regexNodes = trees . regexNodes ;
420420
421+ const isMarkdownCodeblockInjectionRegex = / ( \b | _ ) ( m a r k d o w n | m a r k d o w n b l o c k | c o d e b l o c k | i n j e c t | i n j e c t i o n ) ( \b | _ ) / ;
422+ let isMarkdownCodeblockInjectionGrammar = 0 ;
423+ if ( isMarkdownCodeblockInjectionRegex . test ( document . fileName ) ) {
424+ isMarkdownCodeblockInjectionGrammar ++ ;
425+ }
426+ const injectionScopesQuery = `;scm
427+ (name_display (value) @name)
428+ (scopeName (value) @scopeName)
429+ (injectionSelector (value (selector) . (scope) @injection))
430+ ` ;
431+ const injectionCaptures = queryNode ( trees . jsonTree . rootNode , injectionScopesQuery ) ;
432+ for ( const injectionCapture of injectionCaptures ) {
433+ const text = injectionCapture . node . text ;
434+ // vscode.window.showInformationMessage(text);
435+ switch ( injectionCapture . name ) {
436+ case 'name' :
437+ case 'scopeName' :
438+ if ( isMarkdownCodeblockInjectionRegex . test ( text ) ) {
439+ isMarkdownCodeblockInjectionGrammar ++ ;
440+ }
441+ break ;
442+ case 'injection' :
443+ if ( text == 'text.html.markdown'
444+ || text == 'markup.fenced_code.block.markdown' ) {
445+ isMarkdownCodeblockInjectionGrammar ++ ;
446+ }
447+ break ;
448+ }
449+ }
450+
421451 for ( const regexNode of regexNodes . values ( ) ) {
422452 const text = regexNode . text ;
423453 const key = regexNode . previousNamedSibling ;
@@ -744,7 +774,7 @@ function diagnosticsRegularExpressionErrors(diagnostics: Diagnostic[], document:
744774 diagnostics . push ( {
745775 range : range ,
746776 message : `Regex incompatible with TextMate 2.0${ timeOnigmo >= 1 ? timeMessageOnigmo : '' } (Onigmo v5.13.5)\n${ errorCodeOnigmo } ` ,
747- severity : vscode . DiagnosticSeverity . Warning ,
777+ severity : isMarkdownCodeblockInjectionGrammar > 1 ? vscode . DiagnosticSeverity . Hint : vscode . DiagnosticSeverity . Warning ,
748778 source : 'TextMate' ,
749779 code : 'Onigmo' ,
750780 } ) ;
@@ -754,7 +784,7 @@ function diagnosticsRegularExpressionErrors(diagnostics: Diagnostic[], document:
754784 diagnostics . push ( {
755785 range : range ,
756786 message : `Regex incompatible with Github-Linguist${ timePCRE >= 1 ? timeMessagePCRE : '' } (PCRE v8.36)\n${ errorCodePCRE } ` ,
757- severity : vscode . DiagnosticSeverity . Warning ,
787+ severity : isMarkdownCodeblockInjectionGrammar > 1 ? vscode . DiagnosticSeverity . Hint : vscode . DiagnosticSeverity . Warning ,
758788 source : 'TextMate' ,
759789 code : 'PCRE' ,
760790 } ) ;
@@ -764,7 +794,7 @@ function diagnosticsRegularExpressionErrors(diagnostics: Diagnostic[], document:
764794 diagnostics . push ( {
765795 range : range ,
766796 message : `Regex incompatible with Shiki${ timeES >= 1 ? timeMessageES : '' } (oniguruma-to-es)\n${ errorCodeES } ` ,
767- severity : vscode . DiagnosticSeverity . Warning ,
797+ severity : isMarkdownCodeblockInjectionGrammar > 1 ? vscode . DiagnosticSeverity . Hint : vscode . DiagnosticSeverity . Warning ,
768798 source : 'TextMate' ,
769799 code : 'ES' ,
770800 } ) ;
@@ -1358,7 +1388,7 @@ function diagnosticsScopePostfix(diagnostics: Diagnostic[], document: vscode.Tex
13581388 if ( scope . endsWith ( candidatePostfix ) ) {
13591389 if ( candidatePostfixes . scopes [ scope ] == 1
13601390 && scope . length - candidatePostfix . length > 3 ) {
1361- const spellingSuggestion = getSpellingSuggestion ( scope , commonScopes , 1.99 ) ;
1391+ const spellingSuggestion = getSpellingSuggestion ( scope , commonScopes . filter ( scope => scope . endsWith ( candidatePostfix ) ) , 1.99 ) ;
13621392 if ( spellingSuggestion ) {
13631393 diagnostics . push ( {
13641394 range,
@@ -1428,7 +1458,7 @@ function diagnosticsScopePostfix(diagnostics: Diagnostic[], document: vscode.Tex
14281458 }
14291459
14301460 diagnostics . push ( {
1431- range,
1461+ range : new vscode . Range ( range . end , range . end ) ,
14321462 message : `ScopeName '${ scope } ' missing postfix '.${ candidatePostfixes . candidatePostfixes [ 0 ] } '` ,
14331463 severity : diagnosticSeverity ,
14341464 source : 'TextMate' ,
0 commit comments