Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix not being able to type in code cell after switching from text #17590

Merged
merged 2 commits into from
Nov 4, 2021

Conversation

Charles-Gagnon
Copy link
Contributor

@Charles-Gagnon Charles-Gagnon commented Nov 4, 2021

Fixes #17579 (there are some perf issues mentioned there that this doesn't specifically address, we can follow up to see if those are still happening after this fix goes in)

This was introduced by #17180

The problem here is that the onCellMarkdownModeChanged and onCellPreviewModeChanged callbacks are being called every time we switch cells - even if the text cell in question isn't active. In focusIfPreviewMode there was logic added that gets the current window selection and then replaces it with a new selection for the text cell - but this means that if we're moving into a code cell this event is still being fired and thus we're still running the code to get the current selection (which is now on the code cell) and replacing it with the saved element nodes from the text cell (which aren't even valid anymore since we've moved off of edit mode for the text cell)

(this only happens in WYSIWYG mode because of the check on line 512 which only runs this code if there's a saved richTextCursorPosition)

The fix is simple enough...we only want to do this if the current cell is the active one. This seems to fix the issue but we should be looking at all the changes here closely (especially those in the callbacks) and ensuring we aren't going to have any other similar issues.

@coveralls
Copy link

coveralls commented Nov 4, 2021

Pull Request Test Coverage Report for Build 1419370960

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.004%) to 41.479%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
extensions/notebook/src/book/bookTrustManager.ts 2 96.43%
Totals Coverage Status
Change from base Build 1419365271: -0.004%
Covered Lines: 26892
Relevant Lines: 58803

💛 - Coveralls

@chlafreniere chlafreniere merged commit 84ae306 into main Nov 4, 2021
@chlafreniere chlafreniere deleted the chgagnon/nbBug branch November 4, 2021 02:48
chlafreniere pushed a commit that referenced this pull request Nov 4, 2021
…7590)

* Fix not being able to type in code cell after switching from text

* comment
chlafreniere added a commit that referenced this pull request Nov 4, 2021
…7590) (#17592)

* Fix not being able to type in code cell after switching from text

* comment

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
MaddyDev pushed a commit that referenced this pull request Nov 10, 2021
…7590)

* Fix not being able to type in code cell after switching from text

* comment
Charles-Gagnon added a commit that referenced this pull request Nov 29, 2021
…7590)

* Fix not being able to type in code cell after switching from text

* comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't type in code cell after editing Notebook text cell
5 participants