Skip to content

Conversation

joyceerhl
Copy link

For #12912

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

@joyceerhl joyceerhl added the no-changelog No news entry required label Jul 13, 2020
e.code !== 'ArrowUp' &&
e.code !== 'ArrowDown' &&
e.code !== 'j' &&
e.code !== 'Escape'
Copy link
Author

Choose a reason for hiding this comment

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

These keystrokes are used to navigate and not edit a notebook, so I think we should propagate these, but open to suggestions

Choose a reason for hiding this comment

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

I think its better to check if something is a cell navigation shortcut or a cell edit shortcut.
This method is a little confusing for me cuz there are two negations, each if condition and then a negation at the method name level.

Also i know ArrowUp or k means select the previous cell. I.e. ArrowUp is a cell navigation, what k is treated as a non-cell navigation key. That doesn't seem right.

I personally think it would be more readable to have a function call ~isCellNavigationKeyboardEvent than doing the negation in the function and naming it as such.

Copy link
Author

Choose a reason for hiding this comment

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

Oops, good catch, k is supposed to be there and has now been added. Also renamed the function!

return connect(null, actionCreators)(NativeCell);
}

function isNotWhitelistedCommand(e: IKeyboardEvent) {

Choose a reason for hiding this comment

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

In what context is a whiteListedCommand used? it mean be anything.
is it a list of commands excluded when a notebook is running, disabled, kernel is busy, no kernel, etc.

Copy link
Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Thanks but when looking at the code it is not obvious, i'd like a better name.
E.g. isCellNavigationKeyboardEvent

Copy link
Author

Choose a reason for hiding this comment

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

@DonJayamanne how about isNotebookEditingCommand or isNotNotebookNavigationCommand?

Copy link
Author

Choose a reason for hiding this comment

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

Oh sorry missed your suggestion, isCellNavigationKeyboardEvent works

Copy link
Author

Choose a reason for hiding this comment

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

It should actually be isNotCellNavigationKeyboardEvent, i.e. if the notebook is untrusted and the command is not just for navigating the notebook, we shouldn't allow it


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

Choose a reason for hiding this comment

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

Looks like we need a better property. I think what we're after is readonly.
I.e. if a cell is readonly, then some keyboard shortcuts cannot be handled & the like.

Cuz the requirement is when a notebook is not trusted, then treat it as readonly, right now, when a notebook is not trusted, then ignore some keys, etc.
I know its laet for this change to be made, hence I wouldn't change it now, as it needs to be done across the UI.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'd agree with this. I think that it's going to be easy to accidentally add a new key / command in the future and possibly enable something for an untrusted notebook that we don't want enable.

Copy link

@DonJayamanne DonJayamanne left a comment

Choose a reason for hiding this comment

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

Blocking based on function name isNotWhiteListedCommand, there's no context hence not sure what it means here.
Also instead of whitelist i'd prefer to use included/excluded or similar.

e.code !== 'ArrowUp' &&
e.code !== 'ArrowDown' &&
e.code !== 'j' &&
e.code !== 'Escape'

Choose a reason for hiding this comment

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

I think its better to check if something is a cell navigation shortcut or a cell edit shortcut.
This method is a little confusing for me cuz there are two negations, each if condition and then a negation at the method name level.

Also i know ArrowUp or k means select the previous cell. I.e. ArrowUp is a cell navigation, what k is treated as a non-cell navigation key. That doesn't seem right.

I personally think it would be more readable to have a function call ~isCellNavigationKeyboardEvent than doing the negation in the function and naming it as such.

@joyceerhl joyceerhl requested a review from DonJayamanne July 13, 2020 15:45
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@joyceerhl joyceerhl mentioned this pull request Jul 13, 2020
10 tasks

// 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.

@joyceerhl joyceerhl merged commit 68f4bb0 into microsoft:master Jul 13, 2020
joyceerhl added a commit that referenced this pull request Jul 13, 2020
* Fix regressions in trusted notebooks (#12902)

* Handle trustAllNotebooks selection

* Fix bug where after trusting, UI didn't update

* Recover from ENOENT due to missing parent directory when trusting notebook (#12913)

* Disable keydown on native cells in untrusted notebooks (#12914)
karthiknadig added a commit that referenced this pull request Aug 5, 2020
* Update model.isTrusted on trust change (#12820) (#12823)

* Reduce visual complexity of trust prompt (#12839) (#12847)

* Port python 2.7 fix to release (#12877)

* port color fix on collapse all (#12895) (#12897)

* fix a color on collapse all (#12895)

* update changelog

* Merge fixes into July release (#12889)

Co-authored-by: Timothy Ruscica <35348871+techwithtim@users.noreply.github.com>

* Merge more fixes into july release (#12918)

Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>

* Port trust fixes (#12929)

* Fix regressions in trusted notebooks (#12902)

* Handle trustAllNotebooks selection

* Fix bug where after trusting, UI didn't update

* Recover from ENOENT due to missing parent directory when trusting notebook (#12913)

* Disable keydown on native cells in untrusted notebooks (#12914)

* Hide editor icons when editor is not a notebook (#12934) (#12935)

* Check for hideFromUser before activating current terminal (#12942) (#12956)

* Check for hideFromUser before activating current terminal

* Add tests

* Tweak logic

* Port final trust fixes for release (#12965)

* Only allow Enter / NumpadEnter w/o ctrl/shift/alt (#12939)

* Send telemetry for notebook trust prompt selections (#12964)

* Fixes for persisting trust (#12950)

* Display survey for native notebooks on/after 1st August (#12961) (#12975)

Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>

Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>

* Contains cherry picks, version updates, change log updates (#12983)

* Update version and change log

* Improve detection when LS is fully loaded for IntelliCode (#12853)

* Fix path

* Actually fix settings

* Add news

* Add test

* Format

* Suppress 'jediEnabled' removal

* Drop survey first launch threshold

* Wait for client ready

* Handle async dispose

* Fix the date

Co-authored-by: Mikhail Arkhipov <mikhaila@microsoft.com>

* hide the gather button while a cell is executing (#12984)

* Update date (#13002)

* remove release notes from the start page (#13032)

* Cherry pick, version change and change log update (#13079)

* Ensure languageServer value is valid, send event during activate (#13064)

* Update change log and version

* Activate banner prompt for Pylance (#12817)

* Fix path

* Actually fix settings

* Add news

* Add test

* Format

* Suppress 'jediEnabled' removal

* Drop survey first launch threshold

* Remove LS experiments

* Frequency + tests

* Fix test

* Update message to match spec

* Open workspace for extension rather than changing setting

* Fix localization string

* Show banners asynchronously

* Add experiments

* Formatting

* Typo

* Put back verifyAll

* Remove obsolete experiments, add Pylance

* Suppress experiment if Pylance is installed

* PR feedback

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>

* Update change log as per comments

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: Mikhail Arkhipov <mikhaila@microsoft.com>

* Port fix the gather survey (#13086) (#13105)

* Fix the gather survey (#13086)

* fix the gather survey
added 'gather stats' telemetry
mention the gather comments to update the python ext

* oops

* fix tests and address comments

* update gather stats when resetting the kernel

* set globalstate vars to 0 when we open vs code

* fix gather stats telemetry

* fix tests

* fix tests for real

Co-authored-by: Joyce Er <joyceerhuiling@gmail.com>
Co-authored-by: Ian Huff <ianhu@microsoft.com>
Co-authored-by: David Kutugata <dakutuga@microsoft.com>
Co-authored-by: Don Jayamanne <don.jayamanne@yahoo.com>
Co-authored-by: Timothy Ruscica <35348871+techwithtim@users.noreply.github.com>
Co-authored-by: Mikhail Arkhipov <mikhaila@microsoft.com>
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants