prettier / prettier/plugin-php
Prettier duplicates a comment and inserts it somewhere else
Personne n'a encore pris cette issue.
- Langage dominant
- PHP
- Étoiles
- 1.9k
- Forks
- 139
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
@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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire le problème à partir des liens Playground fournis et comparez la sortie du formateur avec l’entrée, en particulier autour des commentaires PHP proches de else et endif. Suivez le chemin de gestion des commentaires de plugin-php ; le travail est terminé lorsque les commentaires ne sont ni dupliqués ni déplacés, que le bloc PHP environnant soit présent ou supprimé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- php
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 55/100