Don't colorize nested tokens when the parent token has the CommandName TokenFlag

Abierto
#3,994 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
csharp, powershell
Área
cli

Línea de trabajo

Start with Parser.cs around line 6352 to confirm how command names with variables or subexpressions are represented. Then trace PSReadLine’s token-highlighting loop and apply the stated invocation-operator and line-continuation rules. Done means nested tokens are skipped and the full command token uses the command color when no invocation operator precedes it.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Issue-Enhancement Needs-Triage :mag:
Prerequisites
  • Write a descriptive title.
Description of the new feature/enhancement

The PowerShell parser adds nested tokens when parsing command names with variables/subexpressions but don't actually evaluate them unless there's an invocation operator before the command.
This seems to be an intentional choice as noted in the parser code here: https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/parser/Parser.cs#L6352
The syntax highlighting in PSReadLine should make this fact clear to users by coloring the whole token as a command when there's no invocation operator.
You can see the current behavior here:
image

Proposed technical implementation details (optional)

When looping over the tokens, set a flag when an invocation operator is encountered and reset it whenever a non line continuation token is encountered. If a command token is encountered and the flag is set, scan the nested tokens, otherwise skip them and color the whole token with the command color.

Lenguaje dominante
C#
Estrellas
4.4k
Forks
341
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PowerShell/PSReadLine

Todos los issues de PowerShell/PSReadLine

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.