From 394eaa9fa3605c60d5391a11ea4214657edd71f9 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 14 Jul 2022 18:15:13 -0700 Subject: [PATCH] Fix md document links for untitled files (#155248) --- .../markdown-language-features/server/src/workspace.ts | 5 ++++- .../markdown-language-features/src/test/documentLink.test.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/markdown-language-features/server/src/workspace.ts b/extensions/markdown-language-features/server/src/workspace.ts index 7838c20f328..5847d0c5505 100644 --- a/extensions/markdown-language-features/server/src/workspace.ts +++ b/extensions/markdown-language-features/server/src/workspace.ts @@ -162,7 +162,10 @@ export class VsCodeClientWorkspace implements md.IWorkspace { } } - stat(resource: URI): Promise { + async stat(resource: URI): Promise { + if (this._documentCache.has(resource) || this.documents.get(resource.toString())) { + return { isDirectory: false }; + } return this.connection.sendRequest(protocol.statFileRequestType, { uri: resource.toString() }); } diff --git a/extensions/markdown-language-features/src/test/documentLink.test.ts b/extensions/markdown-language-features/src/test/documentLink.test.ts index 6902d689762..37fe52e3dfb 100644 --- a/extensions/markdown-language-features/src/test/documentLink.test.ts +++ b/extensions/markdown-language-features/src/test/documentLink.test.ts @@ -134,7 +134,7 @@ async function getLinksForFile(file: vscode.Uri): Promise } }); - test.skip('Should navigate to fragment within current untitled file', async () => { // TODO: skip for now for ls migration + test('Should navigate to fragment within current untitled file', async () => { // TODO: skip for now for ls migration const testFile = workspaceFile('x.md').with({ scheme: 'untitled' }); await withFileContents(testFile, joinLines( '[](#second)',