Fix up cache scope

envvar-auto-complete
Nick O'Leary 2023-12-20 16:51:34 +00:00
parent 4be6d57d98
commit 20187b51b1
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 7 additions and 7 deletions

View File

@ -135,10 +135,10 @@
} }
const url = `context/${scope}/${encodeURIComponent(searchKey)}?store=${store}&keysOnly` const url = `context/${scope}/${encodeURIComponent(searchKey)}?store=${store}&keysOnly`
if (contextCache[url]) { if (contextCache[url]) {
console.log('CACHED', url) // console.log('CACHED', url)
done() done()
} else { } else {
console.log('GET', url) // console.log('GET', url)
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
// console.log(data) // console.log(data)
contextCache[url] = true contextCache[url] = true
@ -147,9 +147,9 @@
const keyPrefix = searchKey + (searchKey.length > 0 ? '.' : '') const keyPrefix = searchKey + (searchKey.length > 0 ? '.' : '')
keys.forEach(key => { keys.forEach(key => {
if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(key)) { if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(key)) {
contextKnownKeys[store].add(keyPrefix + key) contextKnownKeys[scope][store].add(keyPrefix + key)
} else { } else {
contextKnownKeys[store].add(searchKey + "[\""+key.replace(/"/,"\\\"")+"\"]") contextKnownKeys[scope][store].add(searchKey + "[\""+key.replace(/"/,"\\\"")+"\"]")
} }
}) })
done() done()
@ -179,12 +179,12 @@
const searchKey = keyParts.join('.') const searchKey = keyParts.join('.')
getContextKeysFromRuntime(scope, store, searchKey, function() { getContextKeysFromRuntime(scope, store, searchKey, function() {
if (contextKnownKeys[store].has(key) || key.endsWith(']')) { if (contextKnownKeys[scope][store].has(key) || key.endsWith(']')) {
getContextKeysFromRuntime(scope, store, key, function() { getContextKeysFromRuntime(scope, store, key, function() {
done(contextKnownKeys[store]) done(contextKnownKeys[scope][store])
}) })
} }
done(contextKnownKeys[store]) done(contextKnownKeys[scope][store])
}) })
} }