Closed radix closed 5 years ago
Hydrogen relies on Atom's code-folding and indentation right now to figure out what a block is. This is so that the code for finding blocks works across languages.
This is definitely annoying behavior, but I don't know of a way to address this without writing a parser for each language that Hydrogen supports. Which maybe we should do at some point, but isn't going to happen for a while.
Any ideas about how to solve this without breaking the problem out into all the languages?
sorry, I don't have any ideas. is it a bug in atom?
Nope, it's just hard to take a bunch of text and figure out what a logical block is cross-language. Atom is correct not to fold to decorators, as that would fold the actual function definition under.
any suggestion to get around this problem?
@alvis A way around this is to use comments to define the execution cells in your code and use the command Hydrogen Run Cell and Move Down (Alt+Shift+Enter)
to run them. E.g.:
@n-riesco: Thanks for pointing out. It's smart to use the # In[]:
syntax to separate cells. Never thought it'd be a way.
Please have a look if the most recent commit in this PR nikitakit/hydrogen-python#10 work for you. I've just added exactly this functionality.
This is as solved as possible through the use of cells and with hydrogen-python so I'm going to close.
Say we have this code:
Trying to evaluate the
myfunc
function will be wrong in two different ways: if I have my cursor on the@deco
line, it causes a syntax error because it seems to just be trying to evaluate@deco
by itself, without the function definition after it. If I have my cursor on thedef myfunc
line, or on the blank line immediately aftermyfunc
, it defines the function without the decorator.I can work around this by manually selecting the whole function definition including the decorator line and then hitting cmd-alt-enter.