1- import { normalize } from 'path' ;
1+ import { extname , normalize } from 'path' ;
22import { Diagnostic , DiagnosticSeverity } from 'vscode-languageserver' ;
33import { TextDocument } from 'vscode-languageserver-textdocument' ;
44import { configService } from '../services/configuration.service' ;
55import { fileSystemService } from '../services/fs.service' ;
6+ import { imageFileExtensions } from 'shared' ;
67
78export function validateFilePaths ( textDocument : TextDocument ) : Diagnostic [ ] {
89 // In this simple example we get the settings for every validate run.
@@ -22,7 +23,7 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
2223 problems < configService . globalSettings . maxNumberOfProblems
2324 ) {
2425 const normalizedPath = normalize ( m [ 2 ] ) ;
25- if ( ! fileSystemService . moduleFileList . includes ( normalizedPath ) ) {
26+ if ( ! checkIfPathExists ( normalizedPath ) ) {
2627 problems ++ ;
2728 const diagnostic : Diagnostic = {
2829 severity : DiagnosticSeverity . Error ,
@@ -52,3 +53,22 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
5253 // Send the computed diagnostics to VSCode.
5354 return diagnostics ;
5455}
56+
57+ function checkIfPathExists ( filePath : string ) : boolean {
58+ if ( fileSystemService . moduleFileList . includes ( filePath ) ) {
59+ return true ;
60+ }
61+
62+ if ( imageFileExtensions . includes ( extname ( filePath ) ) ) {
63+ const index = filePath . lastIndexOf ( '.' ) ;
64+ if ( index < 0 ) {
65+ return false ;
66+ }
67+
68+ filePath = filePath . substring ( 0 , index ) + '000' + filePath . substring ( index ) ;
69+
70+ return fileSystemService . moduleFileList . includes ( filePath ) ;
71+ }
72+
73+ return false ;
74+ }
0 commit comments