Skip to content

Commit 7cb1b9d

Browse files
authored
Fix bugs with close of markdown docs (microsoft#164942)
There are two bugs here: - Something in the lsp is converting a value from `undefined` to `null`. To fix this, I've updated us just to check for falsy values instead - The `hasInMemoryDoc` implementation was incorrect. It needs to verify that the value of `this.inMemoryDoc` is not null/undefined
1 parent d65cc6a commit 7cb1b9d

File tree

1 file changed

+4
-3
lines changed
  • extensions/markdown-language-features/server/src

1 file changed

+4
-3
lines changed

extensions/markdown-language-features/server/src/workspace.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class VsCodeDocument implements md.ITextDocument {
6565
}
6666

6767
hasInMemoryDoc(): boolean {
68-
return !this.inMemoryDoc;
68+
return !!this.inMemoryDoc;
6969
}
7070

7171
isDetached(): boolean {
@@ -176,7 +176,7 @@ export class VsCodeClientWorkspace implements md.IWorkspaceWithWatching {
176176
// Check that if file has been deleted on disk.
177177
// This can happen when directories are renamed / moved. VS Code's file system watcher does not
178178
// notify us when this happens.
179-
if (await this.statBypassingCache(uri) === undefined) {
179+
if (!(await this.statBypassingCache(uri))) {
180180
if (this._documentCache.get(uri) === doc && !doc.hasInMemoryDoc()) {
181181
this.doDeleteDocument(uri);
182182
return;
@@ -355,7 +355,8 @@ export class VsCodeClientWorkspace implements md.IWorkspaceWithWatching {
355355
if (this.documents.get(uri)) {
356356
return { isDirectory: false };
357357
}
358-
return this.connection.sendRequest(protocol.fs_stat, { uri });
358+
const fsResult = await this.connection.sendRequest(protocol.fs_stat, { uri });
359+
return fsResult ?? undefined; // Force convert null to undefined
359360
}
360361

361362
async readDirectory(resource: URI): Promise<[string, md.FileStat][]> {

0 commit comments

Comments
 (0)