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

Paste/enter bug with small amount of segments #4200

Closed johnascroft closed 1 year ago

johnascroft commented 1 year ago

Code of Conduct

What happened?

When using oh-my-posh (latest version) with git bash (v2.42.0), within Microsoft Terminal (latest version) I'm getting weird behaviour when pasting commands in and pressing enter. It seems to repeat the first few characters upon pressing enter:

image

If I add some more segments to the config (for example adding the shell type segment), I don't seem to get the issue:

image

In both cases, the commands run as expected but it seems with a minimum length of segments it seems to have this weird behaviour.

Theme

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "type": "prompt",
      "segments": [
        {
          "type": "shell",
          "style": "powerline",
          "powerline_symbol": "",
          "foreground": "#D8DEE9",
          "background": "#3B4252",
          "properties": {
            "mapped_shell_names": {
              "pwsh": "PS"
            }
          }
        },
        {
          "type": "path",
          "background": "#3B4252",
          "foreground": "#D8DEE9",
          "properties": {
            "style": "folder"
          },
          "style": "powerline",
          "powerline_symbol": "",
          "template": " \ue5ff {{ .Path }} "
        },
        {
          "type": "git",
          "background": "#81A0C1",
          "foreground": "#3B4252",
          "powerline_symbol": "",
          "properties": {
            "cherry_pick_icon": "\u2713 ",
            "commit_icon": "\u25b7 ",
            "fetch_status": true,
            "merge_icon": "\u25f4 ",
            "no_commits_icon": "[no commits]",
            "fetch_upstream_icon": true,
            "rebase_icon": "\u2c62 ",
            "tag_icon": "\u25b6 "
          },
          "style": "powerline",
          "template": "{{ if gt .Ahead 0 }} \u2191{{.Ahead}}{{end}}{{ if gt .Behind 0 }} \u2193{{.Behind}}{{end}}{{ if .Working.Changed }} +{{ .Working.Added }} ~{{ .Working.Modified }} -{{ .Working.Deleted }} {{ end }}"
        },
        {
          "type": "root",
          "background": "#ffc107",
          "foreground": "#18354c",
          "powerline_symbol": "",
          "style": "powerline",
          "template": " \uf0e7 "
        }
      ]
    }
  ],
  "final_space": true,
  "version": 2
}

What OS are you seeing the problem on?

Windows

Which shell are you using?

bash

Log output

Version: 18.5.0

Shell: bash (5.2.15(1)-release)

Prompt:

 bash   code 

Segments:

ConsoleTitle(false)                       -   0 ms
Shell(true)                               -   1 ms
Path(true)                                -   2 ms
Git(false)                                -   2 ms
Root(false)                               -   0 ms

Run duration: 9.3302ms

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

Config path: C:/Users/john/john.omp.json
JanDeDobbeleer commented 1 year ago

@crowngasjohn I can't reproduce this with your config, does this also happen with only oh-my-posh in your .bashrc?

johnascroft commented 1 year ago

Apologies, this is the "broken" config that causes the problem (if I remove enough segments, in this case the shell one although I don't think it's specific to that particular type):

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "type": "prompt",
      "segments": [
        {
          "type": "path",
          "background": "#3B4252",
          "foreground": "#D8DEE9",
          "properties": {
            "style": "folder"
          },
          "style": "powerline",
          "powerline_symbol": "",
          "template": " \ue5ff {{ .Path }} "
        },
        {
          "type": "git",
          "background": "#81A0C1",
          "foreground": "#3B4252",
          "powerline_symbol": "",
          "properties": {
            "cherry_pick_icon": "\u2713 ",
            "commit_icon": "\u25b7 ",
            "fetch_status": true,
            "merge_icon": "\u25f4 ",
            "no_commits_icon": "[no commits]",
            "fetch_upstream_icon": true,
            "rebase_icon": "\u2c62 ",
            "tag_icon": "\u25b6 "
          },
          "style": "powerline",
          "template": "{{ if gt .Ahead 0 }} \u2191{{.Ahead}}{{end}}{{ if gt .Behind 0 }} \u2193{{.Behind}}{{end}}{{ if .Working.Changed }} +{{ .Working.Added }} ~{{ .Working.Modified }} -{{ .Working.Deleted }} {{ end }}"
        },
        {
          "type": "root",
          "background": "#ffc107",
          "foreground": "#18354c",
          "powerline_symbol": "",
          "style": "powerline",
          "template": " \uf0e7 "
        }
      ]
    }
  ],
  "final_space": true,
  "version": 2
}

If I remove everything from my .bashrc file and just leave this, it's the same issue:

# Initialise oh-my-posh on start-up with my own config file
eval "$(oh-my-posh init bash --config ~/john.omp.json)"
JanDeDobbeleer commented 1 year ago

@crowngasjohn same, can't reproduce it. Something else is interfering here locally. Do you have shell integrations enabled in Windows Terminal perhaps? I'm also using the Atlas engine (and preview Terminal on latest).