mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
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:
@@ -16,8 +16,6 @@ import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
|||||||
import { Schemas } from 'vs/base/common/network';
|
import { Schemas } from 'vs/base/common/network';
|
||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
import * as types from 'vs/base/common/types';
|
import * as types from 'vs/base/common/types';
|
||||||
import * as fs from 'fs';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SqlMainContext, MainThreadNotebookDocumentsAndEditorsShape, SqlExtHostContext, ExtHostNotebookDocumentsAndEditorsShape,
|
SqlMainContext, MainThreadNotebookDocumentsAndEditorsShape, SqlExtHostContext, ExtHostNotebookDocumentsAndEditorsShape,
|
||||||
INotebookDocumentsAndEditorsDelta, INotebookEditorAddData, INotebookShowOptions, INotebookModelAddedData, INotebookModelChangedData
|
INotebookDocumentsAndEditorsDelta, INotebookEditorAddData, INotebookShowOptions, INotebookModelAddedData, INotebookModelChangedData
|
||||||
@@ -34,6 +32,7 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
|
|||||||
import { viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor';
|
import { viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor';
|
||||||
import { notebookModeId } from 'sql/workbench/browser/customInputConverter';
|
import { notebookModeId } from 'sql/workbench/browser/customInputConverter';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
|
import { IFileService } from 'vs/platform/files/common/files';
|
||||||
|
|
||||||
class MainThreadNotebookEditor extends Disposable {
|
class MainThreadNotebookEditor extends Disposable {
|
||||||
private _contentChangedEmitter = new Emitter<NotebookContentChange>();
|
private _contentChangedEmitter = new Emitter<NotebookContentChange>();
|
||||||
@@ -329,7 +328,8 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
|||||||
@IEditorService private _editorService: IEditorService,
|
@IEditorService private _editorService: IEditorService,
|
||||||
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
|
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
|
||||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||||
@INotebookService private readonly _notebookService: INotebookService
|
@INotebookService private readonly _notebookService: INotebookService,
|
||||||
|
@IFileService private readonly _fileService: IFileService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
if (extHostContext) {
|
if (extHostContext) {
|
||||||
@@ -709,10 +709,11 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
|||||||
if (result) {
|
if (result) {
|
||||||
if (result.next.scheme === Schemas.untitled) {
|
if (result.next.scheme === Schemas.untitled) {
|
||||||
let untitledNbName: URI = URI.parse(`untitled:${path.basename(result.next.path)}`);
|
let untitledNbName: URI = URI.parse(`untitled:${path.basename(result.next.path)}`);
|
||||||
this.doOpenEditor(untitledNbName, { initialContent: fs.readFileSync(result.next.path).toString(), initialDirtyState: false });
|
let content = await this._fileService.readFile(URI.parse(result.next.path));
|
||||||
|
await this.doOpenEditor(untitledNbName, { initialContent: content.value.toString(), initialDirtyState: false });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.doOpenEditor(result.next, {});
|
await this.doOpenEditor(result.next, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -721,10 +722,11 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
|||||||
if (result) {
|
if (result) {
|
||||||
if (result.previous.scheme === Schemas.untitled) {
|
if (result.previous.scheme === Schemas.untitled) {
|
||||||
let untitledNbName: URI = URI.parse(`untitled:${path.basename(result.previous.path)}`);
|
let untitledNbName: URI = URI.parse(`untitled:${path.basename(result.previous.path)}`);
|
||||||
this.doOpenEditor(untitledNbName, { initialContent: fs.readFileSync(result.previous.path).toString(), initialDirtyState: false });
|
let content = await this._fileService.readFile(URI.parse(result.previous.path));
|
||||||
|
await this.doOpenEditor(untitledNbName, { initialContent: content.value.toString(), initialDirtyState: false });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.doOpenEditor(result.previous, {});
|
await this.doOpenEditor(result.previous, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* 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 path from 'vs/base/common/path';
|
||||||
import * as fs from 'fs';
|
|
||||||
|
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
|
|
||||||
@@ -20,6 +19,7 @@ export class NotebookMarkdownRenderer {
|
|||||||
private _baseUrls: string[] = [];
|
private _baseUrls: string[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render(markdown: IMarkdownString): IMarkdownRenderResult {
|
render(markdown: IMarkdownString): IMarkdownRenderResult {
|
||||||
@@ -59,7 +59,7 @@ export class NotebookMarkdownRenderer {
|
|||||||
let signalInnerHTML: () => void;
|
let signalInnerHTML: () => void;
|
||||||
const withInnerHTML = new Promise(c => signalInnerHTML = c);
|
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)) {
|
if (!this._baseUrls.includes(notebookFolder)) {
|
||||||
this._baseUrls.push(notebookFolder);
|
this._baseUrls.push(notebookFolder);
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ export class NotebookMarkdownRenderer {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
let originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
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);
|
href = this.resolveUrl(base, href);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -206,6 +206,7 @@ export class NotebookMarkdownRenderer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return href;
|
return href;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveUrl(base: string, href: string) {
|
resolveUrl(base: string, href: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user