Skip to content

Commit 0f93771

Browse files
author
shuo
committed
store
1 parent 365cba6 commit 0f93771

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,9 +1476,19 @@
14761476
"default": false
14771477
},
14781478
"objectscript.autoAdjustName": {
1479-
"markdownDescription": "Automatically modify the class name or ROUTINE header of a file in a client-side workspace folder to match the file's path when copying or moving a file. Uses the `#objectscript.export#` settings to determine the new name.",
1480-
"type": "boolean",
1481-
"default": false
1479+
"markdownDescription": "Automatically modify the class name or ROUTINE header of a file in a client-side workspace folder to match the file's path when: (Uses the `#objectscript.export#` settings to determine the new name.)",
1480+
"type": "string",
1481+
"enum": [
1482+
"Never",
1483+
"Create",
1484+
"Create, Copy and Move"
1485+
],
1486+
"enumDescriptions": [
1487+
"Do not automatically adjust the name.",
1488+
"Create a matching class name / ROUTINE header when the file is first created.",
1489+
"Create or update an existing class name / ROUTINE header when the file is created, copied or moved."
1490+
],
1491+
"default": "Create"
14821492
},
14831493
"objectscript.compileOnSave": {
14841494
"description": "Automatically compile an InterSystems file when saved in the editor.",

src/extension.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,11 +1262,18 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
12621262
// No workspace folders are open
12631263
return;
12641264
}
1265-
const sourceContent = await vscode.workspace.fs.readFile(uri);
1266-
if (!vscode.workspace.getConfiguration("objectscript").get<boolean>("autoAdjustName")) {
1265+
if (vscode.workspace.getConfiguration("objectscript").get<string>("autoAdjustName") === "Never") {
12671266
// Don't modify a file with content unless the user opts in
12681267
return;
12691268
}
1269+
const sourceContent = await vscode.workspace.fs.readFile(uri);
1270+
if (
1271+
sourceContent.length > 0 &&
1272+
vscode.workspace.getConfiguration("objectscript").get<string>("autoAdjustName") === "Create"
1273+
) {
1274+
// It has content, but user opted to not modify existing files
1275+
return;
1276+
}
12701277
const workspacePath = uriOfWorkspaceFolder(workspace).fsPath;
12711278
const filePathNoWorkspaceArr = uri.fsPath.replace(workspacePath + path.sep, "").split(path.sep);
12721279
const { folder, addCategory } = config("export", workspace);

0 commit comments

Comments
 (0)