artagnon / vstwig

🈸 vscode extension for PHP Twig
MIT License
4 stars 0 forks source link

Formatting does not work #1

Closed kanlukasz closed 5 months ago

kanlukasz commented 3 years ago

It seems that formatting does not work

Example below (GIF Video):

twig1

Tested on:

Version: 1.56.2
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19042

Additional info:

After re-loading the VSCode, Dev Tools Console returns the following warning:

[twig]: language configuration: expected `comments.blockComment` to be an array of two strings.
languageConfigurationExtensionPoint.ts:152

image

Let me know if you need more information or more tests

artagnon commented 3 years ago

Hi @kanlukasz,

Thank you for creating the issue. Can you give me the following information:

  1. Does formatting work on any other twig document, or does VSTwig not work in general for you?
  2. Can you try VSTwig with the following document?
{% extends 'front/layout.html.twig' %}

{% set title = ( 'Home'|trans) ~ ' — Apollon' %}

{% block body %}

    {% set params = {
        'defaultPost': {
            'users': [
                {
                    'name': 'Ama',
                    'image': asset('front/images/feed-default-ama.png'),
                    'image_retina': asset('front/images/feed-default-ama@2x.png')
                },
                {
                    'name': 'Hermann',
                    'image': asset('front/images/feed-default-hermann.png'),
                    'image_retina': asset('front/images/feed-default-hermann@2x.png')
                }
            ],
            'title': "Welcome Apollonians!"|trans,
            'subtitle': "Founder of Apollon"|trans,
            'date': "October 31, 2020 at 12h"|trans,
            'content': "Find here the people and stories that inspires you"|trans,
            'action': "Discover"|trans
        }
    } %}
    <feed-component :params="{{ params|json_encode }}" />

{% endblock %}
  1. If (2) is successful, can you paste me the document that fails?
  2. If (2) is unsuccessful, can you try adding the following to your settings.json, after making sure to remove any conflicting settings?
  "[twig]": {
    "editor.defaultFormatter": "artagnon.vstwig"
  },

Thanks and warm regards.

kanlukasz commented 3 years ago

Hi @artagnon, Thank you for your response. Below, I describe all the necessary details. ​​​​

  1. Does formatting work on any other twig document, or does VSTwig not work in general for you?

The VSTwig formatter generally doesn't work on file that i tested yesterday. I'll check your sample file in a moment ​​​​

  1. Can you try VSTwig with the following document?

twig2 Something happened (as you can see in the gif example), but now it's the wrong formatting ​​​​

  1. Can you paste me the document that fails?

The file I tested that doesn't work is the original twig file from the Symfony Demo Blog from Github. It is here ---> https://github.com/symfony/demo/blob/main/templates/base.html.twig ​​​​

  1. Can you try adding the following to your settings.json, after making sure to remove any conflicting settings?

I added this. Anyway conflict is impossible as I test your addon on a new and fresh install on VSCode without any addons or custom settings

artagnon commented 2 years ago

Hello @kanlukasz. Sorry for the delay, but I finally got around to looking at the issue this morning. It seems that the issue is Windows-specific, and has to do with hard-coding "\n" in several places. I've attempted to fix the issue now, although I don't have a Windows machine to test. Could you kindly report how vstwig 0.0.7 performs?

Warm regards.

kanlukasz commented 2 years ago

Hello

Unfortunately, it still doesn't work properly. Examples below

Case 1 (tried with CRLF and LF):

twig1

Case 2 (Formatting doesn't work at all when you have a twig comment at the top of the file):

twig2

Case 3 (Even if it works, strange things still happen):

twig3

Case 4 (Strange things still happen - another example):

twig4

Case 5 (The formatter does not respect the indentation change [space | tabs]):

twig5

artagnon commented 6 months ago

Hi @kanlukasz. Sorry for the long delay: I don't actually use Twig anymore, but found some time to fix the bugs nevertheless, as vstwig is a popular extension. Could you kindly verify that the issues are all fixed with 0.0.10?

artagnon commented 5 months ago

Closing due to lack of response. Please re-open if issue persists.