Skip to content

Commit 2872eb1

Browse files
hsyhhssyyshuoisc-bsaviano
authored
Add new autoAdjustName setting (#1277)
Co-authored-by: shuo <[email protected]> Co-authored-by: Brett Saviano <[email protected]>
1 parent da772e5 commit 2872eb1

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,11 @@
14581458
"type": "boolean",
14591459
"default": false
14601460
},
1461+
"objectscript.autoAdjustName": {
1462+
"markdownDescription": "Automatically modify the class name or ROUTINE header to match the file's path when copying or creating a new file. Does not affect `isfs` files.",
1463+
"type": "boolean",
1464+
"default": true
1465+
},
14611466
"objectscript.compileOnSave": {
14621467
"description": "Automatically compile an InterSystems file when saved in the editor.",
14631468
"type": "boolean",

src/extension.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
10451045
RESTDebugPanel.create(context.extensionUri)
10461046
),
10471047
vscode.commands.registerCommand("vscode-objectscript.exportCurrentFile", exportCurrentFile),
1048-
vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) =>
1049-
Promise.all(
1048+
vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) => {
1049+
if (!config("autoAdjustName")) return;
1050+
return Promise.all(
10501051
e.files
10511052
.filter((uri) => !filesystemSchemas.includes(uri.scheme))
10521053
.filter((uri) => ["cls", "inc", "int", "mac"].includes(uri.path.split(".").pop().toLowerCase()))
@@ -1078,8 +1079,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
10781079
// Write the new content to the file
10791080
return vscode.workspace.fs.writeFile(uri, new TextEncoder().encode(newContent.content.join("\n")));
10801081
})
1081-
)
1082-
),
1082+
);
1083+
}),
10831084
vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor) => {
10841085
if (config("openClassContracted") && editor && editor.document.languageId === "objectscript-class") {
10851086
const uri: string = editor.document.uri.toString();

0 commit comments

Comments
 (0)