Skip to content

Commit 11f3dc5

Browse files
committed
feat(vscode): improve init update, close #69
1 parent a98eec1 commit 11f3dc5

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

extension/src/fetch.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ export async function fetchAndUpdate(ctx: ExtensionContext, prompt = true) {
3737

3838
if (shouldUpdate) {
3939
const config = workspace.getConfiguration()
40-
if (!config.has('explorer.experimental.fileNesting.enabled'))
41-
config.update('explorer.experimental.fileNesting.enabled', true, true)
42-
if (!config.has('explorer.experimental.fileNesting.expand'))
43-
config.update('explorer.experimental.fileNesting.expand', false, true)
44-
40+
config.update('explorer.experimental.fileNesting.enabled', true, true)
41+
config.update('explorer.experimental.fileNesting.expand', false, true)
4542
config.update('explorer.experimental.fileNesting.patterns', {
4643
'//': `Last update at ${new Date().toLocaleString()}`,
4744
...patterns,

extension/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ export async function activate(ctx: ExtensionContext) {
77
commands.registerCommand('antfu.file-nesting.manualUpdate', () => fetchAndUpdate(ctx, false))
88

99
const lastUpdate = ctx.globalState.get('lastUpdate', 0)
10+
const initialized = ctx.globalState.get('init', false)
1011
const autoUpdateInterval = getConfig<number>('fileNestingUpdater.autoUpdateInterval')
1112

13+
if (!initialized) {
14+
ctx.globalState.update('init', true)
15+
fetchAndUpdate(ctx, false)
16+
}
17+
1218
if (getConfig('fileNestingUpdater.autoUpdate')) {
1319
if (Date.now() - lastUpdate >= autoUpdateInterval * 60_000)
1420
fetchAndUpdate(ctx, getConfig('fileNestingUpdater.promptOnAutoUpdate'))

0 commit comments

Comments
 (0)