Skip to content

Commit 29d0a5e

Browse files
authored
Merge pull request #34 from kaumini/fixInitialDelay
Fix config.toml create command
2 parents efc8408 + a088414 commit 29d0a5e

File tree

1 file changed

+12
-7
lines changed
  • workspaces/ballerina/ballerina-extension/src/features/project/cmds

1 file changed

+12
-7
lines changed

workspaces/ballerina/ballerina-extension/src/features/project/cmds/configRun.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
* under the License.
1717
*/
1818

19-
import { commands, languages, Uri, window } from "vscode";
19+
import { commands, languages, Uri, window, workspace } from "vscode";
2020
import { BALLERINA_COMMANDS, getRunCommand, PALETTE_COMMANDS, runCommand } from "./cmd-runner";
2121
import { ballerinaExtInstance } from "../../../core";
22-
import { prepareAndGenerateConfig } from "../../config-generator/configGenerator";
2322
import { getConfigCompletions } from "../../config-generator/utils";
24-
23+
import { BiDiagramRpcManager } from "../../../rpc-managers/bi-diagram/rpc-manager";
2524

2625
function 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

Comments
 (0)