diff --git a/package-lock.json b/package-lock.json index 73b3e1c7..46f6d72d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-objectscript", - "version": "2.10.5-SNAPSHOT", + "version": "2.10.6-SNAPSHOT", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-objectscript", - "version": "2.10.5-SNAPSHOT", + "version": "2.10.6-SNAPSHOT", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 8278907b..969f00bd 100644 --- a/package.json +++ b/package.json @@ -1458,6 +1458,11 @@ "type": "boolean", "default": false }, + "objectscript.autoAdjustName": { + "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.", + "type": "boolean", + "default": true + }, "objectscript.compileOnSave": { "description": "Automatically compile an InterSystems file when saved in the editor.", "type": "boolean", diff --git a/src/extension.ts b/src/extension.ts index c8a86289..b078b4d5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1045,8 +1045,9 @@ export async function activate(context: vscode.ExtensionContext): Promise { RESTDebugPanel.create(context.extensionUri) ), vscode.commands.registerCommand("vscode-objectscript.exportCurrentFile", exportCurrentFile), - vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) => - Promise.all( + vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) => { + if (!config("autoAdjustName")) return; + return Promise.all( e.files .filter((uri) => !filesystemSchemas.includes(uri.scheme)) .filter((uri) => ["cls", "inc", "int", "mac"].includes(uri.path.split(".").pop().toLowerCase())) @@ -1078,8 +1079,8 @@ export async function activate(context: vscode.ExtensionContext): Promise { // Write the new content to the file return vscode.workspace.fs.writeFile(uri, new TextEncoder().encode(newContent.content.join("\n"))); }) - ) - ), + ); + }), vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor) => { if (config("openClassContracted") && editor && editor.document.languageId === "objectscript-class") { const uri: string = editor.document.uri.toString();