Hydrogen: SyntaxError when creating multi-line dictionaries

Created on 19 Apr 2017  路  9Comments  路  Source: nteract/hydrogen

Description:

A SyntaxError (unexpected OEF while parsing) is generated when creating a dictionary with a line break after the opening brace:
syntaxerror

The syntax is valid, but Hydrogen will only execute the code properly if all the lines are selected first:
noerror

Steps to Reproduce:

  1. Create multi-line dictionary, with a line break after the opening brace.
  2. With the cursor on the first line, run the command Hydrogen:run.

Versions:

Atom : 1.16.0
Electron: 1.3.13
Chrome : 52.0.2743.82
Node : 6.5.0

language specific wontfix

All 9 comments

We rely on Atom's language-python package to determine code blocks depending on the code folding.

Unfortunately this needs to be fixed in the language-python package because Hydrogen is language agnostic. It would be great if you would open a issue there.

Interesting. I'll open an issue at language-python and MagicPython.

Thank you @lgeiger.

I'm a MagicPython developer. Could you be more specific in whether there's a particular scope that's missing or something like that, please?

I can reproduce this in an otherwise empty file, so I guess it's in the global scope.

@lgeiger could you please give a little more detail on what information Hydrogen is relying on when determining code block boundaries? Is there some specific name that is given to the code block by the language parser that should be there?

@vpetrovykh

To get code block boundaries in a language-portable way, hydrogen relies on Atom's code folding.

So for example here is some code:
screen shot 2017-05-03 at 1 28 49 pm

And here is the same code after running the "Editor: Fold All" command
screen shot 2017-05-03 at 1 29 00 pm

Hydrogen considers the block to range from the start of the current line to the end of the folded section, which misses the closing } delimiter.

Also if as a MagicPython developer you know a more targeted way of getting block information that is commonly supported by Atom grammars, please let us know.

@lgeiger considering that Atom seems to have an known issue with code folding (e.g. https://github.com/atom/first-mate/issues/48 and https://github.com/atom/atom/issues/1183) would it be viable for Hydrogen to try and check for some special syntax scope (e.g. meta.foldable... or maybe rely on some existing meta... scopes) and if present use it to fold the all contents marked by that scope? In case the scope is not present you could fall back on generic code-folding.

@vpetrovykh That's a good idea! We're very happy to accept a PR for this.

There's actually a setting named foldEndPattern that fixes this from the grammar side. Creating PRs for both language-python and MagicPython now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tobiasbj picture tobiasbj  路  4Comments

olegantonyan picture olegantonyan  路  3Comments

gepcel picture gepcel  路  3Comments

DannyDannyDanny picture DannyDannyDanny  路  3Comments

wadethestealth picture wadethestealth  路  3Comments