Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl + A on code in maximized window causes Exception #3750

Open
3 tasks done
mavaddat opened this issue Jul 21, 2023 · 7 comments
Open
3 tasks done

Ctrl + A on code in maximized window causes Exception #3750

mavaddat opened this issue Jul 21, 2023 · 7 comments
Labels
Area-Stability Label for tracking stability Issues Needs-More Investigation Initial investigation is done, but need to follow up.

Comments

@mavaddat
Copy link

mavaddat commented Jul 21, 2023

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

Last 200 Keys:

 i l e n a m e Spacebar o f Spacebar t h e Spacebar X M L Spacebar w e l l - f o r m e d Enter
 Spacebar Spacebar $ ( $ u s i n g : C S D B M i g r a t i o n S t a t u s ) [ $ i ] . F i l e n a m e Spacebar = Spacebar $ x m l p a t h . F u l l N a m e Spacebar - r e p l a c e Spacebar ( [ r e g e x ] : : E s c a p e ( $ T p G x ) ) , Spacebar ' t p - g x ' Enter
 Enter
 Spacebar Spacebar # Spacebar R e l e a s e Spacebar t h e Spacebar s e m a p h o r e Enter
 Spacebar Spacebar $ ( $ u s i n g : s e m a p h o r e ) . R e l e a s e ( ) Enter
 } Ctrl+a

### Exception

