mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 06:38:23 +00:00
Pass associated notebook document to kernel source command (#163701)
This commit is contained in:
parent
1afc67ea7f
commit
5612f80f8d
3 changed files with 16 additions and 2 deletions
|
@ -17,6 +17,7 @@ export const enum MarshalledId {
|
|||
CommentThreadNode,
|
||||
TimelineActionContext,
|
||||
NotebookCellActionContext,
|
||||
NotebookActionContext,
|
||||
TestItemContext,
|
||||
Date
|
||||
}
|
||||
|
|
|
@ -92,6 +92,13 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
|
|||
return cell.apiCell;
|
||||
}
|
||||
}
|
||||
if (arg && arg.$mid === MarshalledId.NotebookActionContext) {
|
||||
const notebookUri = arg.uri;
|
||||
const data = this._documents.get(notebookUri);
|
||||
if (data) {
|
||||
return data.apiNotebook;
|
||||
}
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -15,6 +15,7 @@ import { runWhenIdle } from 'vs/base/common/async';
|
|||
import { IMenu, IMenuService, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { MarshalledId } from 'vs/base/common/marshallingIds';
|
||||
|
||||
class KernelInfo {
|
||||
|
||||
|
@ -53,6 +54,7 @@ class SourceAction extends Disposable implements ISourceAction {
|
|||
|
||||
constructor(
|
||||
readonly action: IAction,
|
||||
readonly model: INotebookTextModelLike,
|
||||
readonly isPrimary: boolean
|
||||
) {
|
||||
super();
|
||||
|
@ -72,7 +74,11 @@ class SourceAction extends Disposable implements ISourceAction {
|
|||
|
||||
private async _runAction(): Promise<void> {
|
||||
try {
|
||||
await this.action.run();
|
||||
await this.action.run({
|
||||
uri: this.model.uri,
|
||||
$mid: MarshalledId.NotebookActionContext
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.warn(`Kernel source command failed: ${error}`);
|
||||
}
|
||||
|
@ -314,7 +320,7 @@ export class NotebookKernelService extends Disposable implements INotebookKernel
|
|||
groups.forEach(group => {
|
||||
const isPrimary = /^primary/.test(group[0]);
|
||||
group[1].forEach(action => {
|
||||
const sourceAction = new SourceAction(action, isPrimary);
|
||||
const sourceAction = new SourceAction(action, notebook, isPrimary);
|
||||
const stateChangeListener = sourceAction.onDidChangeState(() => {
|
||||
this._onDidChangeSourceActions.fire({
|
||||
notebook: notebook.uri
|
||||
|
|
Loading…
Reference in a new issue