Skip to content

An alternative for autoAdjustName #1563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1476,9 +1476,19 @@
"default": false
},
"objectscript.autoAdjustName": {
"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.",
"type": "boolean",
"default": false
"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.)",
"type": "string",
"enum": [
"Never",
"Create",
"Create, Copy and Move"
],
"enumDescriptions": [
"Do not automatically adjust the name.",
"Create a matching class name / ROUTINE header when the file is first created.",
"Create or update an existing class name / ROUTINE header when the file is created, copied or moved."
],
"default": "Create"
},
"objectscript.compileOnSave": {
"description": "Automatically compile an InterSystems file when saved in the editor.",
Expand Down
10 changes: 7 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1262,12 +1262,16 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
// No workspace folders are open
return;
}
if (vscode.workspace.getConfiguration("objectscript").get<string>("autoAdjustName") === "Never") {
// Don't modify a file with content unless the user opts in
return;
}
const sourceContent = await vscode.workspace.fs.readFile(uri);
if (
sourceContent.length &&
!vscode.workspace.getConfiguration("objectscript").get<boolean>("autoAdjustName")
sourceContent.length > 0 &&
vscode.workspace.getConfiguration("objectscript").get<string>("autoAdjustName") === "Create"
) {
// Don't modify a file with content unless the user opts in
// It has content, but user opted to not modify existing files
return;
}
const workspacePath = uriOfWorkspaceFolder(workspace).fsPath;
Expand Down