PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.69k stars 487 forks source link

Issue oh-my-posh strange spacing between segments despite working in windows terminal #4925

Closed BenjaminLAZARD closed 7 months ago

BenjaminLAZARD commented 7 months ago

Prerequisites

Summary

Problem: spacing between segments that does not seem related with similar issues raised before. image

Expected output: The way it appears to me on Windows Terminal or powershell image

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0.}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.86.2
x64

Extension Version

ms-vscode.powershell@2024.0.0

Steps to Reproduce

ohmyposh template

{
    "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
    "var": {
        "GitWarningcolor": "#fbff07",
        "GitAheadColor": "#fbff07",
        "Font": "Hack Nerd Font Mono"
    },
    "blocks": [
        {
            "alignment": "left",
            "segments": [
                // {
                //     "background": "#000000",
                //     "foreground": "#1aff00",
                //     "powerline_symbol": "\ue0b4",
                //     "style": "plain",
                //     "template": "\ue0ce ",
                //     "type": "text"
                // },
                {
                    "type": "os",
                    "style": "powerline",
                    "powerline_symbol": "\ue0b4",
                    "template": " {{ .Icon }} ",
                    "foreground": "#ffffff",
                    "background": "#000000"
                },
                {
                    "type": "shell",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "foreground": "#1f222c",
                    "background": "#1d90fb",
                    "template": " {{.Name}} {{$version :=split \".\" .Version}}{{$version._0}}.{{$version._1}}",
                    "properties": {
                        "mapped_shell_names": {
                            "pwsh": "\udb82\ude0a",
                            "bash": "\uebca",
                            "zsh": "\ue7a2",
                            "tmux": "\uebc8"
                        }
                    }
                },
                {
                    "type": "root",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "template": " \uf0e7 ",
                    "foreground": "#201b1b",
                    "background": "#ffffff"               
                },
                // {
                //     "background": "#ffffff",
                //     "foreground": "#100e23",
                //     "powerline_symbol": "",
                //     "style": "powerline",
                //     "template": " {{ .UserName }}@{{ .HostName }} ",
                //     "type": "session"
                // },
                {
                    "type": "docker",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "template": " \uf308 {{ .Context }} ",
                    "foreground": "#000000",
                    "background": "#0B59E7"
                },
                {
                    "type": "path",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "template": " {{path .Path .Location}} ",
                    "foreground": "#100e23",
                    "background": "#91ddff",
                    "properties": {
                        "folder_icon": "\uf115",
                        "folder_separator_icon": " \ue0b5 ",
                        "style": "agnoster_short",
                        "max_depth": 4,
                        "mixed_threshold": 4,
                        "mapped_locations_enabled": true,
                        "mapped_locations": {
                            "~/<custom_path>/*": "   \udb82\udd5f   "
                        }
                    }
                },
                {
                    "type": "git",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "template": " {{ url .UpstreamIcon .UpstreamURL }} {{(split \".\" (split \"@\" .User.Email)._1)._0}} \udb80\udc54 {{(split \"/\" .UpstreamURL )._3}} {{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \udb80\udd93 {{ .StashCount }}{{ end }}",
                    "foreground": "#193549",
                    "background": "#fbff07",
                    "background_templates": [
                        "{{ if or (.Working.Changed) (.Staging.Changed) }}{{ .Var.GitWarningcolor }}{{ end }}",
                        "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#FFCC80{{ end }}",
                        "{{ if gt .Ahead 0 }}#B388FF{{ end }}",
                        "{{ if gt .Behind 0 }}#B388FB{{ end }}"
                    ],
                    "properties": {
                        "fetch_status": true,
                        "fetch_user": true,
                        "fetch_upstream_icon": true,
                        "untracked_modes": {
                            "/Users/user/Projects/oh-my-posh/": "no"
                        }
                    }
                },
                {
                    "type": "python",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "template": "  {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Major }}.{{ .Minor }}{{ end }}",
                    "foreground": "#100e23",
                    "background": "#0daa1c",
                    "display_mode": "context"
                },
                {
                    "type": "node",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "template": "  {{ .Full }} ",
                    "foreground": "#ffffff",
                    "background": "#0daa1c"
                },
                {
                    "type": "aws",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "template": "  {{.Profile}}{{if .Region}}@{{.Region}}{{end}}",
                    "foreground": "#ffffff",
                    "background": "#FFA400"
                },
                {
                    "type": "status",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "template": "  ",
                    "foreground": "#ffffff",
                    "background": "#ff8080"
                }
            ],
            "type": "prompt"
        },
        // {
        //     "alignment": "right",
        //     "newline": false,
        //     "segments": [
        //         {
        //             "background": "#0daa1c",
        //             "foreground": "#100e23",
        //             "style": "diamond",
        //             "leading_diamond":"\ue0b6",
        //             "trailing_diamond":"\ue0b4",
        //             // "powerline_symbol": "\ue0b6",
        //             "template": " {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Major }}.{{ .Minor }}{{ end }}",
        //             "type": "python",
        //             "display_mode": "context"
        //         },
        //         {
        //             "type": "node",
        //             "style": "diamond",
        //             "leading_diamond":"\ue0b6",
        //             "trailing_diamond":"\ue0b4",
        //             "foreground": "#ffffff",
        //             "background": "#0daa1c",
        //             "template": "  {{ .Full }} "
        //         },
        //         {
        //             "type": "aws",
        //             "style": "diamond",
        //             "leading_diamond":"\ue0b6",
        //             "trailing_diamond":"\ue0b4",
        //             "foreground": "#ffffff",
        //             "background": "#FFA400",
        //             "template": "  {{.Profile}}{{if .Region}}@{{.Region}}{{end}}"
        //         }
        //     ],
        //     "type": "prompt"
        // },
        {
            "alignment": "left",
            "newline": true,
            "segments": [
                {
                    "foreground": "#007ACC",
                    "style": "plain",
                    "template": "\u276f ",
                    "type": "text"
                }
            ],
            "type": "prompt"
        }
    ],
    "version": 2
}

Visuals

No response

Logs

No response

JustinGrote commented 7 months ago

Thanks for your submission!

The display is going to be influenced by how oh-my-posh outputs ANSI color codes. VSCode primarily uses xterm.js, so any issues with ANSI rendering needs to either be filed in the xterm repo: https://github.com/xtermjs/xterm.js

or filed with oh-my-posh to output in an xterm friendly manner: https://github.com/jandedobbeleer/oh-my-posh

however there is nothing we can do in the vscode extension repo to solve this issue so closing as wont(cant)fix