mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-28 13:56:50 +01:00
skip scroll to reveal when copying output and select the correct output
This commit is contained in:
@@ -39,7 +39,7 @@ registerAction2(class CopyCellOutputAction extends NotebookAction {
|
||||
if (mimeType?.startsWith('image/')) {
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const editor = editorService.activeEditorPane?.getControl() as INotebookEditor;
|
||||
await editor.focusNotebookCell(outputViewModel.cellViewModel as ICellViewModel, 'output');
|
||||
await editor.focusNotebookCell(outputViewModel.cellViewModel as ICellViewModel, 'output', { skipReveal: true, outputId: outputViewModel.model.outputId });
|
||||
editor.copyOutputImage(outputViewModel);
|
||||
} else {
|
||||
const clipboardService = accessor.get(IClipboardService);
|
||||
|
||||
@@ -151,6 +151,7 @@ export interface IFocusNotebookCellOptions {
|
||||
readonly skipReveal?: boolean;
|
||||
readonly focusEditorLine?: number;
|
||||
readonly minimalScrolling?: boolean;
|
||||
readonly outputId?: string;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -2341,6 +2341,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
|
||||
} else if (focusItem === 'output') {
|
||||
this.focusElement(cell);
|
||||
|
||||
|
||||
if (!this.hasEditorFocus()) {
|
||||
this._list.focusView();
|
||||
}
|
||||
@@ -2349,9 +2350,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
|
||||
return;
|
||||
}
|
||||
|
||||
if (!options?.skipReveal) {
|
||||
this._webview.focusOutput(cell.id, this._webviewFocused);
|
||||
}
|
||||
const focusElementId = options?.outputId ?? cell.id;
|
||||
this._webview.focusOutput(focusElementId, this._webviewFocused);
|
||||
|
||||
cell.updateEditState(CellEditState.Preview, 'focusNotebookCell');
|
||||
cell.focusMode = CellFocusMode.Output;
|
||||
|
||||
@@ -1606,7 +1606,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable {
|
||||
this.webview?.focus();
|
||||
}
|
||||
|
||||
focusOutput(cellId: string, viewFocused: boolean) {
|
||||
focusOutput(cellOrOutputId: string, viewFocused: boolean) {
|
||||
if (this._disposed) {
|
||||
return;
|
||||
}
|
||||
@@ -1617,7 +1617,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable {
|
||||
|
||||
this._sendMessageToWebview({
|
||||
type: 'focus-output',
|
||||
cellId,
|
||||
cellOrOutputId: cellOrOutputId,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ export interface ICopyImageMessage {
|
||||
|
||||
export interface IFocusOutputMessage {
|
||||
readonly type: 'focus-output';
|
||||
readonly cellId: string;
|
||||
readonly cellOrOutputId: string;
|
||||
}
|
||||
|
||||
export interface IAckOutputHeight {
|
||||
|
||||
@@ -474,8 +474,8 @@ async function webviewPreloads(ctx: PreloadContext) {
|
||||
});
|
||||
};
|
||||
|
||||
function focusFirstFocusableOrContainerInOutput(cellId: string) {
|
||||
const cellOutputContainer = document.getElementById(cellId);
|
||||
function focusFirstFocusableOrContainerInOutput(cellOrOutputId: string) {
|
||||
const cellOutputContainer = document.getElementById(cellOrOutputId);
|
||||
if (cellOutputContainer) {
|
||||
if (cellOutputContainer.contains(document.activeElement)) {
|
||||
return;
|
||||
@@ -1523,7 +1523,7 @@ async function webviewPreloads(ctx: PreloadContext) {
|
||||
break;
|
||||
}
|
||||
case 'focus-output':
|
||||
focusFirstFocusableOrContainerInOutput(event.data.cellId);
|
||||
focusFirstFocusableOrContainerInOutput(event.data.cellOrOutputId);
|
||||
break;
|
||||
case 'decorations': {
|
||||
let outputContainer = document.getElementById(event.data.cellId);
|
||||
|
||||
Reference in New Issue
Block a user