refactor: separate fields flow to smaller files
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { getProjectConfigPath } from "@/model/projectConfig";
|
||||
import { TASK_FILE_EXTENSION } from "@/model/taskFile";
|
||||
import * as vscode from "vscode";
|
||||
import {
|
||||
type FrontmatterEditDeps,
|
||||
resolveDocument,
|
||||
resolveTaskFolder,
|
||||
} from "./editFrontmatterBase";
|
||||
|
||||
export async function runOpenProjectConfig(
|
||||
deps: FrontmatterEditDeps,
|
||||
uriArg?: string,
|
||||
): Promise<void> {
|
||||
const document = await resolveDocument(uriArg);
|
||||
if (!document) {
|
||||
void vscode.window.showErrorMessage(
|
||||
`Open a ${TASK_FILE_EXTENSION} task file first`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const folder = await resolveTaskFolder(document, deps.config);
|
||||
if (!folder) {
|
||||
void vscode.window.showErrorMessage(
|
||||
"Task file is outside a configured task folder",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const configPath = getProjectConfigPath(folder);
|
||||
const uri = vscode.Uri.file(configPath);
|
||||
|
||||
try {
|
||||
const doc = await vscode.workspace.openTextDocument(uri);
|
||||
await vscode.window.showTextDocument(doc);
|
||||
} catch {
|
||||
void vscode.window.showErrorMessage(
|
||||
`Could not open config file: ${configPath}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user