Skip to content

Commit

Permalink
refactor(language-service): Improve autocomplete snippet of for blo…
Browse files Browse the repository at this point in the history
…ck (#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 #52405
  • Loading branch information
atscott authored and alxhub committed Oct 31, 2023
1 parent df1b44e commit c3d60ff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/language-service/src/completions.ts
Expand Up @@ -42,14 +42,17 @@ export enum CompletionNodeContext {

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

function buildBlockSnippet(insertSnippet: boolean, text: string, withParens: boolean): string {
function buildBlockSnippet(insertSnippet: boolean, blockName: string, withParens: boolean): string {
if (!insertSnippet) {
return text;
return blockName;
}
if (blockName === 'for') {
return `${blockName} (\${1:item} of \${2:items}; track \${3:\\$index}) {$4}`;
}
if (withParens) {
return `${text} ($1) {$2}`;
return `${blockName} ($1) {$2}`;
}
return `${text} {$1}`;
return `${blockName} {$1}`;
}

/**
Expand Down

0 comments on commit c3d60ff

Please sign in to comment.