Skip to content

Commit

Permalink
fix(vscode): tweak Conditional of intelligent prompt && add context c…
Browse files Browse the repository at this point in the history
…ache of css-like file
  • Loading branch information
TrickyPi committed Jun 19, 2022
1 parent 8426174 commit cdb2e97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/vscode/src/annonation.ts
Expand Up @@ -60,9 +60,9 @@ export async function registerAnnonations(
return reset()

let ctx = await contextLoader.resolveContext(code, id)
if (!ctx && (code.includes(INCLUDE_COMMENT_IDE) || isCssId(id)))
if (!ctx)
ctx = await contextLoader.resolveClosestContext(code, id)
else if (!ctx?.filter(code, id))
else if (!ctx.filter(code, id) && !code.includes(INCLUDE_COMMENT_IDE) && !isCssId(id))
return null

const result = await ctx.uno.generate(code, { id, preflights: false, minify: true })
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode/src/autocomplete.ts
Expand Up @@ -71,9 +71,9 @@ export async function registerAutoComplete(
return null

let ctx = await contextLoader.resolveContext(code, id)
if (!ctx && isCssId(id))
if (!ctx)
ctx = await contextLoader.resolveClosestContext(code, id)
else if (!ctx?.filter(code, id))
else if (!ctx.filter(code, id) && !isCssId(id))
return null

try {
Expand Down
8 changes: 4 additions & 4 deletions packages/vscode/src/contextLoader.ts
Expand Up @@ -8,7 +8,7 @@ import presetUno from '@unocss/preset-uno'
import { resolveOptions as resolveNuxtOptions } from '../../nuxt/src/options'
import { createNanoEvents } from '../../core/src/utils/events'
import { createContext } from './integration'
import { isSubdir } from './utils'
import { isCssId, isSubdir } from './utils'
import { log } from './log'

export class ContextLoader {
Expand Down Expand Up @@ -178,7 +178,7 @@ export class ContextLoader {
if (!isSubdir(configDir, file))
continue

if (!context.filter(code, file))
if (!context.filter(code, file) && !isCssId(file))
continue

this.fileContextCache.set(file, context)
Expand All @@ -193,7 +193,7 @@ export class ContextLoader {
continue

const context = await this.loadContextInDirectory(dir)
if (context?.filter(code, file)) {
if (context?.filter(code, file) || isCssId(file)) {
this.fileContextCache.set(file, context)
return context
}
Expand Down Expand Up @@ -221,7 +221,7 @@ export class ContextLoader {
if (!isSubdir(configDir, file))
continue

if (!context.filter(code, file))
if (!context.filter(code, file) && !isCssId(file))
continue

this.fileContextCache.set(file, context)
Expand Down

0 comments on commit cdb2e97

Please sign in to comment.