Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: full path of root directory displayed without trailing backslash #534

Closed
thorstenkampe opened this issue Mar 15, 2021 · 11 comments
Labels
🤩 enhancement Improvement of a feature

Comments

@thorstenkampe
Copy link

Environment

  • Oh my Posh version: 3.113.0
  • Operating System: Windows
  • Shell: PowerShell
  • Terminal: ConEmu

Steps to Reproduce

{
    "blocks": [
        {
            "type": "prompt",
            "alignment": "left",
            "segments": [
                {
                    "type": "path",
                    "style": "powerline",
                    "properties": {
                        "style": "full"
                    }
                }
            ]
        }
    ]
}

Expected behavior: [What you expected to happen]

 R:\

Actual behavior: [What actually happened]

 R:
@tradiff
Copy link
Contributor

tradiff commented Mar 15, 2021

How about adding this to your properties:

"postfix": "\\"

@JanDeDobbeleer
Copy link
Owner

That's actually by design. There's even a test for that.

@thorstenkampe
Copy link
Author

thorstenkampe commented Mar 16, 2021

Configuring a postfix as suggested would result in a backslash being added to all paths (C:\Users\ instead of C:\Users). The only path missing the trailing backslash is the drive root (C:\, R:\).

@JanDeDobbeleer
Copy link
Owner

@thorstenkampe correct. As stated, this by design. The \ char is a path separator and technically isn't part of the path. If you consider that for C:\, the same goes for any location as @travistx said.

@thorstenkampe
Copy link
Author

@JanDeDobbeleer if it's by design than the design is not correct. The \ is a path separator as well as the path referring to the drive root. The same goes for / on Linux: it's a path separator as well as the root of the directory tree. C: is not a path; it's a qualifier in PowerShell terms.

@JanDeDobbeleer
Copy link
Owner

@thorstenkampe I agree unix is the exception as I can actually type cd \, but on Windows I can also simply type cd Y: and it navigates to where I want it to go. The only difference is that when inside C:\whatever, you can't use cd C: to go to the root, you need to type cd C:\ which is inconsistent behaviour rather than logical. Which is probably due to the legacy "no breaking changes" policy. I'll adjust it to C:\, but not from a regression/logic point of view, simply because Windows is silly in how it handles its paths and it seems to confuse people.

@thorstenkampe
Copy link
Author

@JanDeDobbeleer there seems to be some confusion regarding Windows paths and drive qualifiers. Windows keeps track of your current directory on a specific drive (say C:). The way to switch to another drive is simply drive: (not cd drive:). If you want to cd into a specific directory on another drive you need to specify cd /d.

Using C: or cd C: will switch to whatever your current directory is on C:. You will end up in C:\ or C:\Users or somewhere else because it's not a real change directory. C: is just a drive qualifier and not a path.

@JanDeDobbeleer
Copy link
Owner

@thorstenkampe 100% clear, I'll adjust.

@JanDeDobbeleer JanDeDobbeleer added the 🤩 enhancement Improvement of a feature label Mar 16, 2021
@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Mar 17, 2021

@thorstenkampe what do you expect in this case:

expected: "C: > f > f > location"
actual : "C:\ > f > f > location"

EDIT: going for only adding the \ when we're in the drive root.

JanDeDobbeleer added a commit that referenced this issue Mar 17, 2021
JanDeDobbeleer added a commit that referenced this issue Mar 17, 2021
@thorstenkampe
Copy link
Author

@JanDeDobbeleer if I understand you correctly, C:\ is the correct specification of the C-drive root (equivalent to / on Linux). Adding \ seems only necessary at the root (where it's missing).

@JanDeDobbeleer
Copy link
Owner

@thorstenkampe that's indeed what it should now do for v3.115.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤩 enhancement Improvement of a feature
Projects
None yet
Development

No branches or pull requests

3 participants