Skip to content

Commit 204d37d

Browse files
committed
add config for disabling backups
1 parent 1c077cf commit 204d37d

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ A Visual Studio Code extension for [cht.sh](https://cht.sh/).
2727
- ${index} - the index of the snippet (e.g. 2 for the third answer)
2828
- `insertWithDoubleClick`: insert snippet with double click.
2929
- `showCopySuccessNotification`: Whether to show a notification after the snippet is copied to the clipboard.
30+
- `saveBackups`: Whether to create backups of the snippets.
3031

3132
## Installation
3233

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@
171171
"type": "boolean",
172172
"default": true,
173173
"description": "Whether to show a notification after the snippet is copied to the clipboard."
174+
},
175+
"snippet.saveBackups": {
176+
"type": "boolean",
177+
"default": true,
178+
"description": "Whether to create backups of the snippets."
174179
}
175180
}
176181
},

src/backupManager.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { randomUUID } from "crypto";
22
import * as vscode from "vscode";
3+
import { getConfig } from "./config";
34
import { formatUnixTime } from "./date";
45
import SnippetsStorage, { TreeElement } from "./snippetsStorage";
56

@@ -83,6 +84,10 @@ export class BackupManager {
8384
}
8485

8586
private async makeBackup(elements: TreeElement[], operation?: string) {
87+
if (!getConfig("saveBackups")) {
88+
return;
89+
}
90+
8691
const backup: Backup = {
8792
id: randomUUID(),
8893
dateUnix: Date.now(),

0 commit comments

Comments
 (0)