Skip to content

Commit a765abc

Browse files
authored
Adopt ResourceMap for MD diagnostics (microsoft#152264)
Adopt ResourceMap Switches to use `ResourceMap` instead of our own implementation
1 parent a289e64 commit a765abc

File tree

1 file changed

+8
-8
lines changed
  • extensions/markdown-language-features/src/languageFeatures

1 file changed

+8
-8
lines changed

extensions/markdown-language-features/src/languageFeatures/diagnostics.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class LinkWatcher extends Disposable {
136136
*/
137137
public readonly onDidChangeLinkedToFile = this._onDidChangeLinkedToFile.event;
138138

139-
private readonly _watchers = new Map</* link path */ string, {
139+
private readonly _watchers = new ResourceMap<{
140140
/**
141141
* Watcher for this link path
142142
*/
@@ -145,7 +145,7 @@ class LinkWatcher extends Disposable {
145145
/**
146146
* List of documents that reference the link
147147
*/
148-
readonly documents: Map</* document resource as string */ string, /* document resource*/ vscode.Uri>;
148+
readonly documents: ResourceMap</* document resource*/ vscode.Uri>;
149149
}>();
150150

151151
override dispose() {
@@ -168,21 +168,21 @@ class LinkWatcher extends Disposable {
168168

169169
// First decrement watcher counter for previous document state
170170
for (const entry of this._watchers.values()) {
171-
entry.documents.delete(document.toString());
171+
entry.documents.delete(document);
172172
}
173173

174174
// Then create/update watchers for new document state
175175
for (const path of linkedToResource) {
176-
let entry = this._watchers.get(path.toString());
176+
let entry = this._watchers.get(path);
177177
if (!entry) {
178178
entry = {
179179
watcher: this.startWatching(path),
180-
documents: new Map(),
180+
documents: new ResourceMap(),
181181
};
182-
this._watchers.set(path.toString(), entry);
182+
this._watchers.set(path, entry);
183183
}
184184

185-
entry.documents.set(document.toString(), document);
185+
entry.documents.set(document, document);
186186
}
187187

188188
// Finally clean up watchers for links that are no longer are referenced anywhere
@@ -209,7 +209,7 @@ class LinkWatcher extends Disposable {
209209
}
210210

211211
private onLinkedResourceChanged(resource: vscode.Uri) {
212-
const entry = this._watchers.get(resource.toString());
212+
const entry = this._watchers.get(resource);
213213
if (entry) {
214214
this._onDidChangeLinkedToFile.fire(entry.documents.values());
215215
}

0 commit comments

Comments
 (0)