Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/datascience-ui/native-editor/nativeCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ export class NativeCell extends React.Component<INativeCellProps> {

// tslint:disable-next-line: cyclomatic-complexity max-func-body-length
private keyDownInput = (cellId: string, e: IKeyboardEvent) => {
if (!this.isNotebookTrusted() && !isCellNavigationKeyboardEvent(e)) {
Copy link

@DonJayamanne DonJayamanne Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be checked only if !this.isFocused()
Cuz if a cell is focused, then k might do something else..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unfamiliar with the intended behavior here, but isn't that check already done in onOuterKeyDown?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ignore the comment, thats why i striked it out.

return;
}
const isFocusedWhenNotSuggesting = this.isFocused() && e.editorInfo && !e.editorInfo.isSuggesting;
switch (e.code) {
case 'ArrowUp':
Expand Down Expand Up @@ -886,3 +889,15 @@ export class NativeCell extends React.Component<INativeCellProps> {
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'
);
}