JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
16.79k stars 2.35k forks source link

Cannot Use Cross Segment Template Properties in Transient Prompt #4143

Closed WestRyanK closed 1 year ago

WestRyanK commented 1 year ago

Code of Conduct

What happened?

The following bug was introduced in 18.2.1 (it worked in 18.2.0 and prior).

Cross segment template properties no longer work from the Transient Prompt. The values for all the properties are empty/null. The included theme is a minimal example that reproduces the error.

If you use this theme, you will notice that the Primary Prompt displays the current folder followed by the current date, followed by the current folder. The second display of the current folder uses a cross segment template property. In this situation, the cross segment template property worked correctly.

The transitory prompt should display the current folder and current time using cross segment template properties as well. However, both the value of the current folder and the value of the current time are null/empty, so the result is an empty transitory prompt.

Here's what the Primary Prompt looks like:

Location: 'C:\Users' Date: '2023-08-07 11:57:16.0712383 -0600 MDT m=+0.038072301' CrossSegmentLocation: 'C:\Users'

Here's what the transitory prompt looks like:

Location: '' Date: ''

Theme

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "version": 2,
  "final_space": true,
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "path",
          "style": "plain",
          "foreground": "p:white",
          "template": "Location: '{{ .Location }}'",
          "properties": {
            "style": "full"
          }
        },
        {
          "type": "time",
          "style": "plain",
          "foreground": "p:white",
          "template": " Date: '{{ .CurrentDate }}' CrossSegmentLocation: '{{ .Segments.Path.Location }}'"
        }
      ]
    }
  ],
  "transient_prompt": {
    "foreground": "p:white",
    "background": "transparent",
    "template": "Location: '{{ .Segments.Path.Location }}' Date: '{{ .Segments.Time.CurrentDate }}' "
  }
}

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

Version: 18.2.1

Shell: pwsh (7.3.6)

Segments:

ConsoleTitle(false)                       -   0 ms -
path(true)                                -   2 ms - Location: 'C:\Users'
time(true)                                -   0 ms -  Date: '2023-08-07 11:58:09.6113314 -0600 MDT m=+0.051860601' CrossSegmentLocation: 'C:\Users'

Run duration: 15.239ms

Cache path: C:\Users\RWest\AppData\Local\oh-my-posh

Config path: C:\Users\RWest\.oh_my_posh.omp.json

Logs:

