-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Create newCellCreated signal + make block comment keyboard shortcut a setting #9142
Conversation
For this use case, I would suggest having one single shortcut that using the |
Good point thanks :) just did that |
(notebookTracker.currentWidget !== null && | ||
notebookTracker.currentWidget === app.shell.currentWidget) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be removed? They are in the initial commit that I rebased on top of and I don't fully understand this part. I think that this will mean that some of the fileeditor specific commands below will be erroneously enabled by a notebook being present. (To be clear though I'm not sure)
Yeah, looking through this, we're just working around bad design that was already in the codebase, I think. There's no reason the codemirror factory should be aware of how it's being used in notebook and editors. I guess ideally the editor factory has an initialization step that happens before the editor is handed off to a consumer, and then there is some signal for when that initialization needs to be updated that the consumer should react to. So, for example, when a notebook creates a new code editor, it should be initialized appropriately already, and then the notebook should listen for changes in that editor configuration. |
I looked at this more last night and this morning. Here are my notes about what I think the codemirror-extension should ideally do:
What do you think? Is that too big of a change at this point? It means that the codemirror extension doesn't have to depend on the file editor nor the notebook, and means that settings automatically propagate to all codemirrors (for example, they would also propagate to Code Consoles, which isn't happening now with this PR). Another thought is that we continue with the hacks that you have in place in the VIM extension, without this PR, and we explore this design further for a 3.1 or 4.0. |
Design question: do you do a lot of customization of the codemirrors in the notebook in your vim extension, or (as far as the codemirror is concerned) do you basically just set the keymap? |
That sounds more sensible than the current situation and definitely a good end goal. Unfortunately it is also almost certainly too big a lift for me to do alone, especially given the 3.0 timeline.
That would be fine, the vim extension works satisfactorily as it stands. I was hoping to use the
Pretty much just the keymap. The vim extension also plays around with the A few people have also asked for relative line numbers (mostly on jlab-git for some reason???) #15436 which I'd like to add as well. That would also require setting up an event listener on the editor codemirror/codemirror5#4116 function showRelativeLines(cm) {
const lineNum = cm.getCursor().line + 1;
if (cm.state.curLineNum === lineNum) {
return;
}
cm.state.curLineNum = lineNum;
cm.setOption('lineNumberFormatter', l =>
l === lineNum ? lineNum : Math.abs(lineNum - l));
}
editor.on('cursorActivity', showRelativeLines) |
Yes, I was trying to think of a way to have the block comment shortcut setting at least. You hit the nail on the head with the complication I was weighing - the change the setting if we moved to jlab shortcuts instead of just a normal setting. However, since at least the block comment would be an additive change, we could just target 3.1 with it. |
Moved to 3.1, then. I can work with you after 3.0 is released to get this in. |
It seems that the discussion on improving the dependencies was moved to #10352 and @jasongrout has some recent experiments on this topic in jasongrout@8a6a27d Especially this one seems relevant:
|
There hasn't been any activity on this pull request in over a year. As part of an effort to clean up this repository's pull requests, I'm closing this request. If you would still like to merge this code in, please reopen the request and resolve any outstanding merge conflicts. All of the code and comments will remain in place. Thank you for being part of the JupyterLab community! |
References
Extracts the
newCellCreated
and block comment changes from #9068Closes: #4778
Closes: #8882
also see: #7579 (comment)
Code changes
newCellCreated
signalextraKeys
to allow the keyboard shortcut forblockComment
to become a settingindent
anddeindent
as settingsIs it possible to move that setting into the shortcuts extension? I couldn't figure out how to do that so it is under the
Codemirror
section of the settings.User-facing changes
You can now set whatever keys you want to be block comment.
For example, add this to the
CodeMirror
settings:Backwards-incompatible changes
I guess that any extension that uses the jlab codemirror factory to create an editor separate from the notebook or fileeditor will now be responsible for assigning those shortcuts.