1616 * under the License.
1717 */
1818
19- import { commands , languages , Uri , window } from "vscode" ;
19+ import { commands , languages , Uri , window , workspace } from "vscode" ;
2020import { BALLERINA_COMMANDS , getRunCommand , PALETTE_COMMANDS , runCommand } from "./cmd-runner" ;
2121import { ballerinaExtInstance } from "../../../core" ;
22- import { prepareAndGenerateConfig } from "../../config-generator/configGenerator" ;
2322import { getConfigCompletions } from "../../config-generator/utils" ;
24-
23+ import { BiDiagramRpcManager } from "../../../rpc-managers/bi-diagram/rpc-manager" ;
2524
2625function activateConfigRunCommand ( ) {
2726 // register the config view run command
@@ -37,10 +36,16 @@ function activateConfigRunCommand() {
3736
3837 commands . registerCommand ( PALETTE_COMMANDS . CONFIG_CREATE_COMMAND , async ( ) => {
3938 try {
40- const currentProject = ballerinaExtInstance . getDocumentContext ( ) . getCurrentProject ( ) ;
41- const filePath = window . activeTextEditor . document ;
42- const path = filePath . uri . fsPath ;
43- prepareAndGenerateConfig ( ballerinaExtInstance , currentProject ? currentProject . path ! : path , true ) ;
39+ // Open current config.toml or create a new config.toml if it does not exist
40+ let projectPath : string ;
41+ if ( window . activeTextEditor ) {
42+ projectPath = window . activeTextEditor . document . uri . fsPath ;
43+ } else if ( workspace . workspaceFolders && workspace . workspaceFolders . length > 0 ) {
44+ projectPath = workspace . workspaceFolders [ 0 ] . uri . fsPath ;
45+ }
46+
47+ const biDiagramRpcManager = new BiDiagramRpcManager ( ) ;
48+ await biDiagramRpcManager . openConfigToml ( { filePath : projectPath } ) ;
4449 return ;
4550 } catch ( error ) {
4651 throw new Error ( "Unable to create Config.toml file. Try again with a valid Ballerina file open in the editor." ) ;
0 commit comments