[DEBUG] 11:58:09.596 shell.go:Getenv:387 → NO DATA
[TRACE] 11:58:09.596 shell.go:Getenv(TERM_PROGRAM) - 125.4µs
[DEBUG] 11:58:09.596 shell.go:Getenv:387 → C:\Users\RWest\AppData\Local
[TRACE] 11:58:09.596 shell.go:Getenv(LOCALAPPDATA) - 0s
[TRACE] 11:58:09.596 shell_windows.go:CachePath() - 0s
[DEBUG] 11:58:09.599 shell.go:Getenv:387 → C:\Users\RWest\.oh_my_posh.omp.json
[TRACE] 11:58:09.599 shell.go:Getenv(POSH_THEME) - 0s
[DEBUG] 11:58:09.599 shell.go:Shell:627 → no shell name provided in flags, trying to detect it
[DEBUG] 11:58:09.606 shell.go:Shell:635 → process name: pwsh.exe
[TRACE] 11:58:09.606 shell.go:Shell() - 7.3569ms
[TRACE] 11:58:09.606 shell.go:resolveConfigPath() - 7.3569ms
[TRACE] 11:58:09.606 shell.go:Init() - 10.1677ms
[TRACE] 11:58:09.606 shell.go:Flags() - 0s
[TRACE] 11:58:09.608 config.go:loadConfig() - 1.2356ms
[TRACE] 11:58:09.608 shell.go:Flags() - 0s
[DEBUG] 11:58:09.608 shell.go:Getenv:387 → NO DATA
[TRACE] 11:58:09.608 shell.go:Getenv(OMP_CACHE_DISABLED) - 0s
[TRACE] 11:58:09.608 shell_windows.go:WindowsRegistryKeyValue(HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColor) - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[DEBUG] 11:58:09.608 shell_windows.go:WindowsRegistryKeyValue:209 → ColorizationColor(DWORD): 0xC4D0000C
[TRACE] 11:58:09.608 shell.go:Shell() - 0s
[DEBUG] 11:58:09.608 shell.go:Getenv:387 → 7.3.6
[TRACE] 11:58:09.608 shell.go:Getenv(POSH_SHELL_VERSION) - 89.1µs
[DEBUG] 11:58:09.608 debug.go:PrintDebug:23 → Segment: Title
[TRACE] 11:58:09.608 shell.go:Flags() - 0s
[DEBUG] 11:58:09.608 block.go:Debug:280 → Segment: path
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[DEBUG] 11:58:09.608 shell.go:Pwd:417 → C:\Users
[TRACE] 11:58:09.608 shell.go:Pwd() - 0s
[DEBUG] 11:58:09.608 shell_windows.go:56 → C:\Users\RWest
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:Pwd() - 0s
[TRACE] 11:58:09.608 shell.go:Shell() - 0s
[TRACE] 11:58:09.608 shell.go:Flags() - 0s
[DEBUG] 11:58:09.608 properties.go:GetBool:22 → mapped_locations_enabled: true
[DEBUG] 11:58:09.608 properties.go:GetString:28 → 
[DEBUG] 11:58:09.608 properties.go:GetString:28 → 
[DEBUG] 11:58:09.608 shell_windows.go:56 → C:\Users\RWest
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[DEBUG] 11:58:09.608 properties.go:GetString:28 → ~
[DEBUG] 11:58:09.608 properties.go:GetKeyValueMap:46 → mapped_locations: map[]
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:GOOS() - 0s
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[DEBUG] 11:58:09.608 properties.go:GetString:28 → full
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[DEBUG] 11:58:09.608 properties.go:GetStringArray:52 → cycle: []
[DEBUG] 11:58:09.608 properties.go:GetString:28 → NO DATA
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[DEBUG] 11:58:09.608 properties.go:GetString:28 → \
[DEBUG] 11:58:09.608 properties.go:GetBool:22 → cycle_folder_separator: false
[DEBUG] 11:58:09.608 properties.go:GetString:28 → %s
[DEBUG] 11:58:09.608 properties.go:GetString:28 → %s
[TRACE] 11:58:09.608 shell.go:PathSeparator() - 0s
[TRACE] 11:58:09.608 shell.go:Pwd() - 0s
[TRACE] 11:58:09.608 shell_windows.go:IsWsl() - 0s
[TRACE] 11:58:09.608 shell.go:StackCount() - 0s
[DEBUG] 11:58:09.610 win32_windows.go:isWriteable:299 → not current user or in group
[DEBUG] 11:58:09.610 win32_windows.go:isWriteable:303 → current user is member of S-1-5-32-544
[DEBUG] 11:58:09.610 win32_windows.go:isWriteable:311 ↓
    WRITE_DAC
    WRITE_OWNER
    SYNCHRONIZE
    DELETE
    READ_CONTROL
