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

Indentation of multi-line comments is incorrect when indented with tab #98

Open
2 of 4 tasks
montemartin opened this issue Aug 26, 2024 · 0 comments
Open
2 of 4 tasks

Comments

@montemartin
Copy link

montemartin commented Aug 26, 2024

Describe the bug
I generally use tabs for indentation. Prettier seems to incorrectly handle tabs in indentation of multi-line Antlers comments. Hopefully you can make out the whitespace indicators in these photos. The outcome is consistent no matter what the inpu these is the same on repeated formattings, and regardless of how the comment is indented before formatting, even when before formatting uses all spaces.

Before Formatting After Formatting w/ Tabs After Formatting w/ Space
Before 1 After 1 tab After 1 space
Before 2 After 2 tab After 2 space
Before 3 After 3 tab After 3 space

Impacted Products
Which Antlers Toolbox products does this bug apply to?

  • Antlers Toolbox for VS Code
  • Formatter CLI
  • Antlers Prettier Plugin
  • Antlers Syntax Highlighting (external systems - not VS Code)

Versions and Other Plugins/Extensions

  • stillat-llc.vscode-antlers: 2.6.21
  • esbenp.prettier-vscode: 11.0.0

To Reproduce

const config = {
	plugins: ['prettier-plugin-antlers', 'prettier-plugin-tailwindcss'],
	overrides: [
		{
			"files": '*.antlers.html',
			"vscodeLanguageIds": ["antlers"],
			"options": {
				parser: 'antlers',
			},
		},
	],
	editorconfig: true,
	htmlWhitespaceSensitivity: 'strict',
	singleAttributePerLine: true,
	printWidth: 120,
	proseWrap: 'never',
	bracketSameLine: true,
	trailingComma: 'all',
};
export default config;
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml,json,jsonc,md}]
indent_size = 2
indent_style = space

Expected behavior
I expect indentation to be handled the same as HTML comments.

  • comment brackets should move to the same level of indentation as the surrounding code
  • lines within the comment should indent and align relative to the comment depth
  • line breaks should be preserved (test case 3)
  • space characters should be replaced with tab characters

In the 1st and 3rd test it seems indentation via space is also indented incorrectly. I would expect tab characters to be replaced with the correct amount of spaces, not a single space.

If submitting a formatting bug, please include the template contents below as well as an attachment

<!-- Test Case 1 -->
{{#
    @name Button
	@param anchor
    @param href Creates a link rather than a button
	@param alt
    @param slot:params
#}}

<!-- Test Case 2 -->
{{#
	{{ user:profile field="username" :value="username" }}
	{{ if no_results }}
		{{ 404 }}
	{{ /if }}
#}}

<!-- Test Case 3 -->
<div class="test">
	<div class="">
		{{# @todo Add career/skill tabs here #}}
			{{# 
				2024.08.20 - Amet, sunt aliquip sit nisi duis pariatur culpa.
				
					- Careers: Veniam elit aliquip est occaecat sed anim, esse.
					- Skills: Duis qui aute laboris ad.
					Amet esse nisi pariatur laboris.

					Elit voluptate magna do cillum pariatur lorem. --!>
				Labore sit minim reprehenderit duis labore ea, voluptate. -->
			#}}
	</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@montemartin and others