Skip to content

Commit

Permalink
file associations should be unique by pattern, not system id
Browse files Browse the repository at this point in the history
Fixes #1053

Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 committed Mar 3, 2025
1 parent 18766de commit 5a4cbb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/api/xmlExtensionApiImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function getXmlExtensionApiImplementation(languageClient: LanguageClient,
addXMLFileAssociations: (fileAssociations: XMLFileAssociation[]) => {
const externalfileAssociations = externalXmlSettings.xmlFileAssociations;
fileAssociations.forEach(element => {
if (!externalfileAssociations.some(fileAssociation => fileAssociation.systemId === element.systemId)) {
if (!externalfileAssociations.some(fileAssociation => fileAssociation.pattern === element.pattern)) {
externalfileAssociations.push(element);
}
});
Expand All @@ -54,7 +54,7 @@ export function getXmlExtensionApiImplementation(languageClient: LanguageClient,
removeXMLFileAssociations: (fileAssociations: XMLFileAssociation[]) => {
const externalfileAssociations = externalXmlSettings.xmlFileAssociations;
fileAssociations.forEach(element => {
const itemIndex = externalfileAssociations.findIndex(fileAssociation => fileAssociation.systemId === element.systemId) //returns -1 if item not found
const itemIndex = externalfileAssociations.findIndex(fileAssociation => fileAssociation.pattern === element.pattern) //returns -1 if item not found
if (itemIndex > -1) {
externalfileAssociations.splice(itemIndex, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export function getXMLSettings(javaHome: string | undefined, logfile: string, ex
}
})
externalXmlSettings.xmlFileAssociations.forEach(element => {
if (!xml['xml']['fileAssociations'].some(fileAssociation => fileAssociation.systemId === element.systemId)) {
if (!xml['xml']['fileAssociations'].some(fileAssociation => fileAssociation.pattern === element.pattern)) {
xml['xml']['fileAssociations'].push(element);
}
});
Expand Down

0 comments on commit 5a4cbb1

Please sign in to comment.