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

HTML Extension keeps breaking my django templates on save #22980

Closed
1 task done
guinunez opened this issue Jan 10, 2025 · 2 comments
Closed
1 task done

HTML Extension keeps breaking my django templates on save #22980

guinunez opened this issue Jan 10, 2025 · 2 comments
Labels
html HTML markup support setting Feedback for preferences, configuration, etc support User support (non-defect troubleshooting, documentation, etc)

Comments

@guinunez
Copy link

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Problem Description
When using ZED with a Django project, saving a template file like the following:

{% extends "base.html" %} 
{% block title %} Certificate List {% endblock %}
{% block content %}
<select name="consignatario__pais" id="consignatario__pais" class="form-control select2" required style="width: 100%">
    <option value="">Select a country</option>
    {% for pais in paises %}
    <option value="{{ pais.id }}" {% if consignatario_pais == pais %} selected {% endif %}>{{ pais.nombre }}</option>
    {% endfor %}
</select>
{% endblock %}

Results in the following unwanted transformation after saving:

{% extends "base.html" %}
{% block title %} Certificate List {% endblock %}
{% block content %}
<select
    name="consignatario__pais"
    id="consignatario__pais"
    class="form-control select2"
    required
    style="width: 100%"
>
    <option value="">Select a country</option>
    {% for pais in paises %}
    <option
        value="{{ pais.id }}"
        {%
        if
        consignatario_pais=""
        ="pais"
        %}
        selected
        {%
        endif
        %}
    >
        {{ pais.nombre }}
    </option>
    {% endfor %}
</select>
{% endblock %}

Impact of the Issue
The {% if consignatario_pais == pais %} statement is rewritten incorrectly, introducing errors and breaking the template logic.
Additionally, unnecessary line breaks are added, which breaks the django template system, and of course also impact readability and code maintainability.

Additional Details
Uninstalling the responsible extension (HTML) solves the problem only temporarily, as it is automatically reinstalled when restarting ZED. Should this behavior be reported as a separate bug, or is it part of the same issue?

Steps to Reproduce

  1. Open a Django project in ZED.
  2. Edit a template file like the provided example.
  3. Save the changes.
  4. Observe how the code is automatically transformed.
  5. Undo the changes
  6. Uninstall HTML extension
  7. Save again (now there are no modifications)
  8. Close the app, restart the computer (I'm not 100% sure this part happens every time you restart the computer)
  9. The HTML extension is installed again

Zed Version and System Specs

Zed: v0.168.2 (Zed)
OS: macOS 14.6.1
Memory: 8 GiB
Architecture: aarch64

If applicable, add screenshots or screencasts of the incorrect state / behavior

No response

If applicable, attach your Zed.log file to this issue.

Zed.log

@guinunez guinunez added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Jan 10, 2025
@maxdeviant
Copy link
Member

It sounds like you want to disable Prettier's formatting for HTML:

{
  "languages": {
    "HTML": {
      "prettier": { "allowed": false }
    }
  }
}

@JosephTLyons JosephTLyons added html HTML markup support setting Feedback for preferences, configuration, etc support User support (non-defect troubleshooting, documentation, etc) and removed bug [core label] triage Maintainer needs to classify the issue admin read Pending admin review labels Jan 24, 2025
@JosephTLyons
Copy link
Collaborator

Going to close this out, as the setting above should put you into the proper state to avoid formatting on save in HTML files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
html HTML markup support setting Feedback for preferences, configuration, etc support User support (non-defect troubleshooting, documentation, etc)
Projects
None yet
Development

No branches or pull requests

3 participants