Fix Markdown tests on windows (#153212)

Fix windows tests
This commit is contained in:
Matt Bierner
2022-06-25 09:59:25 -07:00
committed by GitHub
parent 09c5a6ed48
commit d1b4630a50
2 changed files with 4 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as path from 'path';
import * as vscode from 'vscode';
import { ITextDocument } from '../types/textDocument';
import { ResourceMap } from '../util/resourceMap';
@@ -37,11 +38,11 @@ export class InMemoryMdWorkspace implements IMdWorkspace {
public async readDirectory(resource: vscode.Uri): Promise<[string, vscode.FileType][]> {
const files = new Map<string, vscode.FileType>();
const pathPrefix = resource.fsPath + (resource.fsPath.endsWith('/') ? '' : '/');
const pathPrefix = resource.fsPath + (resource.fsPath.endsWith('/') || resource.fsPath.endsWith('\\') ? '' : path.sep);
for (const doc of this._documents.values()) {
const path = doc.uri.fsPath;
if (path.startsWith(pathPrefix)) {
const parts = path.slice(pathPrefix.length).split('/');
const parts = path.slice(pathPrefix.length).split(/\/|\\/g);
files.set(parts[0], parts.length > 1 ? vscode.FileType.Directory : vscode.FileType.File);
}
}