Skip to content

Commit

Permalink
Fix to normalize the names in lgUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
taicchoumsft committed Apr 19, 2021
1 parent 7077369 commit 58a9277
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Composer/packages/lib/indexers/src/utils/lgUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
Range,
LgFile,
DiagnosticSeverity,
LgTemplateRef,
} from '@bfc/shared';
import formatMessage from 'format-message';
import isEmpty from 'lodash/isEmpty';
Expand Down Expand Up @@ -238,7 +239,15 @@ export function removeTemplates(
): LgFile {
const { id } = lgFile;
let resource = getLgResource(lgFile, importResolver);
templateNames.forEach((templateName) => {

const normalizedLgTemplates = templateNames
.map((x) => {
const lgTemplateRef = LgTemplateRef.parse(x);
return lgTemplateRef ? lgTemplateRef.name : x;
})
.filter((x) => !!x);

normalizedLgTemplates.forEach((templateName) => {
resource = resource.deleteTemplate(templateName);
});
return convertTemplatesToLgFile(id, resource.toString(), resource);
Expand Down

0 comments on commit 58a9277

Please sign in to comment.