Skip to content

Commit

Permalink
Add new autoAdjustName setting (#1277)
Browse files Browse the repository at this point in the history
Co-authored-by: shuo <[email protected]>
Co-authored-by: Brett Saviano <[email protected]>
  • Loading branch information
3 people authored Dec 28, 2023
1 parent da772e5 commit 2872eb1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
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.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 5 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
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()))
Expand Down Expand Up @@ -1078,8 +1079,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
// 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();
Expand Down

0 comments on commit 2872eb1

Please sign in to comment.