JanDeDobbeleer / oh-my-posh

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

panic: strings: negative Repeat count #4135

Closed mateuszdrab closed 1 year ago

mateuszdrab commented 1 year ago

Code of Conduct

What happened?

It appears that today's update to OMP triggers a panic in my environment (part of my profile is to auto update omp)

Theme

# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
blocks:
  - alignment: left
    segments:
      - background: "red"
        foreground: "white"
        leading_diamond: 
        trailing_diamond: 
        style: diamond
        properties:
          windows: " "
        template: " {{.Icon}}{{ if .WSL }} WSL{{ end }} "
        type: os
      - background: "yellow"
        foreground: "black"
        powerline_symbol: 
        style: powerline
        template: " {{ if .SSHSession }} {{ end }}{{ .UserName }}@{{ .HostName }} "
        type: session
      - background: "blue"
        foreground: "white"
        leading_diamond: <transparent,background></>
        trailing_diamond: 
        style: diamond
        template: "  {{ .Name }} "
        type: shell
      - background: "red"
        foreground: "white"
        style: powerline
        powerline_symbol: 
        template: "  "
        type: root
    type: prompt
  - alignment: right
    overflow: hide
    segments:
      - background: "cyan"
        foreground: "black"
        leading_diamond: 
        style: diamond
        template:
          "  CPU: {{ round .PhysicalPercentUsed .Precision }}% LOAD: {{ round
          .Load1 .Precision }} {{ round .Load5 .Precision }} {{ round .Load15
          .Precision }} MEM: {{ (div ((sub .PhysicalTotalMemory
          .PhysicalFreeMemory)|float64) 1000000000.0) }}/{{ (div
          .PhysicalTotalMemory 1000000000.0) }}GB "
        trailing_diamond: <transparent,background></>
        type: sysinfo
      - background: "yellow"
        background_templates:
          - '{{if eq "Charging" .State.String}}red{{end}}'
          - '{{if eq "Discharging" .State.String}}yellow{{end}}'
          - '{{if eq "Full" .State.String}}green{{end}}'
        foreground: "white"
        invert_powerline: true
        powerline_symbol: 
        properties:
          charged_icon: " "
          charging_icon: " "
          discharging_icon: " "
        style: powerline
        template:
          " {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error
          }} "
        type: battery
      - background: "lightGreen"
        background_templates:
          - "{{ if .Env.TMUX }}green{{end}}"
        foreground: "black"
        invert_powerline: true
        leading_diamond: 
        trailing_diamond: 
        style: diamond
        template: "  {{ .CurrentDate | date .Format }} "
        type: time
    type: prompt
  - alignment: left
    newline: true
    segments:
      - background: "magenta"
        foreground: "white"
        leading_diamond: 
        properties:
          style: folder
        style: diamond
        template: "  {{ .Path }} "
        type: path
        trailing_diamond: 
      - type: python
        style: powerline
        powerline_symbol: 
        foreground: yellow
        background: blue
        template: "  {{ .Full }} "
      - background: "#fffb38"
        background_templates:
          - "{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}"
          - "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}"
          - "{{ if gt .Ahead 0 }}#B388FF{{ end }}"
          - "{{ if gt .Behind 0 }}#B388FF{{ end }}"
        foreground: "#193549"
        leading_diamond: <transparent,background></>
        properties:
          branch_max_length: 25
          fetch_stash_count: true
          fetch_status: true
          fetch_upstream_icon: true
        style: diamond
        trailing_diamond: 
        template: " {{ .UpstreamIcon }}{{ .HEAD }}{{ .BranchStatus }}{{ if
          .Working.Changed }}  {{ .Working.String }}{{ end }}{{ if and
          (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if
          .Staging.Changed }}  {{ .Staging.String }}{{ end }}{{ if gt
          .StashCount 0 }}  {{ .StashCount }}{{ end }} "
        type: git
      - background: "darkGray"
        foreground: "white"
        properties:
          always_enabled: true
        style: diamond
        template: " {{ .FormattedMs }} "
        type: executiontime
        leading_diamond: <transparent,background></>
        trailing_diamond: 
      - background: "green"
        background_templates:
          - "{{ if gt .Code 0 }}red{{ end }}"
        foreground: "white"
        leading_diamond: <transparent,background></>
        properties:
          always_enabled: true
        style: diamond
        template: " {{ if gt .Code 0 }} {{ .Code }} {{ if ne (toString .Meaning) (toString .Code) }}{{ .Meaning }}{{ end }}{{ else }}{{ end }} "
        trailing_diamond: 
        type: exit
    type: prompt
  - alignment: right
    overflow: hide
    segments:
      - type: text
        # template: "{{ if .Env.StepCaCertificateValidity }}  {{ secondsRound .Env.StepCaCertificateValidity }}{{end}} "
        template: "{{ if .Env.StepCaCertificateValidity }}  {{ .Env.StepCaCertificateValidity }} {{end}}"
        background: "lightMagenta"
        foreground: "white"
        leading_diamond: 
        style: diamond
        trailing_diamond: 
      - background: "lightGreen"
        foreground: "white"
        leading_diamond: " "
        trailing_diamond: 
        template: "{{ if .Env.ConnectedVCenter }}  {{ .Env.ConnectedVCenter }}{{end}} "
        style: diamond
        type: text
      - background: "yellow"
        foreground: "black"
        leading_diamond: " "
        style: diamond
        template: " ﴱ {{.Context}} {{if .Namespace}}- {{.Namespace}}{{end}} "
        trailing_diamond: 
        type: kubectl
      - background: "blue"
        foreground: "white"
        leading_diamond: " "
        trailing_diamond: 
        style: diamond
        template: ' ﴃ {{ .Name }} ({{ if .EnvironmentName | contains "AzureCloud" }}{{ "Global" }}{{ else }} {{ .EnvironmentName }}{{ end }}) '
        type: az
    type: prompt
  - alignment: left
    newline: true
    segments:
      - foreground_templates:
          - "{{ if gt .Code 0 }}red{{ end }}"
        foreground: "green"
        properties:
          always_enabled: true
        style: plain
        template: " > "
        type: exit
    type: prompt
console_title_template: "{{ if not .Env.TMUX}}{{.UserName}}@{{.HostName}}:{{end}}{{.Folder}}"
final_space: false
version: 2
# tooltips:
#   - type: git
#     tips:
#       - git
#       - g
#     style: diamond
#     foreground: "#193549"
#     background: "#fffb38"
#     leading_diamond: 
#     trailing_diamond: 
#     template:
#       "{{ .HEAD }}{{ if .Staging.Changed }}  {{ .Staging.String }}{{ end
#       }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if
#       .Working.Changed }}  {{ .Working.String }}{{ end }}"
#     properties:
#       fetch_status: true
#       fetch_upstream_icon: true

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

goroutine 1 [running]:
strings.Repeat({0x9e3054, 0x1}, 0xffffffe0)
        /opt/hostedtoolcache/go/src/strings/strings.go:538 +0x44c
github.com/jandedobbeleer/oh-my-posh/src/engine.(*Engine).renderBlock(0x29c6d80, 0x29c0600, 0x0)
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine/engine.go:251 +0xac8
github.com/jandedobbeleer/oh-my-posh/src/engine.(*Engine).Primary(0x29c6d80)
        /home/runner/work/oh-my-posh/oh-my-posh/src/engine/prompt.go:37 +0x358
github.com/jandedobbeleer/oh-my-posh/src/cli.glob..func14(0xeb8428, {0x28c1680, 0x1, 0x9})
        /home/runner/work/oh-my-posh/oh-my-posh/src/cli/print.go:78 +0x6cc
github.com/spf13/cobra.(*Command).execute(0xeb8428, {0x28c15e0, 0x9, 0xa})
        /opt/hostedtoolcache/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x714
github.com/spf13/cobra.(*Command).ExecuteC(0xeb8598)
        /opt/hostedtoolcache/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x418
github.com/spf13/cobra.(*Command).Execute(...)
        /opt/hostedtoolcache/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
github.com/jandedobbeleer/oh-my-posh/src/cli.Execute()
        /home/runner/work/oh-my-posh/oh-my-posh/src/cli/root.go:38 +0x20
main.main()
        /home/runner/work/oh-my-posh/oh-my-posh/src/main.go:6 +0x14
JanDeDobbeleer commented 1 year ago

@mateuszdrab which version? I think I just fixed that on the latest one.

mateuszdrab commented 1 year ago

@mateuszdrab which version? I think I just fixed that on the latest one.

You're right it just updated again and works now 🙂

Apologies

JanDeDobbeleer commented 1 year ago

@mateuszdrab all fine, thanks for reporting!

github-actions[bot] commented 8 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.