keywords scoped in places where not actually keywords, IF inside simple interpolation `()` for instance

Ouverte
#152 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
42/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
powershell
Domaine
devtools, tooling

Piste de recherche

Start by reproducing the reported scoping with the PowerShell samples in the issue and compare the result with PSReadLine, where the construct is treated as a command. Inspect the syntax grammar's root patterns and repositories, then verify that if and similarly limited keywords such as in are scoped only where valid, without regressing valid interpolation highlighting.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Environment
  • Editor and Version: VS Code: 1.31 Insiders / 1.30.1
  • Your primary theme: Monokai Dimmed (modified)
Issue Description

In the following image and code, the if is being scoped as 'keyword.control', as if it was valid to utilize an IF statement at this point. However it is not valid, and the code instead causes an error stating that The term 'if' is not recognized as the name … No syntax error is reported by EditorServices either. PSReadLine however does indicate that the if would be treated as a command instead of a keyword.

Screenshots

VS Code:
image
PSReadLine
image
(keywords would be green)

Expected Behavior

I would like to expect that this case would not receive 'keyword.control' scoping, so that I am not led to believe the given command might actually be correct. A quick attempt to correct this indicates that this will require some reorganization, because too many items are in the root patterns and not in the repository.

This also shows that there is more to argument mode vs. expression mode than I had originally thought. Control statements cannot always be used everywhere a command can be used. This also affects other limited scope keywords, such as in, which is scoped as 'keyword.control' in more places than it should be.

Code Samples
    '<?xml version="1.0"' + (if ($encoding) {' encoding="' + $encoding + '"'}) + '?>'

The correct code:

    '<?xml version="1.0"' + $(if ($encoding) {' encoding="' + $encoding + '"'}) + '?>'
Langage dominant
PowerShell
Étoiles
151
Forks
55
Métriques de merge des PR
Aucune PR mergée en 30 j

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de PowerShell/EditorSyntax

Toutes les issues de PowerShell/EditorSyntax

Issues similaires

Plus d'issues DevTools

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.