File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -92,15 +92,16 @@ class LintingSupportProvider {
9292 const matlabConnection = await this . matlabLifecycleManager . getMatlabConnection ( )
9393 const isMatlabAvailable = matlabConnection != null
9494
95- const fileName = URI . parse ( uri ) . fsPath
95+ const isMFile = this . isMFile ( uri )
96+ const fileName = isMFile ? URI . parse ( uri ) . fsPath : "untitled.m"
9697
9798 let lintData : string [ ] = [ ]
9899
99100 if ( isMatlabAvailable ) {
100101 // Use MATLAB-based linting for better results and fixes
101102 const code = textDocument . getText ( )
102103 lintData = await this . getLintResultsFromMatlab ( code , fileName , matlabConnection )
103- } else {
104+ } else if ( isMFile ) {
104105 // Try to use mlint executable for basic linting
105106 lintData = await this . getLintResultsFromExecutable ( fileName )
106107 }
@@ -528,6 +529,16 @@ class LintingSupportProvider {
528529 a . severity === b . severity &&
529530 a . source === b . source
530531 }
532+
533+ /**
534+ * Checks if the given URI corresponds to a MATLAB M-file.
535+ *
536+ * @param uri - The URI of the file to check.
537+ * @returns True if the file is a MATLAB M-file (.m), false otherwise.
538+ */
539+ private isMFile ( uri : string ) : boolean {
540+ return URI . parse ( uri ) . fsPath . endsWith ( ".m" )
541+ }
531542}
532543
533544export default LintingSupportProvider
You can’t perform that action at this time.
0 commit comments