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

Cannot change shortcut for code_prettify #979

Open
cipri-tom opened this issue May 7, 2017 · 5 comments
Open

Cannot change shortcut for code_prettify #979

cipri-tom opened this issue May 7, 2017 · 5 comments

Comments

@cipri-tom
Copy link

I am trying to customise the shortcut for extension code_prettify

I can change it for prettifying a cell. But when I try to change it for prettify notebook the one for the cell gets changed instead.

Not sure if I'm clear: I am pressing the button for notebook but the cell shortcut is updated.

Thank you!

@jfbercher
Copy link
Member

jfbercher commented May 8, 2017

Yes. Reproductible with notebook 5.0.

This is super strange: actually changing the shortcut for process_all changes the shortcut for process_cell. Even more strange, this is also true if I change shortcuts in autopep8 or even in nbTranslate. In all cases, the modified shortcut is the one for code_prettify.hotkeys.process_cell. This can also be checked in notebook.json.
@jcb91 It seems that there is an issue in shortcut updates in nbextension_configurator, perhaps only with notebook 5.

@jcb91
Copy link
Member

jcb91 commented May 9, 2017

That does sound very strange. However, I'd be surprised if it's coming from the configurator, as that just sets config values by text-string names as declared in the yaml files, which seem to be correct. I think more likely is that this is a result of the library factory-method for producing the nbextensions, resulting in the same object being used for something across all of them, which it shouldn't be

@jcb91
Copy link
Member

jcb91 commented May 9, 2017

in fact, I'm fairly sure it's a result of the lines code_prettify/kernel_exec_on_cell.js#L44-L50, where we attempt to keep the same object for the default config, so that nbextensions can alter it, resulting in the same hotkeys object being used in the config for each of the three derived nbextensions. I think in light of this issue, shared config is a bad idea, and we should just go with the more common jquery.extend to get a new object...

@jcb91
Copy link
Member

jcb91 commented May 9, 2017

actually, I'll revise my previous statement, and say that although that was a problem, there may be more than one bug at work here 😜

@jcb91
Copy link
Member

jcb91 commented May 9, 2017

Ok, it seems to work ok for me on 5.0.0 with the fix in jfbercher/code_prettify#8.

However, there's also a bug in the configurator which may be related. Essentially, rebuilding the controls to edit keyboard shortcuts doesn't work correctly, so that if you at any point refresh the list of configurable nbextensions, or reset any nbextensions parameters to their default values using the reset button, any subsequent edits to keyboard shortcuts don't get applied. You can see this in the sense that the displayed shortcut in the parameters list doesn't change, but it isn't super obvious. Im not yet sure what the reason for this is, but will have a look...

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

No branches or pull requests

3 participants