Fix/replace wrong imports (#7158)

* replaced fs with IFileService

* work around for URI with relative paths

* updates to comments

* renamed existsSync to exists

* await on promise inside non-async method

* .then change

* await async calls

* removed the old code

* include everthing in .then

* remove file exists check

* added _ for consistency

* use path.abosult method

* fixed the cleanIrl calls back and path.sep change

* reverted path.sep for now
This commit is contained in:
Maddy
2019-09-13 13:11:18 -07:00
committed by GitHub
parent 86df538db9
commit 29dbce079b
2 changed files with 13 additions and 10 deletions

View File

@@ -3,7 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'vs/base/common/path';
import * as fs from 'fs';
import { URI } from 'vs/base/common/uri';
@@ -20,6 +19,7 @@ export class NotebookMarkdownRenderer {
private _baseUrls: string[] = [];
constructor() {
}
render(markdown: IMarkdownString): IMarkdownRenderResult {
@@ -59,7 +59,7 @@ export class NotebookMarkdownRenderer {
let signalInnerHTML: () => void;
const withInnerHTML = new Promise(c => signalInnerHTML = c);
let notebookFolder = path.dirname(this._notebookURI.path) + '/';
let notebookFolder = path.dirname(this._notebookURI.fsPath) + '/';
if (!this._baseUrls.includes(notebookFolder)) {
this._baseUrls.push(notebookFolder);
}
@@ -197,7 +197,7 @@ export class NotebookMarkdownRenderer {
// ignore
}
let originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
if (base && !originIndependentUrl.test(href) && !fs.existsSync(href)) {
if (base && !originIndependentUrl.test(href) && !path.isAbsolute(href)) {
href = this.resolveUrl(base, href);
}
try {
@@ -206,6 +206,7 @@ export class NotebookMarkdownRenderer {
return null;
}
return href;
}
resolveUrl(base: string, href: string) {