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

Path Segement not working with PSDrive Path #515

Closed
Ergamon opened this issue Mar 11, 2021 · 9 comments
Closed

Path Segement not working with PSDrive Path #515

Ergamon opened this issue Mar 11, 2021 · 9 comments
Labels
🐛 bug Something isn't working

Comments

@Ergamon
Copy link

Ergamon commented Mar 11, 2021

Prerequisites

  • [x ] I have read and understand the CONTRIBUTING guide
  • [x ] I looked for duplicate issues before submitting this one

Description

When the current directory is a virtual path, the root is not shown in the path segment

Environment

  • Oh my Posh version: 3.109.0
  • Theme: Paradox (cutomized)
  • Operating System: Windows 10
  • Shell: PowerShell 7.1.2
  • Terminal: Does not matter (tested in Cmder, WT and pure Console host)

Steps to Reproduce

Run
Set-Location HKCU:\

Expected behavior: [What you expected to happen]
The prompt displays a path "HKCU:"

Actual behavior: [What actually happened]
The prompt dispays a path with just the folder_separator_icon

@JanDeDobbeleer JanDeDobbeleer added the 🐛 bug Something isn't working label Mar 11, 2021
@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Mar 11, 2021

@Ergamon confirmed as a bug. When adding the following it works:

{
  "type": "path",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#100e23",
  "background": "#91ddff",
  "properties": {
    "folder_icon": "\uF115",
    "folder_separator_icon": " \uE0B1 ",
    "style": "full",
    "mapped_locations": [["HKCU:", "REG"]]
  }
}

The unit tests work, but E2E with a config file it fails. Will fix.

@Ergamon
Copy link
Author

Ergamon commented Mar 11, 2021

Thx for your quick reply, the temporary fix with the mapped_locations works like a charm

@JanDeDobbeleer
Copy link
Owner

@Ergamon I believe something is off in parsing the themes for that property. When using the regular json support everything works as expected, but using jsonc something strange happens. I'll have to have a closer look but we'll fix it.

@lnu
Copy link
Contributor

lnu commented Mar 12, 2021

If you check the default mapped_locations, it does what it's supposed to, isn't it?

mappedLocations := map[string]string{
		"HKCU:":          pt.props.getString(WindowsRegistryIcon, "\uE0B1"),
		"HKLM:":          pt.props.getString(WindowsRegistryIcon, "\uE0B1"),
		pt.env.homeDir(): pt.props.getString(HomeIcon, "~"),
	}

It replaces HKCU: by \uE0B1

@JanDeDobbeleer
Copy link
Owner

@lnu it should yes, but I confirmed this isn't working when a theme is loaded.

@JanDeDobbeleer
Copy link
Owner

I can reproduce this when running the theme but never in a test scenario (even when loading the config EXACTLY like we do, so fully E2E). I get the feeling I'm missing something obvious (other than time).

@lnu
Copy link
Contributor

lnu commented Mar 12, 2021

The test is wrong. 3 locations are mapped by default like I said in my previous comment. But in the test, the WindowsRegistryIcon property is initialized like this(look at the RegistryIcon property):

cases := []struct {
		Expected      string
		HomePath      string
		Pswd          string
		Pwd           string
		PathSeperator string
		HomeIcon      string
		RegistryIcon  string
	}{
		{Expected: "~", HomeIcon: "~", HomePath: "/home/bill/", Pwd: "/home/bill/", PathSeperator: "/"},
		{Expected: "usr", HomePath: "/home/bill/", Pwd: "/usr/error/what", PathSeperator: "/"},
		{Expected: "C:", HomePath: "C:\\Users\\Bill", Pwd: "C:\\Program Files\\Go", PathSeperator: "\\"},
		{Expected: "REG", RegistryIcon: "REG", HomePath: "C:\\Users\\Bill", Pwd: "HKCU:\\Program Files\\Go", PathSeperator: "\\"},
		{Expected: "~", HomeIcon: "~", HomePath: "C:\\Users\\Bill", Pwd: "Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Bill", PathSeperator: "\\"},
		{Expected: "C:", HomePath: "C:\\Users\\Jack", Pwd: "Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Bill", PathSeperator: "\\"},
		{Expected: "", HomePath: "C:\\Users\\Jack", Pwd: "", PathSeperator: "\\"},
		{Expected: "DRIVE:", HomePath: "/home/bill/", Pwd: "/usr/error/what", Pswd: "DRIVE:", PathSeperator: "/"},
	}

and it overrides the default value with REG.
With the following change it will work the same way as the with the profile:
image

So, overriding the mapped_locations with REG like you said before is completely in line with the code. Without that, it will take the default icon which looks like a separator.

@JanDeDobbeleer
Copy link
Owner

Oh my god. I didn't check that default icon. I feel so stupid right now. Better call it a weekend.

JanDeDobbeleer added a commit that referenced this issue Mar 13, 2021
JanDeDobbeleer added a commit that referenced this issue Mar 13, 2021
Copy link

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues.
If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants