nikitakit / hydrogen-python

Python-specific plugin for hydrogen. Make Python coding in the Atom editor even more interactive!
https://atom.io/packages/hydrogen-python
MIT License
54 stars 20 forks source link

Similar bug sending to ipython #3

Open kylebarron opened 6 years ago

kylebarron commented 6 years ago

image

kylebarron commented 6 years ago

Some unit tests would probably help with this, but I don't know how to set that up.

nikitakit commented 6 years ago

Huh, this is actually quite a tricky case.

Looks like I may have to re-evaluate my approach, and maybe even remove the indentation-fixing functionality from hydrogen-python until I can write some entirely new code for this.

I don't want to get too much into the details here, but you can see my second-to-last comment on https://github.com/nteract/hydrogen/issues/862. This bug relates to a fundamental limitation of hydrogen. I thought I could use some simple heuristics to work around this, but looks like that approach is fundamentally flawed.

kylebarron commented 6 years ago

Just checking... I assume it's impossible to deal with common leading whitespace in Python specifically by using Python's dedent function? Because Hydrogen has already stripped the text before passing it to Python, right?

nikitakit commented 6 years ago

That's right.

It looks like the best way to solve this issue is to retrieve the original text (e.g. using Atom's APIs) and recover the unstripped version of the text. This has been on my TODO list for a while now, but I haven't gotten around to implementing it.