Skip to content

Commit ff96c2d

Browse files
committed
Fix #2304
1 parent 5cc549a commit ff96c2d

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### 0.28.0
44

5+
- Fix completing prop name completes with extra `:`. #2304.
56
- Add `vetur.languageFeatures.codeActions` option to disable codeAction. #2150
67
- Let VTI load default VLS config. #2274.
78
- Make `prettier` default formatter for HTML as prettyhtml is no longer actively maintained. #2291.

server/src/modes/template/services/htmlCompletion.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ export function doComplete(
154154
if (type !== 'v' && value.length) {
155155
codeSnippet = codeSnippet + value;
156156
}
157+
if ((filterPrefix === ':' && codeSnippet[0] === ':') || (filterPrefix === '@' && codeSnippet[0] === '@')) {
158+
codeSnippet = codeSnippet.slice(1);
159+
}
157160
result.items.push({
158161
label: attribute,
159162
kind: type === 'event' ? CompletionItemKind.Function : CompletionItemKind.Value,

test/completionHelper.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export interface ExpectedCompletionItem extends CompletionItem {
1212
* Documentation has to include this string
1313
*/
1414
documentationFragment?: string;
15+
/**
16+
* Insertion text edit's string
17+
*/
18+
insertTextValue?: string;
1519
}
1620

1721
export async function testCompletion(
@@ -99,6 +103,14 @@ export async function testCompletion(
99103
);
100104
}
101105
}
106+
107+
if (ei.insertTextValue) {
108+
if (match.insertText instanceof vscode.SnippetString) {
109+
assert.strictEqual(match.insertText.value, ei.insertTextValue);
110+
} else {
111+
assert.strictEqual(match.insertText, ei.insertTextValue);
112+
}
113+
}
102114
}
103115
});
104116
}

test/lsp/features/completion/template.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,18 @@ describe('Should autocomplete for <template>', () => {
7171

7272
await testCompletion(parentUri, position(4, 6), ['ChildComp']);
7373

74-
await testCompletion(parentUri, position(2, 15), [':attr-a']);
75-
await testCompletion(parentUri, position(3, 16), [':attr-a']);
74+
await testCompletion(parentUri, position(2, 15), [
75+
{
76+
label: ':attr-a',
77+
insertTextValue: ':attr-a="$1"'
78+
}
79+
]);
80+
await testCompletion(parentUri, position(3, 16), [
81+
{
82+
label: ':attr-a',
83+
insertTextValue: 'attr-a="$1"'
84+
}
85+
]);
7686

7787
// set it back
7888
await c.update('vetur.completion.tagCasing', undefined, ConfigurationTarget.Global);

0 commit comments

Comments
 (0)