Conversation
seidewitz
left a comment
There was a problem hiding this comment.
I noticed that the new extension does not support folding of code between braces. That is, the old mode definition included:
modeProps: {
fold: ['brace'],
}
but I don't see anything similar in the new sysmlparser definition. If there is no way to do this in the new approach, that is a serious degradation of functionality that I know is commonly used by users.
|
Also, the file |
No, this shouldn't work. I always go for jupyter lab. I'm not sure if there is a high demand for classic Notebook. |
I've tried adding code folding as an extension in the frontend plugin but I couldn't get it working unfortunately. I couldn't really find any option either that would indicate some easy turn-on.
|
|
I think we need to use |
If it is not going to work anyway, we should take it out of the build. |
The problem is that the v6 In any case, if we can't find a way to get code folding incorporated fairly quickly, I am going to defer this PR to the next sprint. I don't want to deploy it without code folding. |
|
We can use |
|
I am going to remove this PR from the release. We figure out code folding on the next sprint. |
|
@seidewitz, I made ST6RI-766-1 branch and could successfully make the fold service work. Can I change the source branch to it? |
I was able to get your fold service working. However, while it seems to handle braces in comments and strings correctly, its doesn't properly handle braces in unrestricted names. E.g.: |
|
Opps. |
|
I fixed to skip variableNames as well. Could you please check it? |
* fold.ts: Added. Provide foldService extension via sysmlFoldServiceSelection() * plugin.ts: Register sysmlFoldExtension.
nodes, corresponding to quoted names, as well.
|
@himi @TheKorpos |
|
@himi Thank you for finishing this up! The code looks good and seems to work as intended. I also caught a mistake I made in the packaging that caused some infinite inclusion of the output directory. I managed to get a 50GB tgz as a result... I fixed the issue by re-adding the 'files' field, that I had removed, to the |
|
One last kind of related thing. In Jupyter 2, when you typed an open brace Is it possible to restore the old functionality in which braces were automatically inserted in matched pairs? |
- Also removed support for highlighting in classic Jupyter Notebook (i.e., not Jupyter Lab).
|
It seems to be |
Ah, that does it! I hadn't even noticed that setting. I guess it had been set by default in our old installation. Thanks! |
|
@himi If I create a new notebook and enter something into the first cell, code folding does not seem to be active. If I go on to the second cell, then code folding works in that and subsequent cells. If I save the notebook, close it, and reopen it, then the first cell now has code folding. Can you reproduce this behavior? |
The problem seems to be that JupyterHub does not preserve the setting of the Auto Close Bracket across stopping and starting of a user's virtual server. In the old JupyterHub deployment on I don't know how to change that. |
|
It seems I'm missing something. I will investigate more. |
* fold.ts: Apply foldService to 'plain/text' as well and check the language to make sure it is 'sysml'.
…t-Implementation into ST6RI-766
|
I found the first cell in newly created notebooks is initialized as 'text/plain' and it won't enable foldService. So I enabled foldSerivce to 'text/plain' as well and check if the language is |
|
There is a template for mode.ts. That should be updated as well in case mode.ts requires changes. |
|
@TheKorpos, thanks. I updated |
|
OK, folding works in the first cell now. Thanks! But that does seem harder than it should be... |
This PR includes dependency and code updates for the
org.omg.sysml.jupyter.jupyterlablabextension to support Jupyter 4.x. Older versions are no longer supported.This PR doesn't change how the extension is packaged. Installing it into Jupyter is still possible with
jupyter labextension install(which is deprecated but still works in 4.x).Dependency updates
package.json"@jupyterlab/application": "3.x"->"4.x""typescript": "<4.4.0"->"~5.8.3""@jupyterlab/codemirror": "^0.0.98"->">=4.0""@codemirror/legacy-modes": "^6.3.2"es2018->es2023Code changes
Previously, the syntax highlight was registered by adding a new "mode" to Codemirror. This is no longer an option. Instead, the language has to be registered via
IEditorLanguageRegistryby the front-end plugin. Luckily, the underlying parser is still present and can be registered in "legacy" mode, so most of the configuration can be easily ported. However, a newfoldServicehad to be implemented to support code folding between braces ({ ... }).org.omg.sysml.jupyter.jupyterlab/src/main/plugin.ts– updated the implementation of the front-end pluginsysmllanguagesysml-fold-extensionmode.ts– created aclikeparser to replace the CodeMirror modefold.ts– implementedsysmlFoldServiceSelectionto support code foldingtool-support/syntax-highlighting/jupyter/xtext_grammar_converter.py– removed support for keyword highlighting in classic Jupyter Notebook, Jupyter Lab should always be used insteadjupyter/mode_template.js– updated the template formode.jsused by thextext_grammar_converter