Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Aug 25, 2024
1 parent a7f3d42 commit 4dd2bd5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/template/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function createTemplateCodegenContext(scriptSetupBindingNames: TemplateCo
source: string;
className: string;
offset: number;
}[] = [];
}[] = [];
const emptyClassOffsets: number[] = [];
const inlayHints: InlayHintInfo[] = [];

Expand Down
4 changes: 3 additions & 1 deletion packages/language-core/lib/codegen/template/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,9 @@ function* generateReferencesForScopedCssClasses(
if (
!ts.isExpressionStatement(node) ||
!isTemplateExpression(node.expression)
) return;
) {
return;
}

const expression = node.expression.templateSpans[0].expression;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export function* generateStyleScopedClasses(

function* escapeString(source: string, className: string, offset: number, escapeTargets: string[]): Generator<Code> {
let count = 0;

const currentEscapeTargets = [...escapeTargets];
const firstEscapeTarget = currentEscapeTargets.shift()!;
const splitted = className.split(firstEscapeTarget);

for (let i = 0; i < splitted.length; i++) {
const part = splitted[i];
const partLength = part.length;

if (escapeTargets.length > 0) {
yield* escapeString(source, part, offset + count, [...currentEscapeTargets]);
} else {
Expand All @@ -60,17 +60,17 @@ export function* generateStyleScopedClasses(
ctx.codeFeatures.navigationAndAdditionalCompletion,
];
}

if (i !== splitted.length - 1) {
yield '\\';

yield [
firstEscapeTarget,
source,
offset + count + partLength,
ctx.codeFeatures.navigationAndAdditionalCompletion,
];

count += partLength + 1;
} else {
count += partLength;
Expand Down

0 comments on commit 4dd2bd5

Please sign in to comment.