PowerShell / PowerShell/PowerShellEditorServices

$psEditor does not handle 32/64 bit file redirection

Offen
#253 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Area-Extension Terminal Issue-Bug
Vorherrschende Sprache
C#
Sterne
767
Forks
266
Ø Merge
3 T. 16 Std.
Gemergte PRs (30 T.)
1

Beschreibung

PSES is properly running in a 64bit context, but when it passes a path to be opened in VSCode it is being redirected to the 32bit path.

Example:

Register-EditorCommand `
    -Name 'PowerShellEditorServices.OpenAllUserEditorProfile' `
    -DisplayName 'Open All User Editor Profile' `
    -SuppressOutput `
    -ScriptBlock {
        param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)

        $ProfilePath = Join-Path -Path $PShome -ChildPath 'Microsoft.VSCode_profile.ps1'
        If (!(Test-Path -Path $ProfilePath)) { New-Item -Path $ProfilePath -ItemType File }

        $psEditor.Workspace.OpenFile($ProfilePath)
    }

The Editor Command properly creates

"C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.VSCode_profile.ps1"

Then when the same path is passed to $psEditor.Workspace.OpenFile and it is passing it to VSCode to open, Code is not handling the 32/64 redirect. This has terrible consequences for the user.

Code the attempts to open the following path:

"C:\Windows\sysWOW64\WindowsPowerShell\v1.0\Microsoft.VSCode_profile.ps1"

The command silently fails because the item does not exist.

As a temporary workaround you could pass $psEditor this path and it will work:

"C:\Windows\sysnative\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1"

This is not really a good solution and really should be addressed by VSCode. If they never plan on making a 64 bit client, they need to be handling 32/64 redirect. However, since I really don't think that will happen(or if it does, its likely not anytime soon), maybe we can get PSES handling this by passing the sysnative path if PSES is running in a 64 bit context.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den $psEditor.Workspace.OpenFile-Einstiegspunkt und die Art nachzuverfolgen, wie er Windows-Pfade an VSCode übergibt. Reproduziere die 32/64-Bit-Umleitung anhand des bereitgestellten profile-path-Beispiels und vergleiche sie anschließend mit dem sysnative-Workaround. Erledigt ist die Aufgabe, wenn ein gültiger 64-Bit-Pfad geöffnet wird, ohne stillschweigend auf den nicht vorhandenen sysWOW64-Pfad zu zielen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp, powershell, vscode
Bereich
devtools, operating-systems
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.