Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update extension model to focus on last cell added through input box #161630

Merged
merged 2 commits into from Sep 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -54,6 +54,7 @@ import { NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vs/workbench/contrib/noteb
import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
import * as icons from 'vs/workbench/contrib/notebook/browser/notebookIcons';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
import { CellEditType, CellKind, CellUri, ICellOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { INotebookContentProvider, INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
Expand Down Expand Up @@ -474,6 +475,7 @@ registerAction2(class extends Action2 {
const editorService = accessor.get(IEditorService);
const bulkEditService = accessor.get(IBulkEditService);
const historyService = accessor.get(IInteractiveHistoryService);
const notebookEditorService = accessor.get(INotebookEditorService);
let editorControl: { notebookEditor: NotebookEditorWidget | undefined; codeEditor: CodeEditorWidget } | undefined;
if (context) {
if (context.scheme === Schemas.vscodeInteractive) {
Expand Down Expand Up @@ -514,6 +516,7 @@ registerAction2(class extends Action2 {
outputCollapsed: false
} :
undefined;

await bulkEditService.apply([
new ResourceNotebookCellEdit(notebookDocument.uri,
{
Expand All @@ -534,8 +537,16 @@ registerAction2(class extends Action2 {
]);

// reveal the cell into view first
editorControl.notebookEditor.revealCellRangeInView({ start: index, end: index + 1 });
const range = { start: index, end: index + 1 };
editorControl.notebookEditor.revealCellRangeInView(range);
await editorControl.notebookEditor.executeNotebookCells(editorControl.notebookEditor.getCellsInRange({ start: index, end: index + 1 }));

// update the selection and focus in the extension host model
const editor = notebookEditorService.getNotebookEditor(editorControl.notebookEditor.getId());
if (editor) {
editor.setSelections([range]);
editor.setFocus(range);
}
}
}
}
Expand Down