labels: fix caching of unintended formatters (#157313)

* labels: fix caching of unintended formatters

`this.formatters` was the same list instance stored in the memo, so we
could cache things we didn't want to. I believe this caused #156135,
since things we _intend_ to cache from the extension host are parsed
from JSON and cannot be circular.

Fixes #156135

* labels: rev label storage to avoid previous bugs

Fixes #155844

* fixup! tets
This commit is contained in:
Connor Peet 2022-08-05 13:13:58 -07:00 committed by GitHub
parent b3a5653de7
commit 24547bcd8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -143,9 +143,9 @@ export class LabelService extends Disposable implements ILabelService {
this.os = OS;
this.userHome = pathService.defaultUriScheme === Schemas.file ? this.pathService.userHome({ preferLocal: true }) : undefined;
const memento = this.storedFormattersMemento = new Memento('cachedResourceLabelFormatters', storageService);
const memento = this.storedFormattersMemento = new Memento('cachedResourceLabelFormatters2', storageService);
this.storedFormatters = memento.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE);
this.formatters = this.storedFormatters?.formatters || [];
this.formatters = this.storedFormatters?.formatters?.slice() || [];
// Remote environment is potentially long running
this.resolveRemoteEnvironment();

View file

@ -166,7 +166,7 @@ suite('URI Label', () => {
test('label caching', () => {
const m = new Memento('cachedResourceLabelFormatters', storageService).getMemento(StorageScope.PROFILE, StorageTarget.MACHINE);
const m = new Memento('cachedResourceLabelFormatters2', storageService).getMemento(StorageScope.PROFILE, StorageTarget.MACHINE);
const makeFormatter = (scheme: string): ResourceLabelFormatter => ({ formatting: { label: `\${path} (${scheme})`, separator: '/' }, scheme });
assert.deepStrictEqual(m, {});