Open kylebarron opened 6 years ago
Some unit tests would probably help with this, but I don't know how to set that up.
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.
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?
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.