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

Adding ability to click to go to cell / line in Jupyter Notebooks like currently exists in normal scripts #18202

Closed
milanleonard opened this issue Nov 29, 2021 · 6 comments

Comments

@milanleonard
Copy link

I will explain this through example as it's easiest. When I run a linter, say flake8 over a .py file, it gives me a list of issues with the associated place that the issue is located using filename.py:linenum:charnum, which I can then click on to take my cursor to that exact location

image

When I run the same tool over a notebook, I get a similar information. However, whilst I can ctrl+click the filename.ipynb:cell_num:line_num_within_cell:charnum, I get no such results as shown at the bottom.

image

image

I am requesting that VS Code recognize the cell_num aspect of these tools to allow for quickly going to the right location. Cheers!

@rebornix rebornix transferred this issue from another repository Dec 16, 2021
@ghost ghost assigned IanMatthewHuff and unassigned rebornix Dec 16, 2021
@rchiodo rchiodo transferred this issue from microsoft/vscode-jupyter Dec 16, 2021
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Dec 16, 2021
@rchiodo
Copy link

rchiodo commented Dec 16, 2021

This would be handled by the formatter in python. Might be necessary for the formatter to be updated to output something VS code understands.

@milanleonard
Copy link
Author

This would be handled by the formatter in python. Might be necessary for the formatter to be updated to output something VS code understands.

I'm not sure that VS code understands the structure of .ipynb files at all though right? Like it doesn't have the concept of going into a file at a specific cell. I was suggesting the addition of this knowledge

@rchiodo
Copy link

rchiodo commented Dec 17, 2021

I'm not sure that VS code understands the structure of .ipynb files at all though right?

There's a URI that vscode does understand that would allow jumping to a specific cell. But it's VS code specific.

Something like so:

vscode-notebook://test.ipynb#ch000001

where ch00001 points to the second cell.

I would hazard a guess if the formatter outputted that format, it would work.

@milanleonard
Copy link
Author

I'm not sure that VS code understands the structure of .ipynb files at all though right?

There's a URI that vscode does understand that would allow jumping to a specific cell. But it's VS code specific.

Something like so:

vscode-notebook://test.ipynb#ch000001

where ch00001 points to the second cell.

I would hazard a guess if the formatter outputted that format, it would work.

Oh thanks, that's really helpful. Is there any documentation that shows what the ch###### actually means? Does it then allow for line + cursor position on line?

I think this cell_i:line:cursor or even just cell:line:cursor is a pretty standard format amongst python tools, could be worth adding the ability to recognise this. Thanks for the info

@rchiodo
Copy link

rchiodo commented Dec 17, 2021

Is there any documentation that shows what the ch###### actually means?

Not that I could find. I don't believe the schemes for URIs are documented anywhere. (That may be on purpose so they can change).

They are in the vscode source though:
https://github.com/microsoft/vscode/blob/2d271e5e733d3efdb75b53711adffab4faff282f/src/vs/base/common/network.ts#L61

Looks like I had the wrong scheme. Should have been vscode-notebook-cell

@brettcannon
Copy link
Member

What's more likely to happen is we are going to put all linters and formatters behind LSP, so as long as LSP understands notebook structure that will be how that works. This is being tracked in #17235 and what I'm closing this issue in favour of.

Otherwise that output format is unique to nbqa and we would have to add explicit support for that tool to control how it emitted things so we could somehow come up with a traceback provider just for that tool.

@karthiknadig karthiknadig removed the triage-needed Needs assignment to the proper sub-team label Jan 13, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants