Skip to content

Deletes entire files on save #582

Description

@mblode

I've tried using this formatter with my twig code, but it's way too volatile. Some files get completely deleted and all the text inside the document is gone. Some files on save delete a large amount and leaves internally placed javascript code behind and no trace of any other code.

This is an issue in the Twig Language extension on VS Code

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta content="width=device-width, initial-scale=1.0" name="viewport">
        <meta content="ie=edge" http-equiv="X-UA-Compatible">
        <title>Document</title>
    </head>
    <body>
        <script>console.log("Hello")</script>
    </body>
</html>
Then when I beautify as HTML it becomes...

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta content="width=device-width, initial-scale=1.0" name="viewport">
        <meta content="ie=edge" http-equiv="X-UA-Compatible">
        <title>Document</title>
    </head>
    <body>
        <script>console.log("Hello")</script>
    </body>
</html>

But finally, if I run the formatter for a second time, the contents of the beautify become...

console.log("Hello")

This is breaking formatting for many people who have a script tag within their HTML file. How can I fix this issue?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions