prettier / prettier/plugin-php
Prettier duplicates a comment and inserts it somewhere else
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- PHP
- Sterne
- 1.9k
- Forks
- 139
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
@prettier/plugin-php v0.25.0
Playground link
Input:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
/* My comment */
?>
<?php
// Comment in else
// Another comment
// Comment number three
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Output:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
/* My comment */
?>
<?php
// Comment in else
// Another comment
// Comment number three
// end true check
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Notice that the //end true check comment is inserted next to the comments near the else statement.
However, a weirder things happen when I delete the entire /* My comment */ PHP block:
@prettier/plugin-php v0.25.0
Playground link
Input:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
// Comment in else
// Another comment
// Comment number three
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Output:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
// Comment in else
// Another comment
// Comment number three
// end true check
// Comment in else
// Another comment
// Comment number three
// end true check
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Multiple comments get duplicated
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Problem anhand der bereitgestellten Playground-Links zu reproduzieren, und vergleiche die Formatter-Ausgabe mit der Eingabe, insbesondere im Hinblick auf die PHP-Kommentare in der Nähe von else und endif. Verfolge den Pfad zur Kommentarverarbeitung von plugin-php; abgeschlossen ist die Aufgabe, wenn Kommentare weder dupliziert noch verschoben werden, unabhängig davon, ob der umgebende PHP-Block vorhanden ist oder entfernt wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100