intellij-snakeyaml icon indicating copy to clipboard operation
intellij-snakeyaml copied to clipboard

yaml folding blocks (with chomping and/or indentation indicators) incorrectly identified as errors

Open cognifloyd opened this issue 7 years ago • 0 comments

It seems that SnakeYAML is not identifying folding blocks correctly. The highlighter is highlighting random parts of the folded block when it should all be just text. And PyCharm is complaining about syntax errors when none are present.

This issue is very similar issue to #13. I installed the dev version of the plugin linked in that issue to see if it fixed it, and it does not seem to. All of the screenshots below are with that dev version in d16efef of the plugin installed.

My example, below, is in an ansible playbook (The screenshots show the Ansible/YAML plugin, but I get the same results whether I set *.yml/*.yaml to SnakeYAML directly or use the Ansible/YAML plugin which uses SnakeYAML).

This is a short snippet using a folded block with indentation and chomping indicators (the: >10-)

---
- hosts: all
  tasks:
    - name: "foo bar"
      lineinfile:
        path: /some/path/file
        line: >10-
            '{{ some_var }}': (
          {{ some_other_var}}
          {% if extras_var %}{% for e in extras_var %}, '{{ e }}'{% endfor %}{% endif %}
          ),

Screenshots

Here are a few variations with screenshots:

>10-

note the extra two spaces before first line which yaml would include in the string selection_015

>-

extra spaces removed selection_016

>

extra spaces removed selection_017

>10

includes extra two spaces selection_018

Errors

  • "Expected some indent after > or |" on the red underline on the 10 or the - of line 7.
  • "Expected key-val pair or array item" on all of the rest of the red lines.

cognifloyd avatar Jun 07 '17 21:06 cognifloyd