Skip to content

Commit d1b4630

Browse files
authored
Fix Markdown tests on windows (microsoft#153212)
Fix windows tests
1 parent 09c5a6e commit d1b4630

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { IMdParser } from '../markdownEngine';
99
import { TableOfContents } from '../tableOfContents';
1010
import { ITextDocument } from '../types/textDocument';
1111
import { resolveUriToMarkdownFile } from '../util/openDocumentLink';
12-
import { Schemes } from '../util/schemes';
1312
import { IMdWorkspace } from '../workspace';
1413
import { MdLinkProvider } from './documentLinks';
1514

@@ -325,7 +324,7 @@ export class MdVsCodePathCompletionProvider implements vscode.CompletionItemProv
325324

326325
private resolvePath(root: vscode.Uri, ref: string): vscode.Uri | undefined {
327326
try {
328-
if (root.scheme === Schemes.file) {
327+
if (root.scheme === 'file') {
329328
return vscode.Uri.file(resolve(dirname(root.fsPath), ref));
330329
} else {
331330
return root.with({

extensions/markdown-language-features/src/test/inMemoryWorkspace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as assert from 'assert';
7+
import * as path from 'path';
78
import * as vscode from 'vscode';
89
import { ITextDocument } from '../types/textDocument';
910
import { ResourceMap } from '../util/resourceMap';
@@ -37,11 +38,11 @@ export class InMemoryMdWorkspace implements IMdWorkspace {
3738

3839
public async readDirectory(resource: vscode.Uri): Promise<[string, vscode.FileType][]> {
3940
const files = new Map<string, vscode.FileType>();
40-
const pathPrefix = resource.fsPath + (resource.fsPath.endsWith('/') ? '' : '/');
41+
const pathPrefix = resource.fsPath + (resource.fsPath.endsWith('/') || resource.fsPath.endsWith('\\') ? '' : path.sep);
4142
for (const doc of this._documents.values()) {
4243
const path = doc.uri.fsPath;
4344
if (path.startsWith(pathPrefix)) {
44-
const parts = path.slice(pathPrefix.length).split('/');
45+
const parts = path.slice(pathPrefix.length).split(/\/|\\/g);
4546
files.set(parts[0], parts.length > 1 ? vscode.FileType.Directory : vscode.FileType.File);
4647
}
4748
}

0 commit comments

Comments
 (0)