Skip to content
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

feat: auto apply checksum when starting VSCode #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@
"command": "fixChecksums.restore",
"title": "Fix Checksums: Restore"
}
]
],
"configuration": {
"title": "vscode-fix-checksums",
"properties": {
"checksums.autoFix": {
"type": "boolean",
"description": "Fix checksums automatically when VSCode start up",
"default": false
}
}
}
},
"scripts": {
"vscode:prepublish": "pnpm build",
Expand Down
9 changes: 7 additions & 2 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ exports.activate = function activate(context) {
vscode.commands.registerCommand('fixChecksums.restore', restore)
)
cleanupOrigFiles()

const auto = vscode.workspace.getConfiguration().get("checksums.autoFix")
apply(auto)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that it always applies whether you set auto fix or not. The option just hides the message, not controls the behavior

Copy link
Author

@zent1n0 zent1n0 Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, seems auto only controls message, then the logic should be correct with a if clause.

However, the plugin code doesn't load with VSCode extension server starting, but on the first command was executed, thus the function call apply(auto) seems no sense.

Or shall we set the plugin activate on start up to trigger an Apply event?

}

const messages = {
Expand All @@ -27,7 +30,7 @@ const messages = {
Make sure you have write access rights to the VSCode files, see README`,
}

async function apply() {
async function apply(hidden) {
const product = requireUncached(productFile)
if (!product.checksums) {
vscode.window.showInformationMessage(messages.unchanged)
Expand All @@ -54,7 +57,9 @@ async function apply() {
message = messages.error
}
}
vscode.window.showInformationMessage(message);
if (hidden !== true) {
vscode.window.showInformationMessage(message);
}
}

async function restore() {
Expand Down