System.InvalidOperationException: Cannot locate the offset in the rendered text that was pointed by the original cursor. Initial Coord: (35, -3) Buffer: (98, 30) Cursor: (3, 29)
   at Microsoft.PowerShell.PSConsoleReadLine.RecomputeInitialCoords(Boolean isTextBufferUnchanged)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Render()
   at Microsoft.PowerShell.PSConsoleReadLine.RenderWithPredictionQueryPaused()
   at Microsoft.PowerShell.PSConsoleReadLine.SelectAll(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Screenshot

Screenshot

🛈 Note: Some data has been obscured for privacy.

Environment data

PS Version: 7.3.6
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.1-beta1
PSReadLine EditMode: Windows
OS: 10.0.19041.320 (WinBuild.160101.0800)

Window size

Before maximizing
BufferWidth: 98
BufferHeight: 30
After maximizing
BufferWidth: 183
BufferHeight: 51

Steps to reproduce

  1. Small PowerShell window.
  2. Multiline scriptblock at the prompt.
$CSDBMigrationStatus = Import-Csv -Path "$env:OneDriveCommercial\Documents\csdbMigrationPlan.csv"  # A CSV export of the latest version of the CSDB Migration Plan XLSX file
$semaphore = [System.Threading.Semaphore]::new(0,1)  # A semaphore to limit the number of threads accessing the CSDB object concurrently
$CSDBMigrationStatus | Where-Object -FilterScript { -not [string]::IsNullOrEmpty($_.'Full Path') } | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel {  
# Get the export.log path for the manual export
$exportPath = $_.'Full Path' -replace 'tp-gx', $($using:TpGx) | Split-Path -Parent

# Get all the XML files in the export folder
$xmls = Get-ChildItem -Path $exportPath -Filter '*.xml' | Where-Object -FilterScript {-not (Select-String -Path $_ -Pattern 'This is DRAFT data to be used only for development')} 

# Get the latest XML with the 'well' keyword
$xmlPath = $xmls | Where-Object -FilterScript { $_.BaseName -match 'well' } | Sort-Object -Descending -Property CreationTimeUtc -Top 1

# If there is no such file, get the latest XML with the same name as the export folder
if ($null -eq $xmlPath -or $xmlPath.Count -eq 0) {
  $xmlPath = $xmls | Where-Object -FilterScript { $_.BaseName -match ([regex]::Escape(($exportPath | Split-Path -Leaf))) } | Sort-Object -Descending -Property CreationTimeUtc -Top 1
}

# Look up the index of the current item in the array
$i = $($using:CSDBMigrationStatus).IndexOf($_)

# Wait for the semaphore
$($using:semaphore).WaitOne()

# Set the filename of the XML well-formed
$($using:CSDBMigrationStatus)[$i].Filename = $xmlpath.FullName -replace ([regex]::Escape($TpGx)), 'tp-gx'

# Release the semaphore
$($using:semaphore).Release()
}
  1. Maximize window
  2. Select all using Ctrl + A
  3. Boom 💥 exception

Expected behavior

The original issue is that when I maximize, the text as displayed in the window is not the position of the editable underlying command text. That is, the maximize command isn't able to correctly reflow the command at the command prompt to anticipate where it is in the maximized context.

This is evident by the fact that moving the cursor around does not land in the correct place corresponding to the text as rendered. (I.e., the cursor does not edit the shown text and moving the cursor around doesn't follow the text as shown.)

To mitigate, I do a select all Ctrl + A to force the PowerShell to recalculate the text reflow. The highlighting will show be the boundaries of the text and allow me to understand how the text has moved.

Actual behavior

There is an exception thrown.

@daxian-dbw
Copy link
Member

@mavaddat I cannot reproduce the issue locally with your repro step:

repro-ws-2022

The only difference that I can tell by looking at your screenshot is the prompts (both the regular prompt and the continuation prompt). Can you please come up with a repro with simpler prompts, so that I can reproduce the issue locally?

@daxian-dbw daxian-dbw added Needs-Repro There is no sufficient information on repro steps. Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. labels Jul 21, 2023
@mavaddat
Copy link
Author

mavaddat commented Jul 21, 2023

Very interesting. I am able to consistently reproduce this on my side.
Demo 1
Demo 2

I am on Windows Terminal Preview with the following settings:

settings.json contents
{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        }
    ],
    "copyFormatting": "all",
    "copyOnSelect": false,
    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
    "newTabMenu": 
    [
        {
            "type": "remainingProfiles"
        }
    ],
    "profiles": 
    {
        "defaults": 
        {
            "colorScheme": "Campbell",
            "font": 
            {
                "face": "JetBrainsMonoNL Nerd Font",
                "size": 11.0
            },
            "unfocusedAppearance": 
            {
                "adjustIndistinguishableColors": "never",
                "experimental.retroTerminalEffect": true
            }
        },
        "list": 
        [
            {
                "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "commandline": "%SystemRoot%\\System32\\cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{d7b20cea-47a9-518c-95a4-c8bd91e2e1c6}",
                "hidden": false,
                "name": "Ubuntu 22.04.2 LTS",
                "source": "CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc"
            },
            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                "guid": "{2595cd9c-8f05-55ff-a1d4-93f3041ca67f}",
                "hidden": false,
                "name": "PowerShell Preview (msix)",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                "guid": "{17bf3de4-5353-5709-bcf9-835bd952a95e}",
                "hidden": true,
                "name": "Ubuntu-22.04",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{de381bb4-d05f-5c30-be26-10369b63728b}",
                "hidden": false,
                "name": "Developer Command Prompt for VS 2022 [Preview]",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{9a595cce-583f-58cc-acd3-7103a6175772}",
                "hidden": false,
                "name": "Developer PowerShell for VS 2022 [Preview]",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{8ab8e6f6-35c6-5b46-8419-3e1568105476}",
                "hidden": false,
                "name": "podman-machine-default",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{e636fd95-8db6-56fc-969f-5647553fa92b}",
                "hidden": false,
                "name": "wsl-vpnkit",
                "source": "Windows.Terminal.Wsl"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#300A24",
            "black": "#171421",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#08458F",
            "brightCyan": "#2C9FB3",
            "brightGreen": "#26A269",
            "brightPurple": "#A347BA",
            "brightRed": "#C01C28",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#A2734C",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#FFFFFF",
            "green": "#26A269",
            "name": "Ubuntu-22.04-ColorScheme",
            "purple": "#881798",
            "red": "#C21A23",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#A2734C"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        }
    ],
    "startOnUserLogin": true,
    "themes": []
}
Windows Terminal Preview
Version: 1.18.1462.0

Actually, even pasting the above JSON (the settings for the Windows Terminal) will produce the error.
psreadline

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention 👋 and removed Needs-Repro There is no sufficient information on repro steps. labels Jul 21, 2023
@daxian-dbw
Copy link
Member

You are not using Ctrl+v for pasting. Are you using right click? The 1st and 2nd GIFs from your reply above showed weird results from pasting -- lots of white spaces that don't exist in the script you shared above.

image

Also, I cannot reproduce locally even with the JSON setting you shared, and I'm using the same version of Windows Terminal preview.

repro-ws-2022

Can you paste using Ctrl+v and see if there is a difference? Also, can you also try it in a PowerShell session without loading your profile (so that the influence from your custom prompts can be ruled out)?

@mavaddat
Copy link
Author

Can you paste using Ctrl+v and see if there is a difference? Also, can you also try it in a PowerShell session without loading your profile (so that the influence from your custom prompts can be ruled out)?

Nice catch! I see that the issue does not arise in pwsh -NoProfile -NoLogo (i.e., without loading my profile), so this suggests that it is only happening in conjunction with @JanDeDobbeleer ohmyposh.

You are right that I was pasting with right-click. I see the issue persists with Ctrl+v though if I am using my custom prompts.

@daxian-dbw
Copy link
Member

Can you share your custom prompts here (both the prompt function and the continuation prompt)? Hopefully we can reproduce the issue with the same prompt functions, so we can investigate the root cuase.

@mavaddat
Copy link
Author

Sure, it is the standard setup for oh-my-posh with oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/jandedobbeleer.omp.json" | Invoke-Expression in my PowerShell profile.

This is my oh-my-posh config:

JSON output of oh-my-posh.exe config export

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "version": 2,
  "final_space": true,
  "console_title_template": "{{ .Shell }} in {{ .Folder }}",
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "session",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#c386f1",
          "leading_diamond": "\ue0b6",
          "trailing_diamond": "\ue0b0",
          "template": " {{ .UserName }} "
        },
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#ff479c",
          "template": " \uea83  {{ .Path }} ",
          "properties": {
            "folder_separator_icon": " \ue0b1 ",
            "home_icon": "~",
            "style": "folder"
          }
        },
        {
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#193549",
          "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 }}"
          ],
          "leading_diamond": "\ue0b6",
          "trailing_diamond": "\ue0b4",
          "template": " {{ .UpstreamIcon }}{{ .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 }} \ueb4b {{ .StashCount }}{{ end }} ",
          "properties": {
            "branch_max_length": 25,
            "fetch_stash_count": true,
            "fetch_status": true,
            "fetch_upstream_icon": true
          }
        },
        {
          "type": "node",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#6CA35E",
          "template": " \ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} ",
          "properties": {
            "fetch_version": true
          }
        },
        {
          "type": "go",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#111111",
          "background": "#8ED1F7",
          "template": " \ue626 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
          "properties": {
            "fetch_version": true
          }
        },
        {
          "type": "julia",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#111111",
          "background": "#4063D8",
          "template": " \ue624 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
          "properties": {
            "fetch_version": true
          }
        },
        {
          "type": "python",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#111111",
          "background": "#FFDE57",
          "template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
          "properties": {
            "display_mode": "files",
            "fetch_virtual_env": false
          }
        },
        {
          "type": "ruby",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#AE1401",
          "template": " \ue791 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
          "properties": {
            "display_mode": "files",
            "fetch_version": true
          }
        },
        {
          "type": "azfunc",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#FEAC19",
          "template": " \uf0e7{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
          "properties": {
            "display_mode": "files",
            "fetch_version": false
          }
        },
        {
          "type": "aws",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background_templates": [
            "{{if contains \"default\" .Profile}}#FFA400{{end}}",
            "{{if contains \"jan\" .Profile}}#f1184c{{end}}"
          ],
          "template": " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ",
          "properties": {
            "display_default": false
          }
        },
        {
          "type": "root",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#111111",
          "background": "#ffff66",
          "template": " \uf0ad "
        },
        {
          "type": "executiontime",
          "style": "plain",
          "foreground": "#ffffff",
          "background": "#83769c",
          "template": "<transparent>\ue0b0</> \ueba2 {{ .FormattedMs }}\u2800",
          "properties": {
            "always_enabled": true
          }
        },
        {
          "type": "exit",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#00897b",
          "background_templates": [
            "{{ if gt .Code 0 }}#e91e63{{ end }}"
          ],
          "trailing_diamond": "\ue0b4",
          "template": "<parentBackground>\ue0b0</> \ue23a ",
          "properties": {
            "always_enabled": true
          }
        }
      ]
    },
    {
      "type": "rprompt",
      "segments": [
        {
          "type": "shell",
          "style": "plain",
          "foreground": "#ffffff",
          "background": "#0077c2",
          "template": "<#0077c2,transparent>\ue0b6</> \uf489 {{ .Name }} <transparent,#0077c2>\ue0b2</>"
        },
        {
          "type": "ytm",
          "style": "powerline",
          "powerline_symbol": "\ue0b2",
          "invert_powerline": true,
          "foreground": "#111111",
          "background": "#1BD760",
          "template": " \uf167 {{ .Icon }}{{ if ne .Status \"stopped\" }}{{ .Artist }} - {{ .Track }}{{ end }} ",
          "properties": {
            "paused_icon": "\uf04c ",
            "playing_icon": "\uf04b "
          }
        },
        {
          "type": "battery",
          "style": "powerline",
          "powerline_symbol": "\ue0b2",
          "invert_powerline": true,
          "foreground": "#ffffff",
          "background": "#f36943",
          "background_templates": [
            "{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
            "{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
            "{{if eq \"Full\" .State.String}}#4caf50{{end}}"
          ],
          "template": " {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}\uf295 ",
          "properties": {
            "charged_icon": "\ue22f ",
            "charging_icon": "\ue234 ",
            "discharging_icon": "\ue231 "
          }
        },
        {
          "type": "time",
          "style": "diamond",
          "invert_powerline": true,
          "foreground": "#111111",
          "background": "#2e9599",
          "leading_diamond": "\ue0b2",
          "trailing_diamond": "\ue0b4",
          "template": " {{ .CurrentDate | date .Format }} "
        }
      ]
    }
  ]
}

