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

Aperta
#152 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
powershell
Ambito
devtools, tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 + '"'}) + '?>'
Lingua principale
PowerShell
Stelle
151
Fork
55
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PowerShell/EditorSyntax

Tutte le issue di PowerShell/EditorSyntax

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.