Skip to content

Commit

Permalink
fix: 修复vite预启动时,获取不到当前文件而不开启插件
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Apr 28, 2024
1 parent e7f313c commit e4a6591
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = antfu(
'ts/no-require-imports': 'off',
'style/max-statements-per-line': 'off',
'import/no-mutable-exports': 'off',
'no-console': 'off',
},
},
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"lint:fix": "eslint . --fix",
"publish": "vsce publish --no-dependencies",
"typecheck": "tsc --noEmit",
"release": "pnpm run build && bumpp && pnpm run publish"
"release": "pnpm run build && bumpp && pnpm publish"
},
"devDependencies": {
"@antfu/eslint-config": "^2.9.0",
Expand Down
19 changes: 9 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import type { ChangeList } from './type'
import { parser } from './parser'

const cacheMap = new LRUCache(5000)
const errorFlag = '[Unot Error]:'
export let toRemFlag = false
export let decorationType: TextEditorDecorationType
export async function activate(context: vscode.ExtensionContext) {
const activeTextEditor = getActiveTextEditor()
if (!activeTextEditor)
return

console.log('Unot is now active!')
// 注册打开文档事件
openDocumentation(context)
openPlayground(context)
Expand Down Expand Up @@ -209,8 +207,10 @@ export async function activate(context: vscode.ExtensionContext) {
}
}

if (isNotUnocss)
if (isNotUnocss) {
console.error(`${errorFlag} is not unocss project, please install unocss first!`)
return
}

// style to unocss hover事件
context.subscriptions.push(vscode.languages.registerHoverProvider(LANS, {
Expand Down Expand Up @@ -319,11 +319,7 @@ export async function activate(context: vscode.ExtensionContext) {

let hasUnoConfig: string | undefined
const currentFolder = (vscode.workspace.workspaceFolders as any)?.[0]
const activeTextEditorUri = getCurrentFileUrl()
if (!activeTextEditorUri)
return
// const completions: vscode.CompletionItem[] = []
// let unoCompletionsMap: any

const switchMagic = getConfiguration('unot').get('switchMagic')

let isOpen = switchMagic
Expand Down Expand Up @@ -411,6 +407,9 @@ export async function activate(context: vscode.ExtensionContext) {
}

function updateUnoStatus(cwd = currentFolder.uri.fsPath.replace(/\\/g, '/')) {
const activeTextEditorUri = getCurrentFileUrl()
if (!activeTextEditorUri)
return
if (activeTextEditorUri && !prefix.includes(activeTextEditorUri.split('.').slice(-1)[0])) {
hasUnoConfig = undefined
return
Expand Down

0 comments on commit e4a6591

Please sign in to comment.