mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 09:35:37 -05:00
Add placeholders for missing VSCode notebook events that are used by the Jupyter extension. (#18138)
* Also reduced the number of timeouts for waiting on notebook provider descriptors, and fixed an issue with undefined cancellation tokens in vscode notebook conversion code.
This commit is contained in:
@@ -54,10 +54,27 @@ export class ExtHostNotebookDocumentsAndEditors implements ExtHostNotebookDocume
|
||||
private readonly _onDidChangeActiveVSCodeEditor = new Emitter<vscode.NotebookEditor>();
|
||||
private readonly _onDidOpenVSCodeNotebook = new Emitter<vscode.NotebookDocument>();
|
||||
private readonly _onDidCloseVSCodeNotebook = new Emitter<vscode.NotebookDocument>();
|
||||
private readonly _onDidSaveVSCodeNotebook = new Emitter<vscode.NotebookDocument>();
|
||||
private readonly _onDidChangeVSCodeCellMetadata = new Emitter<vscode.NotebookCellMetadataChangeEvent>();
|
||||
private readonly _onDidChangeVSCodeDocumentMetadata = new Emitter<vscode.NotebookDocumentMetadataChangeEvent>();
|
||||
private readonly _onDidChangeVSCodeCellOutputs = new Emitter<vscode.NotebookCellOutputsChangeEvent>();
|
||||
private readonly _onDidChangeVSCodeNotebookCells = new Emitter<vscode.NotebookCellsChangeEvent>();
|
||||
private readonly _onDidChangeVSCodeExecutionState = new Emitter<vscode.NotebookCellExecutionStateChangeEvent>();
|
||||
private readonly _onDidChangeVSCodeEditorSelection = new Emitter<vscode.NotebookEditorSelectionChangeEvent>();
|
||||
private readonly _onDidChangeVSCodeEditorRanges = new Emitter<vscode.NotebookEditorVisibleRangesChangeEvent>();
|
||||
|
||||
readonly onDidChangeVisibleVSCodeEditors: Event<vscode.NotebookEditor[]> = this._onDidChangeVisibleVSCodeEditors.event;
|
||||
readonly onDidChangeActiveVSCodeEditor: Event<vscode.NotebookEditor> = this._onDidChangeActiveVSCodeEditor.event;
|
||||
readonly onDidOpenVSCodeNotebookDocument: Event<vscode.NotebookDocument> = this._onDidOpenVSCodeNotebook.event;
|
||||
readonly onDidCloseVSCodeNotebookDocument: Event<vscode.NotebookDocument> = this._onDidCloseVSCodeNotebook.event;
|
||||
readonly onDidSaveVSCodeNotebookDocument: Event<vscode.NotebookDocument> = this._onDidSaveVSCodeNotebook.event;
|
||||
readonly onDidChangeVSCodeCellMetadata: Event<vscode.NotebookCellMetadataChangeEvent> = this._onDidChangeVSCodeCellMetadata.event;
|
||||
readonly onDidChangeVSCodeDocumentMetadata: Event<vscode.NotebookDocumentMetadataChangeEvent> = this._onDidChangeVSCodeDocumentMetadata.event;
|
||||
readonly onDidChangeVSCodeCellOutputs: Event<vscode.NotebookCellOutputsChangeEvent> = this._onDidChangeVSCodeCellOutputs.event;
|
||||
readonly onDidChangeVSCodeNotebookCells: Event<vscode.NotebookCellsChangeEvent> = this._onDidChangeVSCodeNotebookCells.event;
|
||||
readonly onDidChangeVSCodeExecutionState: Event<vscode.NotebookCellExecutionStateChangeEvent> = this._onDidChangeVSCodeExecutionState.event;
|
||||
readonly onDidChangeVSCodeEditorSelection: Event<vscode.NotebookEditorSelectionChangeEvent> = this._onDidChangeVSCodeEditorSelection.event;
|
||||
readonly onDidChangeVSCodeEditorRanges: Event<vscode.NotebookEditorVisibleRangesChangeEvent> = this._onDidChangeVSCodeEditorRanges.event;
|
||||
|
||||
constructor(
|
||||
private readonly _mainContext: IMainContext,
|
||||
|
||||
@@ -14,6 +14,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { NotebookCellExecutionTaskState } from 'vs/workbench/api/common/extHostNotebookKernels';
|
||||
import { asArray } from 'vs/base/common/arrays';
|
||||
import { convertToADSCellOutput } from 'sql/workbench/api/common/notebooks/notebookUtils';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
type SelectionChangedEvent = { selected: boolean, notebook: vscode.NotebookDocument; };
|
||||
type MessageReceivedEvent = { editor: vscode.NotebookEditor, message: any; };
|
||||
@@ -173,7 +174,7 @@ class ADSNotebookCellExecution implements vscode.NotebookCellExecution {
|
||||
}
|
||||
|
||||
public get token(): vscode.CancellationToken {
|
||||
return undefined;
|
||||
return CancellationToken.None;
|
||||
}
|
||||
|
||||
public get executionOrder(): number {
|
||||
|
||||
@@ -40,6 +40,6 @@ export class VSCodeNotebookEditor implements vscode.NotebookEditor {
|
||||
}
|
||||
|
||||
public setDecorations(decorationType: vscode.NotebookEditorDecorationType, range: vscode.NotebookRange): void {
|
||||
throw new Error(functionalityNotSupportedError);
|
||||
// No-op
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import type * as vscode from 'vscode';
|
||||
import type * as azdata from 'azdata';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { convertToADSNotebookContents, convertToVSCodeNotebookData } from 'sql/workbench/api/common/notebooks/notebookUtils';
|
||||
|
||||
export class VSCodeContentManager implements azdata.nb.ContentManager {
|
||||
@@ -15,13 +15,13 @@ export class VSCodeContentManager implements azdata.nb.ContentManager {
|
||||
|
||||
public async deserializeNotebook(contents: string): Promise<azdata.nb.INotebookContents> {
|
||||
let buffer = VSBuffer.fromString(contents);
|
||||
let notebookData = await this._serializer.deserializeNotebook(buffer.buffer, new CancellationTokenSource().token);
|
||||
let notebookData = await this._serializer.deserializeNotebook(buffer.buffer, CancellationToken.None);
|
||||
return convertToADSNotebookContents(notebookData);
|
||||
}
|
||||
|
||||
public async serializeNotebook(notebook: azdata.nb.INotebookContents): Promise<string> {
|
||||
let notebookData = convertToVSCodeNotebookData(notebook);
|
||||
let bytes = await this._serializer.serializeNotebook(notebookData, new CancellationTokenSource().token);
|
||||
let bytes = await this._serializer.serializeNotebook(notebookData, CancellationToken.None);
|
||||
let buffer = VSBuffer.wrap(bytes);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user