JanDeDobbeleer / oh-my-posh

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

Angular Block Causes Delay #1352

Closed yekanchi closed 2 years ago

yekanchi commented 2 years ago

Code of Conduct

What happened?

Adding an Angular block to show the angular version on the prompt, causes the blocks to delay around 4 secs before show-up.

oh-my-posh is speedy in non-anuglar folders. so I'm sure the delaying block is angular. I tried it with the new angular app with just basic node_modules. the result is delayed again. my angular version is 12.

Theme

custom theme:

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "root",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#ffe9aa"
        },
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#91ddff",
          "properties": {
            "folder_icon": "\uF115",
            "folder_separator_icon": " \uE0B1 ",
            "style": "full"
          }
        },
        {
          "type": "python",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#ff774d",
          "properties": {
            "prefix": " \uE235 "
          }
        },
        {
          "type": "executiontime",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#faffaf",
          "properties": {
            "prefix": "<#ff774d> \ufbab </>",
            "always_enabled": true,
            "display_mode": "always"
          }
        },
        {
          "type": "exit",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#ff8080",
          "properties": {
            "prefix": " \uE20F"
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "right",
      "segments": [
        {
          "type": "angular",
          "style": "powerline",
          "invert_powerline": true,
          "powerline_symbol": "\uE0B2",
          "foreground": "#ffffff",
          "background": "#c71f1f",
          "properties": {
            "postfix": " \uE753 "
          }
        },
        {
          "type": "git",
          "style": "powerline",
          "invert_powerline": true,
          "powerline_symbol": "\uE0B2",
          "foreground": "#193549",
          "background": "#95ffa4",
          "properties": {
            "prefix": "",
            "fetch_status": true,
            "fetch_stash_count": true,
            "fetch_upstream_icon": true,
            "template": "{{ .UpstreamIcon }}{{ .HEAD }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }}"
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "type": "text",
          "style": "plain",
          "foreground": "#007ACC",
          "properties": {
            "prefix": "",
            "text": "→"
          }
        }
      ]
    }
  ],
  "final_space": false
}

What OS are you seeing the problem on?

Windows

Which shell are you using?

PowerShell, I'm using pwsh 7.2 (PowerShell core).

Log output

lnu commented 2 years ago

someone reported the same issue https://github.com/JanDeDobbeleer/oh-my-posh/issues/1254 The way we retrieve the version(using ng version) is known to be slow It should also be slow if you call ng version manually

JanDeDobbeleer commented 2 years ago

@yekanchi yes, that's the angular CLI which is suuuuuper slow. We could fallback to parsing the value inside the json file but I don't have a setup yet to facilitate debugging that.

yekanchi commented 2 years ago

also, it seams if the local angular version for the project is lower than the global version, the prompt is ruined.

the red lines are angular block:

image

JanDeDobbeleer commented 2 years ago

@yekanchi yes, that's because that should never the case, right? At least, that was my assumption... I'm in favour of removing the CLI call for parsing the local package.json or context inside the node_modules folder. Can you share that information with me?

Depechie commented 2 years ago

@JanDeDobbeleer this is certainly often the case... we have several Angular projects and fix the cli version in our devcointainers ( we develop with VS Code dev containers ). But the global install on the dev machine will be higher because the dev is looking at the new features for other projects.

JanDeDobbeleer commented 2 years ago

@Depechie the good news is that @lnu created a PR to parse the info in the node_modules folder.

lnu commented 2 years ago

@Depechie hope it will suit your need. Can you confirm it works well on your side?

Depechie commented 2 years ago

@lnu looking good it seems

yekanchi commented 2 years ago

this issue is resolved in version 6.29.1 of oh-my-posh

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.