diff --git a/src/datascience-ui/native-editor/nativeCell.tsx b/src/datascience-ui/native-editor/nativeCell.tsx index 39f97b3f7090..77fe2ad356db 100644 --- a/src/datascience-ui/native-editor/nativeCell.tsx +++ b/src/datascience-ui/native-editor/nativeCell.tsx @@ -281,6 +281,9 @@ export class NativeCell extends React.Component { // tslint:disable-next-line: cyclomatic-complexity max-func-body-length private keyDownInput = (cellId: string, e: IKeyboardEvent) => { + if (!this.isNotebookTrusted() && !isCellNavigationKeyboardEvent(e)) { + return; + } const isFocusedWhenNotSuggesting = this.isFocused() && e.editorInfo && !e.editorInfo.isSuggesting; switch (e.code) { case 'ArrowUp': @@ -886,3 +889,15 @@ export class NativeCell extends React.Component { export function getConnectedNativeCell() { return connect(null, actionCreators)(NativeCell); } + +function isCellNavigationKeyboardEvent(e: IKeyboardEvent) { + return ( + e.code === 'Enter' || + e.code === 'NumpadEnter' || + e.code === 'ArrowUp' || + e.code === 'k' || + e.code === 'ArrowDown' || + e.code === 'j' || + e.code === 'Escape' + ); +}