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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -9,7 +9,6 @@ import { IMdParser } from '../markdownEngine';
import { TableOfContents } from '../tableOfContents';
import { ITextDocument } from '../types/textDocument';
import { resolveUriToMarkdownFile } from '../util/openDocumentLink';
import { Schemes } from '../util/schemes';
import { IMdWorkspace } from '../workspace';
import { MdLinkProvider } from './documentLinks';
@ -325,7 +324,7 @@ export class MdVsCodePathCompletionProvider implements vscode.CompletionItemProv
private resolvePath(root: vscode.Uri, ref: string): vscode.Uri | undefined {
try {
if (root.scheme === Schemes.file) {
if (root.scheme === 'file') {
return vscode.Uri.file(resolve(dirname(root.fsPath), ref));
} else {
return root.with({

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);
}
}