Skip to content

Commit 44464cb

Browse files
committed
fix(vue-volar): normalize config path when checking
1 parent 24e105e commit 44464cb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/vueVolarSupport.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,23 @@ export default () => {
7272
const isConfigValueChanged = (settingId: string) => {
7373
if (process.env.PLATFORM !== 'web') {
7474
const config = vscode.workspace.getConfiguration('')
75-
const userValue = config.get<string>(settingId)
76-
if (userValue === config.inspect(settingId)!.defaultValue) return false
75+
let userValue = config.get<string>(settingId)
76+
if (!userValue || userValue === config.inspect(settingId)!.defaultValue) return false
7777
// means that value was set by us programmatically, let's update it
7878
// eslint-disable-next-line @typescript-eslint/no-require-imports
79-
if (userValue?.startsWith(require('path').join(extensionCtx.extensionPath, '../..'))) return false
79+
let extensionsBasePath = require('path').join(extensionCtx.extensionPath, '../..') as string
80+
const normalizePathWin = (path: string) => {
81+
// normalize casing of drive
82+
if (/^[a-z]:/.test(path)) {
83+
path = path[0]!.toUpperCase() + path.slice(1)
84+
}
85+
86+
return path.replace(/\\/g, '/')
87+
}
88+
89+
userValue = normalizePathWin(userValue)
90+
extensionsBasePath = normalizePathWin(extensionsBasePath)
91+
if (userValue.startsWith(extensionsBasePath)) return false
8092
return true
8193
}
8294

0 commit comments

Comments
 (0)