Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError when creating multi-line dictionaries #724

Closed
onewhaleid opened this issue Apr 18, 2017 · 9 comments
Closed

SyntaxError when creating multi-line dictionaries #724

onewhaleid opened this issue Apr 18, 2017 · 9 comments
Labels
language specific Not universal in all languages wontfix

Comments

@onewhaleid
Copy link

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

@lgeiger lgeiger added the language specific Not universal in all languages label Apr 19, 2017
@lgeiger
Copy link
Member

lgeiger commented Apr 21, 2017

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.

@onewhaleid
Copy link
Author

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

Thank you @lgeiger.

@vpetrovykh
Copy link

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?

@onewhaleid
Copy link
Author

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

@vpetrovykh
Copy link

@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?

@nikitakit
Copy link
Contributor

@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.

@vpetrovykh
Copy link

vpetrovykh commented Aug 1, 2017

@lgeiger considering that Atom seems to have an known issue with code folding (e.g. atom/first-mate#48 and atom/atom#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.

@lgeiger
Copy link
Member

lgeiger commented Aug 10, 2017

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

@kylebarron
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language specific Not universal in all languages wontfix
Projects
None yet
Development

No branches or pull requests

5 participants