Skip to content

Commit c3d60ff

Browse files
atscottalxhub
authored andcommitted
refactor(language-service): Improve autocomplete snippet of for block (angular#52405)
The `for` block has several parts which we know are required. This commit improves the autocomplete snippet of the `for` block by adding those required parts and providing placeholders. PR Close angular#52405
1 parent df1b44e commit c3d60ff

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/language-service/src/completions.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ export enum CompletionNodeContext {
4242

4343
const ANIMATION_PHASES = ['start', 'done'];
4444

45-
function buildBlockSnippet(insertSnippet: boolean, text: string, withParens: boolean): string {
45+
function buildBlockSnippet(insertSnippet: boolean, blockName: string, withParens: boolean): string {
4646
if (!insertSnippet) {
47-
return text;
47+
return blockName;
48+
}
49+
if (blockName === 'for') {
50+
return `${blockName} (\${1:item} of \${2:items}; track \${3:\\$index}) {$4}`;
4851
}
4952
if (withParens) {
50-
return `${text} ($1) {$2}`;
53+
return `${blockName} ($1) {$2}`;
5154
}
52-
return `${text} {$1}`;
55+
return `${blockName} {$1}`;
5356
}
5457

5558
/**

0 commit comments

Comments
 (0)