[DEBUG] 11:58:09.610 win32_windows.go:isWriteable:313 → user has write access
[TRACE] 11:58:09.610 shell_windows.go:DirIsWritable() - 2.1904ms
[TRACE] 11:58:09.610 shell_windows.go:Root() - 0s
[TRACE] 11:58:09.610 shell.go:Shell() - 0s
[TRACE] 11:58:09.610 shell.go:StatusCodes() - 0s
[TRACE] 11:58:09.610 shell_windows.go:IsWsl() - 0s
[DEBUG] 11:58:09.611 shell.go:TemplateCache:805 → environment: [=::=::\ ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\RWest\AppData\Roaming CommonProgramFiles=C:\Program Files (x86)\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=ARDRWEST-XPS15 ComSpec=C:\WINDOWS\system32\cmd.exe CONDA_PROMPT_MODIFIER=False DriverData=C:\Windows\System32\Drivers\DriverData EFC_12280=1 FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer FPS_BROWSER_USER_PROFILE_STRING=Default HOMEDRIVE=C: HOMEPATH=\Users\RWest LOCALAPPDATA=C:\Users\RWest\AppData\Local LOGONSERVER=\\DS1 NUMBER_OF_PROCESSORS=20 OneDrive=C:\Users\RWest\OneDrive OS=Windows_NT Path=C:\Program Files\PowerShell\7;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\PowerShell\7\;C:\Program Files (x86)\oh-my-posh\bin;C:\Program Files\Git\cmd;C:\Users\RWest\AppData\Local\Microsoft\WindowsApps;C:\Users\RWest\.dotnet\tools;C:\Users\RWest\AppData\Local\Programs\oh-my-posh\bin;C:\Users\RWest\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Neovim\bin; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL POSH_AZURE_ENABLED=False POSH_CURSOR_COLUMN=1 POSH_CURSOR_LINE=1 POSH_GIT_ENABLED=False POSH_INSTALLER=winget POSH_PID=19012 POSH_SHELL_VERSION=7.3.6 POSH_THEME=C:\Users\RWest\.oh_my_posh.omp.json POSH_THEMES_PATH=C:\Users\RWest\AppData\Local\Programs\oh-my-posh\themes POWERLINE_COMMAND=oh-my-posh POWERSHELL_DISTRIBUTION_CHANNEL=MSI:Windows 10 Pro PROCESSOR_ARCHITECTURE=x86 PROCESSOR_ARCHITEW6432=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 154 Stepping 3, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=9a03 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files (x86) ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PSModulePath=C:\Users\RWest\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules PUBLIC=C:\Users\Public SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\WINDOWS TEMP=C:\Users\RWest\AppData\Local\Temp TMP=C:\Users\RWest\AppData\Local\Temp USERDNSDOMAIN=NOVARAD.NET USERDOMAIN=NOVARAD USERDOMAIN_ROAMINGPROFILE=NOVARAD USERNAME=RWest USERPROFILE=C:\Users\RWest windir=C:\WINDOWS WSLENV=WT_SESSION::WT_PROFILE_ID WT_PROFILE_ID={574e775e-4f2a-5b96-ac1e-a2962a402336} WT_SESSION=52fc8c7f-630c-49bd-8aed-4af946d04f96 ZES_ENABLE_SYSMAN=1]
[TRACE] 11:58:09.611 shell.go:Pwd() - 0s
[DEBUG] 11:58:09.611 shell_windows.go:56 → C:\Users\RWest
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[DEBUG] 11:58:09.611 shell.go:User:538 → RWest
[TRACE] 11:58:09.611 shell.go:User() - 0s
[DEBUG] 11:58:09.611 shell.go:Host:550 → ARDRWEST-XPS15
[TRACE] 11:58:09.611 shell.go:Host() - 0s
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[DEBUG] 11:58:09.611 shell.go:Getenv:387 → NO DATA
[TRACE] 11:58:09.611 shell.go:Getenv(SHLVL) - 0s
[TRACE] 11:58:09.611 shell.go:TemplateCache() - 538.1µs
[TRACE] 11:58:09.611 shell.go:TemplateCache() - 0s
[TRACE] 11:58:09.611 shell.go:Shell() - 0s
[DEBUG] 11:58:09.611 block.go:Debug:280 → Segment: time
[TRACE] 11:58:09.611 shell.go:Pwd() - 0s
[DEBUG] 11:58:09.611 shell_windows.go:56 → C:\Users\RWest
[TRACE] 11:58:09.611 shell.go:GOOS() - 0s
[DEBUG] 11:58:09.611 properties.go:GetString:28 → 15:04:05
[TRACE] 11:58:09.611 shell.go:TemplateCache() - 0s
[TRACE] 11:58:09.611 shell.go:TemplateCache() - 0s
[TRACE] 11:58:09.611 shell.go:Shell() - 0s
[DEBUG] 11:58:09.611 shell.go:Getenv:387 → C:\Users\RWest\AppData\Local
[TRACE] 11:58:09.611 shell.go:Getenv(LOCALAPPDATA) - 0s
[TRACE] 11:58:09.611 shell_windows.go:CachePath() - 0s
[TRACE] 11:58:09.611 shell.go:Flags() - 0s
JanDeDobbeleer commented 1 year ago

@WestRyanK confirmed to have been broken with the change to sync.Map. Wil check how to solve this tomorrow.

github-actions[bot] commented 7 months ago

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.