davidmiller / pony-mode

Django mode for emacs
Other
149 stars 32 forks source link

Template indentation is wrong when there are multiple tags on a line #51

Open gareth-rees opened 12 years ago

gareth-rees commented 12 years ago

Open the following template in pony-tpl-mode:

<img>
{% block foo %}{% endblock %}
<img>

and indent the whole file (C-x h C-M-\). The result is as follows:

<img>
{% block foo %}{% endblock %}
  <img>

with the second <img> incorrectly indented. This is because pony-calculate-indent-backward recognizes that the {% block foo %} starts an indented block but does not recognize that the {% endblock %} closes that block.

The indentation calculation needs to look at all tags on a line, not just the first tag.

davidmiller commented 12 years ago

Thoughts:

I can't recreate this issue when I paste your example into a new template.

I end up with all three lines without an indent - running from the latest Pony Mode master, Emacs 23.

e.g.

<img>
{% block foo %}{% endblock %}
<img>

Which is the "Right Thing" AFAIC

I added a test for this - if you run

$ rake test

... from the root of the repo on a local checkout you should see four passing tests