-
Notifications
You must be signed in to change notification settings - Fork 12
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
⚡️Open node's script at specific line #160
Conversation
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.
As @mansouralawi has mentioned, this has to do with the way the go to line is implemented, where the search will break if users mention that component name in a comment or such.
There are 2 ways of remedying this - one is to search using the @ decorator tag + class name, but I think the best way of implementing it is using the feature right after the search command, the go to line feature: https://github.com/jupyterlab/jupyterlab/pull/12204/files
This might require additional information embedded inside the component information though, but I think it's fine to add.
Awesome feature, looking forward to having this one implemented!
Thanks @mansouralawi & @MFA-X-AI for the review. I didn't consider class name on the docstring. Then, this search function doesn't bode well in this situation. Luckily, @MFA-X-AI found a go-to-line command(which I didn't know it exist) which I just added in the latest commit. Hope you guys can review it again. Thanks. |
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.
Looks good from my side, opening nodes will properly jumps to that specific line number.
One thing that I wish could've been supported by Jupyterlab is the view control itself so that when jumping to that component class definition it wouldn't be at the bottom but instead the top, but I don't think that's possible from the codemirror text editor plugin itself.
Nonetheless this is definitely a lifesaver feature for a big component libraries, so great work and thanks!
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.
There was an extra edit by @AdrySky, old nodes on the canvas don't have that line number data. Reloading those components will correctly reload the information. Since reloading .xircuits changes a lot of lines, I think we can do the reloading of all examples before the 1.5 update, just in case add more node related changes. Better yet, maybe a refresh all nodes feature. 😄 |
Reloading the node fixed the issue. the new feature behaves as expected now. |
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.
Just checked the newest commit, I'm very impressed how well this works out. Great thinking!
newWidget.context.ready.then(() => {
// Go to end of node's line first before go to its class
app.commands.execute('codemirror:go-to-line', {
line: nodeLineNo[0].end_lineno
}).then(() => {
app.commands.execute('codemirror:go-to-line', {
line: nodeLineNo[0].lineno
})
Here's a gif of how it works now.
Since it's working well, will merge. Will also add the update previous workflows to the todo list.
Description
This PR will enable to open node's script and go to its specific line.
Ways to open script are via context menu and component library.
Pull Request Type
Type of Change
Tests
Open Script
Ctrl+click
ordouble-click
any node on component library(sidebar).Tested on?
Notes
Need to update JupyterLab to at least 3.4.0v.
Notice a few bugs with this latest JupyterLab update. Probably need to check on that or fix the version.