JanDeDobbeleer / oh-my-posh

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

Color mismatch between segments #1226

Closed chrisant996 closed 2 years ago

chrisant996 commented 2 years ago

Code of Conduct

What happened?

The part inside the red box looks wrong. image

Since the arrowhead to the right is black, I would expect the tails to the left to be black, but they are cyan.

Using -debug or -export-png produce the expected results, but printing the actual prompt string with ANSI codes emits incorrect ANSI code for the background color (it explicitly uses a cyan color -- see the Logs section below).

Version

oh-my-posh 6.3.1, windows i386, in plain CMD.EXE window, on Windows 10 21H1 (19043.1348).

Also occurs in Windows Terminal or ConEmu. Occurs when running oh-my-posh by itself in CMD.EXE, or when using Clink to apply it to the prompt.

Theme

jandedobbeleer.omp.json

What OS are you seeing the problem on?

Windows

Which shell are you using?

other (please specify)

Relevant log output

JanDeDobbeleer commented 2 years ago

@chrisant996 could it be the theme you're using is outdated looking at the version of oh-my-posh? Might be good to get the latest version of oh-my-posh and the corresponding theme in main as I can't reproduce this.

chrisant996 commented 2 years ago

The latest theme probably avoids the issue.

Doesn't it seem like there has to be a code issue, though? Since -debug and -export-png produce correct output, but normal output is incorrect, it must be that the output algorithms are not fully in sync with each other, right?

Try this theme file, which should reproduce the issue:

{
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "session",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#c386f1",
          "leading_diamond": "\uE0B6",
          "trailing_diamond": "\uE0B0"
        },
        {
          "type": "spotify",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#1BD760",
          "properties": {
            "prefix": " \uF9C6 "
          }
        },
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#ff479c",
          "properties": {
            "prefix": " \uE5FF ",
            "style": "folder"
          }
        },
        {
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#fffb38",
          "properties": {
            "display_stash_count": true,
            "display_upstream_icon": true
          }
        },
        {
          "type": "battery",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#f36943",
          "properties": {
            "battery_icon": "",
            "color_background": true,
            "charged_color": "#4caf50",
            "charging_color": "#40c4ff",
            "discharging_color": "#ff5722",
            "postfix": "\uF295 "
          }
        },
        {
          "type": "node",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#6CA35E",
          "properties": {
            "prefix": " \uE718 "
          }
        },
        {
          "type": "shell",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#0077c2",
          "properties": {
            "prefix": " \uFCB5 "
          }
        },
        {
          "type": "root",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#ffff66"
        },
        {
          "type": "exit",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#2e9599",
          "leading_diamond": "",
          "trailing_diamond": "\uE0B4",
          "properties": {
            "display_exit_code": false,
            "always_enabled": true,
            "error_color": "#f1184c",
            "color_background": true,
            "prefix": "<transparent>\uE0B0</> \uE23A"
          }
        }
      ]
    }
  ],
  "final_space": true
}
JanDeDobbeleer commented 2 years ago

The latest theme probably avoids the issue.

@chrisant996 can you confirm that on your end?

I'll validate this theme as well. There's a color fallback in the normal rendering, debug is different in that area.

JanDeDobbeleer commented 2 years ago

@chrisant996 on second thought, I do believe that was an actual bug I fixed this week even. But please confirm. I read too quickly here and might have misinterpreted the issue (late evening, dead tired).

chrisant996 commented 2 years ago

@chrisant996 on second thought, I do believe that was an actual bug I fixed this week even. But please confirm. I read too quickly here and might have misinterpreted the issue (late evening, dead tired).

I'm using omp 6.3.1 which seems to be the latest and up to date with head in master.

Also, why does the current jandedobbeleer.omp.json using U+2800 (braille zero, empty braille pattern) for the final character in the execution time segment? It shows up as an unrecognized character in the nerd font I'm using (Fira Code), and it also shows up as an unrecognized character in the preview image at https://ohmyposh.dev/docs/themes/.

chrisant996 commented 2 years ago

The latest theme probably avoids the issue.

@chrisant996 can you confirm that on your end?

I'll validate this theme as well. There's a color fallback in the normal rendering, debug is different in that area.

The latest jandedobbeleer.omp.json does not show the glitch with v6.3.1, but I don't know exactly which change avoids that. I guess I can try to narrow it down.

JanDeDobbeleer commented 2 years ago

@chrisant996 I know why. It misses a segment in between compared to the last one. The change that causes this is that a diamond style segment without a leading diamond gets joined to a powerline style segment (wasn't the case before). In theory you could add the prefix as the leading diamond and it would render correctly.

About U+2800, that's very observant and it's because of a bug in Windows Terminal.

chrisant996 commented 2 years ago

About U+2800, that's very observant and it's because of a bug in Windows Terminal.

I see. Since the Preview shows it as an unrecognized character, I wondered if it was a typo. The previews probably all use the same font, which is probably different than some of the themes expect.

JanDeDobbeleer commented 2 years ago

@chrisant996 exactly, the preview was quite the work tbh. Maybe not ideal, and one could argue that fix should be part of the standard themes.

JanDeDobbeleer commented 2 years ago

@chrisant996 confirmed that changing to this segment fixes the issue:

{
  "type": "exit",
  "style": "diamond",
  "foreground": "#ffffff",
  "background": "#2e9599",
  "leading_diamond": "<transparent,background>\uE0B0</>",
  "trailing_diamond": "\uE0B4",
  "properties": {
    "display_exit_code": false,
    "always_enabled": true,
    "error_color": "#f1184c",
    "color_background": true,
    "prefix": " \uE23A"
  }
}
github-actions[bot] commented 3 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.