@StevenBucher98 StevenBucher98 added the Area-Stability Label for tracking stability Issues label Aug 14, 2023
@StevenBucher98 StevenBucher98 added Needs-More Investigation Initial investigation is done, but need to follow up. and removed Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. Needs-Attention 👋 labels Aug 21, 2023
@mavaddat
Copy link
Author

mavaddat commented Feb 6, 2024

I am still seeing this exception, BTW.

Environment

Field Value
PSReadLine 2.3.4
PowerShell 7.4.1
OS Microsoft Windows 10.0.19045
BufferWidth 235
BufferHeight 60

Last 200 Keys:

 o n ) ) Enter
 Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar i f ( - n o t Spacebar $ p a r s i n g E r r o r ) { Enter
 Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar W r i t e - E r r o r Spacebar - E x c e p t i o n Spacebar $ _ . E x c e p t i o n Spacebar - M e s s a g e Spacebar " E r r o r Spacebar p r o c e s s i n g Spacebar $ x m l F i l e " Enter
 Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar Spacebar } Enter
 Spacebar Spacebar Spacebar Spacebar } Enter
 } Enter
 G e t - e r Tab Spacebar RightArrow Enter
 $ k k Backspace Backspace l a t Tab Enter
 LeftArrow $ RightArrow . e x Tab . Backspace Enter
 UpArrow . i n Tab Enter
 UpArrow . i n Tab Enter
 UpArrow Ctrl+Backspace Ctrl+Backspace Ctrl+Backspace Ctrl+Backspace Ctrl+Backspace UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow LeftArrow Home Ctrl+a LeftArrow RightArrow Ctrl+a

Exception

System.InvalidOperationException: Cannot locate the offset in the rendered text that was pointed by the original cursor. Initial Coord: (34, -4) Buffer: (171, 39) Cursor: (3, 38)
   at Microsoft.PowerShell.PSConsoleReadLine.RecomputeInitialCoords(Boolean isTextBufferUnchanged)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Render()
   at Microsoft.PowerShell.PSConsoleReadLine.RenderWithPredictionQueryPaused()
   at Microsoft.PowerShell.PSConsoleReadLine.SelectAll(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Stability Label for tracking stability Issues Needs-More Investigation Initial investigation is done, but need to follow up.
Projects
None yet
Development

No branches or pull requests

3 participants