@@ -215,6 +215,24 @@ async function updatePanelContent(): Promise<void> {
215215 const filePath = lastActiveTextEditor ?. document . uri . fsPath ;
216216 const fileInfo = getFileInfo ( filePath ) ;
217217
218+ // If no file is selected, show a "no file" state without running commands
219+ if ( ! fileInfo ) {
220+ const noFileState : PanelState = {
221+ fileInfo : null ,
222+ cliVersion : cachedCliVersion || 'Unknown' ,
223+ extensionVersion,
224+ lintResult : { raw : '' , health : null } ,
225+ formatResult : { output : '' , exitCode : null } ,
226+ metaschemaResult : { output : '' , exitCode : null } ,
227+ isLoading : false ,
228+ hasParseErrors : false ,
229+ noFileSelected : true
230+ } ;
231+ currentPanelState = noFileState ;
232+ panelManager . updateContent ( noFileState ) ;
233+ return ;
234+ }
235+
218236 // Send initial loading state
219237 const loadingState : PanelState = {
220238 fileInfo,
@@ -237,7 +255,7 @@ async function updatePanelContent(): Promise<void> {
237255 const version = await commandExecutor . getVersion ( ) ;
238256 cachedCliVersion = version ;
239257
240- const metaschemaRawResult = fileInfo ? await commandExecutor . metaschema ( fileInfo . absolutePath ) : { output : 'No file selected' , exitCode : null } ;
258+ const metaschemaRawResult = await commandExecutor . metaschema ( fileInfo . absolutePath ) ;
241259 const metaschemaResult = parseMetaschemaResult ( metaschemaRawResult . output , metaschemaRawResult . exitCode ) ;
242260
243261 if ( metaschemaResult . errors && metaschemaResult . errors . length > 0 ) {
@@ -266,8 +284,8 @@ async function updatePanelContent(): Promise<void> {
266284 }
267285
268286 const [ lintOutput , formatResult ] = await Promise . all ( [
269- fileInfo ? commandExecutor . lint ( fileInfo . absolutePath ) : Promise . resolve ( 'No file selected' ) ,
270- fileInfo ? commandExecutor . formatCheck ( fileInfo . absolutePath ) : Promise . resolve ( { output : 'No file selected' , exitCode : null } )
287+ commandExecutor . lint ( fileInfo . absolutePath ) ,
288+ commandExecutor . formatCheck ( fileInfo . absolutePath )
271289 ] ) ;
272290
273291 const lintResult = parseLintResult ( lintOutput ) ;
0 commit comments