Use cellId for focus-editor
I believe we only care about the cell, not the output it contains
This commit is contained in:
parent
df7fa054f7
commit
345443810e
3 changed files with 9 additions and 14 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue