question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$psEditor.Workspace.OpenFile puts file name into all lower case.

See original GitHub issue

System Details Output


### VSCode version: 1.49.0 e790b931385d72cf5669fcefc51cdf65990efa5d x64

### VSCode extensions:      
andyyaldoo.vscode-json@1.5.0
jock.svg@1.3.9
ms-azure-devops.azure-pipelines@1.174.2
ms-azuretools.vscode-azurefunctions@0.24.0
ms-dotnettools.csharp@1.23.2
ms-mssql.mssql@1.9.0
ms-python.python@2020.8.108011
ms-vscode-remote.remote-containers@0.140.1
ms-vscode-remote.remote-ssh@0.51.0
ms-vscode-remote.remote-ssh-edit@0.51.0
ms-vscode-remote.remote-wsl@0.44.5
ms-vscode-remote.vscode-remote-extensionpack@0.20.0
ms-vscode.azure-account@0.9.3
ms-vscode.powershell@2020.6.0
ms-vscode.powershell-preview@2020.7.0


### PSES version: 2.3.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

This also appears with vs-code insiders and the 2020.9.0 extension …

The issue is that the $psEditor.Workspace.OpenFile - which is called from various places - like PsEdit, changes the file name to lower case. This is usually just a cosmetic problem, but I have found a case were pester ran a script using its lower-cased name and the script failed because it tried to do a case sensitive replace on part of its own name.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
SeeminglySciencecommented, Sep 17, 2020

@rjmholt I think we store ScriptFile’s as all lower case in an OrderedDictionary on Mac/Windows. I’ve ran into it too, easiest way to repro is:

# In PSIC 
New-Item Something.ps1 | Out-Null
psedit ./Something.ps1

And then look at the tab title.

I think it only happens when you haven’t already opened the file at least once (so it’s not in the workspace cache). I’m guessing the path is always lowercase in the request and if VSCode hasn’t already cached some state for that file it’ll take our word for it.

1reaction
jhoneillcommented, Sep 18, 2020

Still, if I can get the example where it’s caused a Pester issue in full detail, we’ll be able to fix this in a much more reliable way than if I just guess where the issue is and claim it’s solved.

It’s working with the module from https://github.com/MethodsAndPractices/vsteam and the author has a) A PS1 file for each command for each command function (e.g. Add-VSTeam.ps1) b) A .Tests.PS1 file for each (e.g. Add-VSTeam.Tests.ps1) as the unit test for that command. c) Lines in every unit-test to dot-source all the files needed for that command.

Describe "VSTeam" {
  BeforeAll {  
    $sut = (Split-Path -Leaf $PSCommandPath).Replace(".Tests.", ".")
    . "$PSScriptRoot/../../Source/Public/$sut"

So I

  1. Open Add-VSTeam.Tests.ps1 from the PowerShell Window. It opens as add-vsteam.tests.ps1 2.) I click Debug tests in the VSCode editor.

Pester then runs add-vsteam.tests.ps1 and $PSCommandPath).Replace(".Tests.", ".") does not replace tests, because this replace() is case sensitive. The script tires to DOT source a file with .tests and everything fails.

I know I could fix this by using -replace (or making other changes) but this bit of design isn’t under my control. I can work round it by not opening from the command line … and everywhere else - on windows at least - it is just a cosmetic thing. I don’t know what happens if the underlying OS has a case sensitive file system.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing the Case of a Filename - Perforce
How to change Perforce Helix lowercase file to a mixed case file. ... and you want to change the file name to use...
Read more >
text editor - Vim save file in lower case - Stack Overflow
Since I cannot make a comment, I will make an answer instead. This same problem has been solved here: Vim overwrites filename when...
Read more >
Vscode doesn't show change in opened file when ... - GitHub
I open the entire project on another texteditor and when I search the same file, it shows me just one match, the filename...
Read more >
Is there a way to batch rename files to lowercase? - Super User
Go to the directory and run the following command: for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f"). Here is the...
Read more >
Filename changes from upper case to lower case - MSDN
After the migration is completed, as I check the TFS files, I see that the file name cases are changed from upper to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found