vscode-liquid icon indicating copy to clipboard operation
vscode-liquid copied to clipboard

assign variables breaks into new lines (question)

Open mau2099 opened this issue 2 years ago • 3 comments

Hi! I was wondering how can I get a better format:

I have this messed piece of code (before format)

Messed pieced of code

{% assign currentInsurableItems = policy.detail.insurableItems | where:
'versionInfo.versionNumber', policy.versionInfo.versionNumber | where:
'itemType', 'vehicle' %} {% if currentInsurableItems %}
<div>
  <table class="esignAutoAppTable" data-testid="coverages-table">
    <tbody>
      {% for currentItem in currentInsurableItems %} {% assign usState =
      policy.detail.usState %} {% assign umLabel = 'UM' %} {% assign biLimit =
      nil %} {% assign pdLimit = nil %} {% assign umpdLimit = nil %} {% assign
      umpdValue = nil %} {% assign collLimit = nil %} {% assign compLimit = nil
      %} {% assign mpLimit = nil %} {% assign raLimit = 'Not Included' %} {%
      assign atLimit = nil %} {% assign uimpdLimit = nil %} {% assign umLimit =
      nil %} {% assign uiumLimit = nil %} {% endfor %}
    </tbody>
  </table>
</div>
{% endif %}

current outcomes (formatted)

{% assign currentInsurableItems = policy.detail.insurableItems | where:
'versionInfo.versionNumber', policy.versionInfo.versionNumber | where:
'itemType', 'vehicle' %}
{% if currentInsurableItems %}
  <div>
    <table class="esignAutoAppTable" data-testid="coverages-table">
      <tbody>
        {% for currentItem in currentInsurableItems %}
          {% assign usState =
      policy.detail.usState %}
          {% assign umLabel = 'UM' %}
          {% assign biLimit =
      nil %}
          {% assign pdLimit = nil %}
          {% assign umpdLimit = nil %}
          {% assign
      umpdValue = nil %}
          {% assign collLimit = nil %}
          {% assign compLimit = nil
      %}
          {% assign mpLimit = nil %}
          {% assign raLimit = 'Not Included' %}
          {%
      assign atLimit = nil %}
          {% assign uimpdLimit = nil %}
          {% assign umLimit =
      nil %}
          {% assign uiumLimit = nil %}
        {% endfor %}
      </tbody>
    </table>
  </div>
{% endif %}

expected outcomes (desired)

(all assign statements in one line)

{% assign currentInsurableItems = policy.detail.insurableItems | where:
'versionInfo.versionNumber', policy.versionInfo.versionNumber | where:
'itemType', 'vehicle' %}
{% if currentInsurableItems %}
  <div>
    <table class="esignAutoAppTable" data-testid="coverages-table">
      <tbody>
        {% for currentItem in currentInsurableItems %}
          {% assign usState = policy.detail.usState %}
          {% assign umLabel = 'UM' %}
          {% assign biLimit =nil %}
          {% assign pdLimit = nil %}
          {% assign umpdLimit = nil %}
          {% assign umpdValue = nil %}
          {% assign collLimit = nil %}
          {% assign compLimit = nil %}
          {% assign mpLimit = nil %}
          {% assign raLimit = 'Not Included' %}
          {% assign atLimit = nil %}
          {% assign uimpdLimit = nil %}
          {% assign umLimit = nil %}
          {% assign uiumLimit = nil %}
        {% endfor %}
      </tbody>
    </table>
  </div>
{% endif %}

how could I get this kind of formatting?

mau2099 avatar Feb 11 '22 00:02 mau2099

Hey @mau2099 this is likely a defect. You can adjust it manually after initial format.

panoply avatar Feb 11 '22 15:02 panoply

Hey @mau2099 this is likely a defect. You can adjust it manually after initial format.

thanks for your answer! do you mean it's a defect in the original prettydiff tool? Or am I doing something wrong in the code? do you have an expected date to release your tool Liquify?

Thank you a lot!

mau2099 avatar Feb 11 '22 17:02 mau2099

do you mean it's a defect in the original prettydiff tool? Or am I doing something wrong in the code?

So likely an issue with PrettyDiff the current version of this extension is using or something internally happening when the code is being formatted, I would need to run tests to see where it actually happening, nothing wrong with your code though.

In Liquify, the formatting logic was completely overhauled and it uses a hard-froked variation of PrettyDiff which addresses all these issues. That project is called Prettify so I will likely upstream the defect in that project.

do you have an expected date to release your tool Liquify?

In the past I have failed to come through on release dates (like, I am really bad at keeping to deadlines with this tool) so I try to avoid giving them because I am the only developer really working on it atm. I am aiming towards a summer release as per liquify.dev. I just need to find the time, I apologize for delays or headaches the current version is giving you.

panoply avatar Feb 11 '22 19:02 panoply

🚢 Shipped v3.0.0

panoply avatar Sep 28 '22 08:09 panoply