@@ -21,9 +21,7 @@ export function registerVSCodeQuteCommands(context: ExtensionContext) {
2121 registerQuteValidationToggleCommand ( context ) ;
2222 context . subscriptions . push (
2323 workspace . onDidOpenTextDocument ( ( document ) => {
24- if ( ! ( document . uri . scheme === 'git' ) ) {
25- updateQuteLanguageId ( context , document , true ) ;
26- }
24+ updateQuteLanguageId ( context , document , true ) ;
2725 } )
2826 ) ;
2927 // When extension is started, loop for each text documents which are opened to update their language ID.
@@ -202,7 +200,7 @@ async function checkQuteValidationFromExclusionContext(uri: Uri) {
202200 * - the button can be shown with eye-closed (when file is a Qute template file and validation is enabled).
203201 * - the button can be shown with eye-opened (when file is a Qute template file and validation is disabled)
204202 */
205- export async function synchronizeQuteValidationButton ( editor : TextEditor ) {
203+ export async function synchronizeQuteValidationButton ( editor : TextEditor ) {
206204 const document = editor ?. document ;
207205 if ( ! document ) {
208206 return ;
@@ -243,26 +241,40 @@ const LANGUAGE_MAP = new Map<string, string>([
243241 * @param document the text document.
244242 * @param onExtensionLoad if the user manually changed the language id.
245243 */
246- async function updateQuteLanguageId ( context : ExtensionContext , document : TextDocument , onExtensionLoad : boolean ) {
244+ async function updateQuteLanguageId ( context : ExtensionContext , document : TextDocument , onExtensionLoad : boolean ) {
245+ if ( document . uri . scheme === 'git' ) {
246+ return ;
247+ }
247248 const propertiesLanguageMismatch : QuteTemplateLanguageMismatch = QuteSettings . getQuteTemplatesLanguageMismatch ( ) ;
248249 // Check if the setting is set to ignore or if the language ID is already set to Qute
249250 if ( propertiesLanguageMismatch === QuteTemplateLanguageMismatch . ignore || document . languageId . startsWith ( 'qute-' ) ) {
250251 // Do nothing
251252 return ;
252253 }
253- const fileName : string = path . basename ( document . fileName ) ;
254- if ( document . fileName . includes ( `resources${ path . sep } templates${ path . sep } ` ) ) {
254+ if ( isInTemplates ( document ) ) {
255255 for ( const extension of LANGUAGE_MAP . keys ( ) ) {
256256 if ( path . extname ( document . fileName ) === extension ) {
257257 const quteLanguageId = LANGUAGE_MAP . get ( extension ) ;
258-
258+ const fileName : string = path . basename ( document . fileName ) ;
259259 tryToForceLanguageId ( context , document , fileName , propertiesLanguageMismatch , quteLanguageId , onExtensionLoad , QuteSettings . QUTE_OVERRIDE_LANGUAGE_ID , QuteSettings . QUTE_TEMPLATES_LANGUAGE_MISMATCH ) ;
260260 break ;
261261 }
262262 }
263263 }
264264}
265265
266+ function isInTemplates ( document : TextDocument ) : boolean {
267+ if ( document . fileName . includes ( `resources${ path . sep } templates${ path . sep } ` ) ) {
268+ // HTML, etc file is included in src/main/resources/templates
269+ return true ;
270+ }
271+ if ( document . uri . scheme === 'jdt' && document . uri . path . startsWith ( `/templates` ) ) {
272+ // HTML, etc file is included in a JAR in templates JAR entry
273+ return true ;
274+ }
275+ return false ;
276+ }
277+
266278interface IConfiguration {
267279 workspaceConfiguration : WorkspaceConfiguration ;
268280 target : ConfigurationTarget ;
0 commit comments