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

Closing angle bracket autofilled after adding opening angle bracket inside liquid tag #564

Open
david-w-shopify opened this issue Nov 6, 2024 · 3 comments
Labels
Bug Something isn't working

Comments

@david-w-shopify
Copy link

david-w-shopify commented Nov 6, 2024

Describe the bug
This bug occurs in the VSCode extension.

Inside a Liquid tag, e.g. {% if %} - typing an opening angle bracket < results in a closing angle bracket > being added as well

Source

{% if 2 < %}

Expected behaviour
After typing the <, nothing else should be injected

Actual behaviour
I get the following.

{% if 2 <> %}

Debugging information

  • OS: Mac
  • OS Version: Sequoia 15.0.1

Additional Context

The same behaviour happens inside a `liquid tag too.

{% liquid
  if 2 <

  endif
%}

becomes

{% liquid
  if 2 <>

  endif
%}
@charlespwd
Copy link
Contributor

Ah yuk. The language-configuration stuff really should be contextual...

https://github.com/Shopify/theme-tools/blob/main/packages/vscode-extension/scripts/language-configuration.ts

We probably can fix this with a OnTypeFormatter

@charlespwd charlespwd added the Bug Something isn't working label Nov 7, 2024
@Smintfy
Copy link
Contributor

Smintfy commented Nov 18, 2024

@charlespwd @david-w-shopify I tried a workaround by creating an OnTypeFormatting provider. Then we use the ast to get the current node and check whether we're inside a LiquidTag or not which handle both cases where the Liquid Tag is closed and unclosed. Then we delete the > after typing out < using TextEdit. Haven't dig much deeper but I'm sure this isn't the best solution 😅

angle_bracket_in_liquid_tag.mp4

@charlespwd
Copy link
Contributor

I mean that's definitely an approach 👀 curious what the implementation looks like.

We could also maybe do the opposite? Remove < & > from the language config and add the > with an on type formatter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants