Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export async function loadConfig<U extends UserConfig>(
return result
}

export const errorCwdMap = new Set()

/**
* Create a factory function that returns a config loader that recovers from errors.
*
Expand All @@ -90,6 +92,7 @@ export function createRecoveryConfigLoader<U extends UserConfig>() {
}
catch (e) {
if (lastResolved) {
errorCwdMap.add(cwd)
console.error(e)
return lastResolved
}
Expand Down
5 changes: 4 additions & 1 deletion packages/vscode/src/contextLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { UnocssPluginContext, UserConfig, UserConfigDefaults } from '@unocs
import type { ExtensionContext, StatusBarItem } from 'vscode'
import { readdir } from 'fs/promises'
import path from 'path'
import { errorCwdMap } from '@unocss/config'
import { notNull } from '@unocss/core'
import presetUno from '@unocss/preset-uno'
import { exists } from 'fs-extra'
Expand Down Expand Up @@ -217,8 +218,10 @@ export class ContextLoader {
}

const context = await load()
if (!this.contextsMap.has(dir))
if (!this.contextsMap.has(dir) && !errorCwdMap.has(dir))
this.contextsMap.set(dir, context)
else if (errorCwdMap.has(dir))
errorCwdMap.delete(dir)
this.fileContextCache.clear()
this.events.emit('reload')

Expand Down
Loading