Skip to content

Commit 217d574

Browse files
committed
fix(language-service): optimism filter
1 parent 7c64219 commit 217d574

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

packages/language-service/lib/plugins/vue-template.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export function create(
274274
if (!htmlCompletion) {
275275
return;
276276
}
277-
if (!prevText.match(/\b[\S]+$/)) {
277+
if (!prevText.match(/[\S]+$/)) {
278278
htmlCompletion.isIncomplete = true;
279279
}
280280

@@ -690,11 +690,22 @@ export function create(
690690
}
691691
if (attr.name === 'ref' || attr.name.startsWith('v-')) {
692692
attributes.push(attr);
693+
continue;
693694
}
694-
else {
695+
if (!hint || hint === ':') {
695696
attributes.push({
696697
...attr,
697-
name: ':' + attr.name,
698+
name: V_BIND_SHORTHAND + attr.name,
699+
});
700+
}
701+
if (!hint || hint === 'v') {
702+
attributes.push({
703+
...attr,
704+
name: DIRECTIVE_V_BIND + attr.name,
705+
});
706+
attributes.push({
707+
...attr,
708+
name: attr.name,
698709
});
699710
}
700711
}
@@ -712,10 +723,15 @@ export function create(
712723
labelName = hyphenateAttr(labelName);
713724
}
714725

715-
if (!hint || hint === '@' || hint === 'v') {
716-
const prefix = !hint || hint === '@' ? V_ON_SHORTHAND : DIRECTIVE_V_ON;
726+
if (!hint || hint === '@') {
717727
attributes.push({
718-
name: prefix + labelName,
728+
name: V_ON_SHORTHAND + labelName,
729+
description: propMeta && createDescription(propMeta),
730+
});
731+
}
732+
if (!hint || hint === 'v') {
733+
attributes.push({
734+
name: DIRECTIVE_V_ON + labelName,
719735
description: propMeta && createDescription(propMeta),
720736
});
721737
}
@@ -726,14 +742,17 @@ export function create(
726742
const name = attrNameCasing === AttrNameCasing.Camel ? prop.name : hyphenateAttr(prop.name);
727743
return name === labelName;
728744
});
729-
if (!hint || hint === ':' || hint === 'v') {
730-
const prefix = !hint || hint === ':' ? V_BIND_SHORTHAND : DIRECTIVE_V_BIND;
745+
if (!hint || hint === ':') {
731746
attributes.push({
732-
name: prefix + labelName,
747+
name: V_BIND_SHORTHAND + labelName,
733748
description: propMeta2 && createDescription(propMeta2),
734749
});
735750
}
736751
if (!hint || hint === 'v') {
752+
attributes.push({
753+
name: DIRECTIVE_V_BIND + labelName,
754+
description: propMeta2 && createDescription(propMeta2),
755+
});
737756
attributes.push({
738757
name: labelName,
739758
description: propMeta2 && createDescription(propMeta2),
@@ -744,10 +763,15 @@ export function create(
744763
for (const event of meta?.events ?? []) {
745764
const eventName = attrNameCasing === AttrNameCasing.Camel ? event.name : hyphenateAttr(event.name);
746765

747-
if (!hint || hint === '@' || hint === 'v') {
748-
const prefix = !hint || hint === '@' ? V_ON_SHORTHAND : DIRECTIVE_V_ON;
766+
if (!hint || hint === '@') {
767+
attributes.push({
768+
name: V_ON_SHORTHAND + eventName,
769+
description: event && createDescription(event),
770+
});
771+
}
772+
if (!hint || hint === 'v') {
749773
attributes.push({
750-
name: prefix + eventName,
774+
name: DIRECTIVE_V_ON + eventName,
751775
description: event && createDescription(event),
752776
});
753777
}

0 commit comments

Comments
 (0)