The fix in #510 only worked sometimes, as seen by the numerous bugs reported by CTI surrounding things not refreshing on the tree when commands are invoked via command palette. It turns out this is because multiple items were being added to the cache with the same id. We were just returning the first one we found with a matching id when iterating through the cached items.
Solution
The solution I implemented makes it so we only ever have one object in memory for each id. Before creating a new object, we check if we have an object in the cache with that id.
I've taken extra time on this PR to do a lot of manual testing with the client extensions to make sure this functionality works. I will have CTI do test passes on the clients as well.
Fixes #640, and a bunch of others including:
Background
This following line was added in https://github.com/microsoft/vscode-azureresourcegroups/pull/510 as a band aid solution to try and fix issues where the item returned by the picker was not reference equal to the same item in the tree view. This made it so calling refresh with the item didn't refresh on the tree among other things. https://github.com/microsoft/vscode-azureresourcegroups/blob/11e06179ad12c30fb01259bbe8bfc0a87304c8eb/src/api/compatibility/pickAppResource.ts#L19
The fix in #510 only worked sometimes, as seen by the numerous bugs reported by CTI surrounding things not refreshing on the tree when commands are invoked via command palette. It turns out this is because multiple items were being added to the cache with the same id. We were just returning the first one we found with a matching id when iterating through the cached items.
Solution
The solution I implemented makes it so we only ever have one object in memory for each id. Before creating a new object, we check if we have an object in the cache with that id.
In psuedocode:
I've taken extra time on this PR to do a lot of manual testing with the client extensions to make sure this functionality works. I will have CTI do test passes on the clients as well.