mblode / mblode/vscode-twig-language-2

Formatter adding new lines

Open
#95 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

formatter
Dominant language
JavaScript
Stars
62
Forks
33
PR merge metrics
No merged PRs in 30d

Description

I can't work out why the formatter is adding blank lines when I format my file:

Before

<div class="flexibleblocks-block">
	<section class="table-block">
		<!--mixcontent-->
		<div class="container">
			<div class="row">
				<div class="col-lg-10 offset-lg-1">
					<?php include($_SERVER["DOCUMENT_ROOT"] . '/structure/flexcontent/table.php'); ?>
				</div>
			</div>
		</div>
		<!--mixcontent-->
	</section>
</div>
<!-- flexible block -->

After

<div class="flexibleblocks-block">
	<section
		class="table-block">
		<!--mixcontent-->
		<div class="container">
			<div class="row">
				<div class="col-lg-10 offset-lg-1">
					<?php include($_SERVER["DOCUMENT_ROOT"] . '/structure/flexcontent/table.php'); ?>
				</div>
			</div>
		</div>
		<!--mixcontent-->
	</section>
</div>
<!-- flexible block -->

The section class is moved to a new line and the cursor moved there, but the line isn't too long nor are other tags broken up like this. Is this a bug?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the formatter behavior in VS Code using the supplied Before example and confirm the section class moves to a new line. Start from the formatter entry point, then identify how this tag is wrapped; done means formatting no longer introduces the unwanted line break or cursor movement while preserving the shown structure.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vscode
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.