keywords scoped in places where not actually keywords, IF inside simple interpolation `()` for instance
還沒有人認領這個 Issue。
評估
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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:

PSReadLine

(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 + '"'}) + '?>'
- 主要語言
- PowerShell
- 星號
- 151
- 分支
- 55
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PowerShell/EditorSyntax 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 55/100
PowerShell/EditorSyntax#224 · 2 則留言 ·
-
難度 3/5 1-2 天 新手友好度 48/100
PowerShell/EditorSyntax#222 · 2 則留言 ·
-
難度 3/5 1-2 天 新手友好度 55/100
PowerShell/EditorSyntax#221 · 2 則留言 ·
-
難度 3/5 1-2 天 新手友好度 45/100
PowerShell/EditorSyntax#220 · 2 則留言 · 1 個 reaction ·
-
Issue-Bug
難度 3/5 1-2 天 新手友好度 48/100
PowerShell/EditorSyntax#219 · 2 則留言 ·
查看 PowerShell/EditorSyntax 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
idean3885/claude-ops-agent#521 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
0xMiden/bridge-portal#132 ·
-
bug
難度 2/5 1-3 小時 新手友好度 84/100
newrelic-experimental/preflight#793 · 1 則留言 ·
-
enhancement
難度 2/5 1-3 小時 新手友好度 70/100
babalae/bettergi-scripts-list#3674 ·
-
難度 2/5 1-3 小時 新手友好度 88/100
caddyserver/caddy#8046 ·