New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(vscode): respect unocss.root
#1169
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ class UnoCompletionItem extends CompletionItem { | |
} | ||
|
||
export async function registerAutoComplete( | ||
cwd: string, | ||
contextLoader: ContextLoader, | ||
ext: ExtensionContext, | ||
) { | ||
|
@@ -64,9 +65,11 @@ export async function registerAutoComplete( | |
|
||
const provider: CompletionItemProvider<UnoCompletionItem> = { | ||
async provideCompletionItems(doc, position) { | ||
const code = doc.getText() | ||
const id = doc.uri.fsPath | ||
if (!id.startsWith(cwd)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. |
||
return null | ||
|
||
const code = doc.getText() | ||
if (!code) | ||
return null | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,17 @@ export async function activate(ext: ExtensionContext) { | |
log.appendLine(`UnoCSS for VS Code v${version} ${process.cwd()}`) | ||
|
||
const contextLoader = new ContextLoader(cwd) | ||
|
||
const hasConfig = await contextLoader.loadContextInDirectory(cwd) | ||
if (!hasConfig) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
return | ||
|
||
await contextLoader.ready | ||
|
||
const status = window.createStatusBarItem(StatusBarAlignment.Right, 200) | ||
status.text = 'UnoCSS' | ||
|
||
registerAutoComplete(contextLoader, ext) | ||
registerAutoComplete(cwd, contextLoader, ext) | ||
registerAnnotations(cwd, contextLoader, status, ext) | ||
|
||
ext.subscriptions.push(commands.registerCommand('unocss.reload', async () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's unnecessary.