Use cellId for focus-editor

I believe we only care about the cell, not the output it contains
This commit is contained in:
Matt Bierner 2021-06-09 16:44:53 -07:00
parent df7fa054f7
commit 345443810e
No known key found for this signature in database
GPG key ID: 099C331567E11888
3 changed files with 9 additions and 14 deletions

View file

@ -525,17 +525,12 @@ var requirejs = (function() {
}
case 'focus-editor':
{
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
if (!latestCell) {
return;
}
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell) {
if (data.focusNext) {
this.notebookEditor.focusNextNotebookCell(latestCell, 'editor');
this.notebookEditor.focusNextNotebookCell(cell, 'editor');
} else {
this.notebookEditor.focusNotebookCell(latestCell, 'editor');
this.notebookEditor.focusNotebookCell(cell, 'editor');
}
}
break;

View file

@ -59,7 +59,7 @@ export interface IScrollAckMessage extends BaseToWebviewMessage {
export interface IBlurOutputMessage extends BaseToWebviewMessage {
readonly type: 'focus-editor';
readonly id: string;
readonly cellId: string;
readonly focusNext?: boolean;
}

View file

@ -320,12 +320,12 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
}
}
function createFocusSink(cellId: string, outputId: string, focusNext?: boolean) {
function createFocusSink(cellId: string, focusNext?: boolean) {
const element = document.createElement('div');
element.tabIndex = 0;
element.addEventListener('focus', () => {
postNotebookMessage<webviewMessages.IBlurOutputMessage>('focus-editor', {
id: outputId,
cellId: cellId,
focusNext
});
});
@ -563,7 +563,7 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
if (!cellOutputContainer) {
const container = document.getElementById('container')!;
const upperWrapperElement = createFocusSink(data.cellId, outputId);
const upperWrapperElement = createFocusSink(data.cellId);
container.appendChild(upperWrapperElement);
const newElement = document.createElement('div');
@ -574,7 +574,7 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
container.appendChild(newElement);
cellOutputContainer = newElement;
const lowerWrapperElement = createFocusSink(data.cellId, outputId, true);
const lowerWrapperElement = createFocusSink(data.cellId, true);
container.appendChild(lowerWrapperElement);
}