Skip to content

Commit

Permalink
fix: avoid html emmet active in style block
Browse files Browse the repository at this point in the history
close #1358
  • Loading branch information
johnsoncodehk committed May 30, 2022
1 parent 1dcc164 commit 879e7dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 11 additions & 0 deletions packages/vue-language-service/src/languageFeatures/complete.ts
Expand Up @@ -125,6 +125,9 @@ export function register(context: LanguageServiceRuntimeContext) {
mainCompletion: undefined,
};

// monky fix https://github.com/johnsoncodehk/volar/issues/1358
let isFirstMapping = true;

if (vueDocument) {

const embeddeds = vueDocument.file.getEmbeddeds();
Expand All @@ -140,6 +143,9 @@ export function register(context: LanguageServiceRuntimeContext) {
if (!plugin.complete?.on)
continue;

if (plugin.complete.isAdditional && !isFirstMapping)
continue;

if (completionContext?.triggerCharacter && !plugin.complete.triggerCharacters?.includes(completionContext.triggerCharacter))
continue;

Expand Down Expand Up @@ -188,6 +194,8 @@ export function register(context: LanguageServiceRuntimeContext) {
list: completionList,
});
}

isFirstMapping = false;
}

return true;
Expand All @@ -203,6 +211,9 @@ export function register(context: LanguageServiceRuntimeContext) {
if (!plugin.complete?.on)
continue;

if (plugin.complete.isAdditional && !isFirstMapping)
continue;

if (completionContext?.triggerCharacter && !plugin.complete.triggerCharacters?.includes(completionContext.triggerCharacter))
continue;

Expand Down
6 changes: 2 additions & 4 deletions packages/vue-language-service/src/plugins/emmet.ts
Expand Up @@ -3,8 +3,6 @@ import * as emmet from '@vscode/emmet-helper';

export default function (): EmbeddedLanguageServicePlugin {

let emmetConfig: any;

return {

complete: {
Expand Down Expand Up @@ -33,10 +31,10 @@ export default function (): EmbeddedLanguageServicePlugin {

async function getEmmetConfig(syntax: string): Promise<emmet.VSCodeEmmetConfig> {

emmetConfig = await useConfigurationHost()?.getConfiguration<emmet.VSCodeEmmetConfig>('emmet') ?? {};

const emmetConfig: any = await useConfigurationHost()?.getConfiguration<emmet.VSCodeEmmetConfig>('emmet') ?? {};
const syntaxProfiles = Object.assign({}, emmetConfig['syntaxProfiles'] || {});
const preferences = Object.assign({}, emmetConfig['preferences'] || {});

// jsx, xml and xsl syntaxes need to have self closing tags unless otherwise configured by user
if (syntax === 'jsx' || syntax === 'xml' || syntax === 'xsl') {
syntaxProfiles[syntax] = syntaxProfiles[syntax] || {};
Expand Down

0 comments on commit 879e7dd

Please sign in to comment.