camdencheek / tree-sitter-dockerfile

A tree-sitter grammar for Dockerfile
MIT License
71 stars 20 forks source link

Parser errors on comment immediately after RUN #10

Closed thetic closed 5 months ago

thetic commented 2 years ago

The following causes an error:

RUN \
  # comment
  echo foo

Whereas none of the following do:

RUN echo foo \
  # comment
  echo foo
# comment
RUN \
  echo foo
RUN \
  echo foo \
  # comment
  echo foo
camdencheek commented 2 years ago

Thanks for the report! I just pushed a commit to main that should fix this issue.

thetic commented 2 years ago

I just noticed that this also affects ENV:

ENV \
   # comment
  VAR=value
camdencheek commented 2 years ago

Sure enough. Thanks for the vigilance 😄

I'll reopen this until I get to fixing the issue for all commands.

vcunat commented 2 years ago

I see issue e.g. on:

FROM image
ENV FOO bar baz
ENV BAR foo

with the last ENV not getting highlighted. Similarly to this, "multi-parameter" EXPOSE also does this.

camdencheek commented 5 months ago

Okay, the issue with comment lines not being removed after line continuations should be fixed by https://github.com/camdencheek/tree-sitter-dockerfile/commit/439c3e7b8a9bfdbf1f7d7c2beaae4173dc484cbf. Thanks for the report!