@@ -6,7 +6,7 @@ import * as path from 'path';
66import { getWorkspaceFolder } from '../api' ;
77import { executeCommand } from '../terminal' ;
88import { readWorkspaceJson , writeWorkspaceJson } from '../webviews/project' ;
9- import { getMenuconfigMethod } from '../smart' ;
9+ import { getMenuconfigMethod , MENUCONFIG_COMMANDS } from '../smart' ;
1010
1111let _currentProject : string = '' ;
1212
@@ -33,20 +33,28 @@ export function configProject(arg: any) {
3333
3434 if ( menuconfigMethod . type === 'extension' ) {
3535 // For rt-thread-kconfig extension, it handles multi-BSP scenarios automatically
36- if ( menuconfigMethod . command === 'rt-thread-kconfig.menuconfig.windows' ) {
36+ if ( menuconfigMethod . command === MENUCONFIG_COMMANDS . RT_THREAD_KCONFIG ) {
3737 // Change to the BSP directory first
3838 executeCommand ( 'cd ' + arg . fn ) ;
3939 // Execute the extension command
4040 vscode . commands . executeCommand ( menuconfigMethod . command ) ;
4141 }
4242 // For vscode-kconfig-visual-editor, we need to open the Kconfig file explicitly
43- else if ( menuconfigMethod . command === 'kconfig-visual-editor.open' ) {
43+ else if ( menuconfigMethod . command === MENUCONFIG_COMMANDS . KCONFIG_VISUAL_EDITOR ) {
4444 const kconfigPath = path . join ( arg . fn , 'Kconfig' ) ;
4545 if ( fs . existsSync ( kconfigPath ) ) {
4646 // Open the Kconfig file with the visual editor
47- vscode . workspace . openTextDocument ( kconfigPath ) . then ( doc => {
48- vscode . window . showTextDocument ( doc ) ;
49- } ) ;
47+ vscode . workspace . openTextDocument ( kconfigPath ) . then (
48+ doc => {
49+ vscode . window . showTextDocument ( doc ) ;
50+ } ,
51+ ( error : Error ) => {
52+ vscode . window . showErrorMessage ( `Failed to open Kconfig file: ${ error . message } ` ) ;
53+ // Fallback to terminal on error
54+ let cmd = 'scons -C ' + arg . fn + ' --menuconfig' ;
55+ executeCommand ( cmd ) ;
56+ }
57+ ) ;
5058 } else {
5159 // Fallback to terminal if Kconfig doesn't exist
5260 let cmd = 'scons -C ' + arg . fn + ' --menuconfig' ;
0 commit comments