Skip to content

Commit

Permalink
labels: fix caching of unintended formatters (#157313)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
connor4312 committed Aug 5, 2022
1 parent b3a5653 commit 24547bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/vs/workbench/services/label/common/labelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/services/label/test/browser/label.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {});

Expand Down

0 comments on commit 24547bc

Please sign in to comment.