Skip to content

Commit

Permalink
Fixes completion spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
rpaul-stripe committed Feb 14, 2024
1 parent b10ee90 commit 4824f3d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/plugins/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Completion = {
export default class CompletionProvider {
protected completions: Completion[] = [
{
match: /\{%[ ]*(\/)?[^ ]+$/,
match: /\{%([ ]*)(\/)?[^ ]+$/,
complete: (params, matches, text) => {
const uri = params.textDocument.uri;
const schema = this.services.Schema.get(uri);
Expand All @@ -26,7 +26,8 @@ export default class CompletionProvider {
data: {
resolve: "tag", uri,
block: text.trim() === matches[0],
closing: matches[1],
spacing: matches[1],
closing: matches[2],
pos: params.position
},
label,
Expand Down Expand Up @@ -111,9 +112,10 @@ export default class CompletionProvider {

if (required.length < attrs.length) attrText += `\${${index++}}`;

const spacing = item.data.spacing?.length > 0 ? '' : ' ';
const text = config.selfClosing
? `${item.label}${attrText} /%}`
: `${item.label}${attrText} %}\n\$0\n{% /${item.label} %}`;
: `${spacing}${item.label}${attrText} %}\n\$0\n{% /${item.label} %}`;

return {
...item,
Expand Down

0 comments on commit 4824f3d

Please sign in to comment.