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

Refactoring Notebook.command_mode #5268

Merged
merged 3 commits into from Mar 6, 2014
Merged

Conversation

ellisonbg
Copy link
Member

This splits Notebook.command_mode into two parts, like edit_mode is already. This is needed to avoid having to call Cell.focus_cell manually each time Notebook.command_mode is called.

// Notify the keyboard manager if this is a change of mode for the
// notebook as a whole.
Notebook.prototype.handle_command_mode = function (cell) {
if (cell === null) { return; } // TODO: do I really need this?
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need this. It only existed for command_mode the callable method, and doesn't need to exist in the cell event handler.

@ellisonbg
Copy link
Member Author

@minrk and @takluyver can you test this branch to see if you find any problems with the modal/keyboard stuff?

@@ -457,6 +457,11 @@ var IPython = (function (IPython) {
if (this.is_valid_cell_index(index)) {
var sindex = this.get_selected_index();
if (sindex !== null && index !== sindex) {
// If we are about to select a different cell, make sure we are
// first in command mode.
if (this.mode !== 'command') {
Copy link
Member

Choose a reason for hiding this comment

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

what is the cost of calling command_mode if already in command_mode? If there is a cost, perhaps this check should be inside the command_mode method so it never happens.

Copy link
Member Author

Choose a reason for hiding this comment

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

Notebook.command_mode is a no-op if already in command mode.

Copy link
Member Author

Choose a reason for hiding this comment

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

But I think it is important that the code path in select also has the test - mainly as a reminder for devs.

@ellisonbg
Copy link
Member Author

@minrk @fperez We (@jdfreder and I) have started to design a way of testing all of the Ui stuff in a consistent and thorough manner. That will be in a separate PR. So let's test this PR interactively for now.

@takluyver
Copy link
Member

Testing reveals something similar to what I've already seen in master: if I refresh the page while in edit mode, it is sometimes left in between modes - keyboard shortcuts work, but uncaptured key presses type, and the text cursor is visible within a grey border.

@takluyver
Copy link
Member

Ahem. Scratch that. I was testing on a notebook where I had tested switching to edit mode in javascript, and that was interfering with it. When I remove that cell, it works.

@ellisonbg
Copy link
Member Author

Hmm, I just tried various combinations of page refreshing and can't reproduce this. Can you give you details on an exact sequence of steps require to reproduce? Can I assume you are Linux+Chrome? (@jdfreder can test this)

@@ -1467,15 +1466,19 @@ var IPython = (function (IPython) {

// If we are at the end always insert a new cell and return
if (cell_index === (this.ncells()-1)) {
this.command_mode();
Copy link
Member

Choose a reason for hiding this comment

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

Just for my peace of mind, this command_mode call doesn't need to happen before the insert_cell_below call, right? In fact, it shouldn't be needed at all, it's just a best practice before calling select, right?

@jdfreder
Copy link
Member

jdfreder commented Mar 5, 2014

I just have one comment inline, other than that the code looks good, makes sense, and seems to work okay.

@ellisonbg
Copy link
Member Author

Yep.

On Wed, Mar 5, 2014 at 11:55 AM, Jonathan Frederic <notifications@github.com

wrote:

I just have one comment inline, other than that the code looks good, makes
sense, and seems to work okay.

Reply to this email directly or view it on GitHubhttps://github.com//pull/5268#issuecomment-36785937
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

ellisonbg added a commit that referenced this pull request Mar 6, 2014
Refactoring Notebook.command_mode
@ellisonbg ellisonbg merged commit c66eef7 into ipython:master Mar 6, 2014
@ellisonbg ellisonbg deleted the cmd-mode branch March 6, 2014 23:00
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Refactoring Notebook.command_mode
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.

None yet

4 participants