Open alvaropp opened 11 months ago
It looks like you are using run selection in interactive window
?
Try turning off the special normalization that occurs when that command is run: "jupyter.interactiveWindow.textEditor.normalizeSelection": false
Thanks, I'll try this.
There seems to be something else going on, as I'm also getting mismatched line numbers when using the embedded terminal to execute Python scripts.
Your suggestion fixes the above toy example, but I'm still seeing problems in longer scripts!
looks like this happens when a selection starts with one or more blank lines. Are you seeing any other cases of this?
Not that I can think of. As I noted above, I always try to have a couple of blank lines before a new section (# %%
). The example I posted at the beginning of the issue works fine with your suggested change ("jupyter.interactiveWindow.textEditor.normalizeSelection": false
). However, I'm finding mismatched lines with larger scripts (cannot share).
Applies To
What happened?
I always find that the line numbers listed in errors in an interactive Python session don't match those of the code.
For example, see the following code:
which provides the following error with wrong line numbers:
There has been talk about this issue in the past couple of years and I've seen a few issues closed, but this happens to me every time. It's related to the fact that I have a couple of new lines after the cell delimiter
# %%
, but I find this very convenient to provide visual separation!Many thanks 😄
VS Code Version
Version: 1.83.1 (Universal) Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc Date: 2023-10-10T23:46:55.789Z Electron: 25.8.4 ElectronBuildId: 24154031 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 22.6.0
Jupyter Extension Version
v2023.10.1003070148
Jupyter logs
Coding Language and Runtime Version
Python 3.11.6
Language Extension Version (if applicable)
Python v2023.20.0
Anaconda Version (if applicable)
No response
Running Jupyter locally or remotely?
Local