Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
* under the License.
*/

import { commands, languages, Uri, window } from "vscode";
import { commands, languages, Uri, window, workspace } from "vscode";
import { BALLERINA_COMMANDS, getRunCommand, PALETTE_COMMANDS, runCommand } from "./cmd-runner";
import { ballerinaExtInstance } from "../../../core";
import { prepareAndGenerateConfig } from "../../config-generator/configGenerator";
import { getConfigCompletions } from "../../config-generator/utils";

import { BiDiagramRpcManager } from "../../../rpc-managers/bi-diagram/rpc-manager";

function activateConfigRunCommand() {
// register the config view run command
Expand All @@ -37,10 +36,16 @@ function activateConfigRunCommand() {

commands.registerCommand(PALETTE_COMMANDS.CONFIG_CREATE_COMMAND, async () => {
try {
const currentProject = ballerinaExtInstance.getDocumentContext().getCurrentProject();
const filePath = window.activeTextEditor.document;
const path = filePath.uri.fsPath;
prepareAndGenerateConfig(ballerinaExtInstance, currentProject ? currentProject.path! : path, true);
// Open current config.toml or create a new config.toml if it does not exist
let projectPath: string;
if (window.activeTextEditor) {
projectPath = window.activeTextEditor.document.uri.fsPath;
} else if (workspace.workspaceFolders && workspace.workspaceFolders.length > 0) {
projectPath = workspace.workspaceFolders[0].uri.fsPath;
}

const biDiagramRpcManager = new BiDiagramRpcManager();
await biDiagramRpcManager.openConfigToml({ filePath: projectPath });
return;
} catch (error) {
throw new Error("Unable to create Config.toml file. Try again with a valid Ballerina file open in the editor.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ export class BiDiagramRpcManager implements BIDiagramAPI {
return new Promise(async (resolve) => {
const currentProject: BallerinaProject | undefined = await getCurrentBIProject(params.filePath);

const configFilePath = path.join(StateMachine.context().projectUri, "config.toml");
const configFilePath = path.join(StateMachine.context().projectUri, "Config.toml");
const ignoreFile = path.join(StateMachine.context().projectUri, ".gitignore");
const docLink = "https://ballerina.io/learn/provide-values-to-configurable-variables/#provide-via-toml-syntax";
const uri = Uri.file(configFilePath);
Expand Down
Loading