Skip to content

The progress bar displayed by WriteProgress() in the console becomes corrupted. #21293

Closed

Description

@yotsuda

Prerequisites

Steps to reproduce

If the StatusDescription includes Japanese characters, the progress bar becomes corrupted.
Execute the following cmdlet.

using System.Management.Automation;
namespace ReproProgress
{
    [Cmdlet(VerbsCommon.Get, "MyItem", SupportsShouldProcess = true)]
    public class MyCmdlet : Cmdlet
    {
        protected override void ProcessRecord()
        {
            string[] status = new string[] {
                "The first stage",
                "次の段階",
                "その次の段階",
                "そのまた次の段階",
                "もうすぐ終わるよ",
                "完了!"
            };

            var progress = new ProgressRecord(1, "My Status", "preparing...");

            int index = 0;
            foreach (var stage in status)
            {
                progress!.PercentComplete = (++index * 100) / status.Count();
                progress.StatusDescription = $"{index:D}/{status.Count()} {stage}";
                WriteProgress(progress);
                Thread.Sleep(500);
            }

            progress.RecordType = ProgressRecordType.Completed;
            WriteProgress(progress);
        }
    }
}

Expected behavior

The closing bracket at the end of the progress bar should be displayed on the same line without breaking to a new line.

Actual behavior

The closing bracket at the end of the progress bar appears on the next line and remains there even after the progress has completed.

Error details

No response

Environment data

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

Visuals

In progress:
image

The end bracket remains after completion:
image

Activity

  1. SteveL-MSFT commented on Mar 4, 2024

    @SteveL-MSFT
    Member

    Seems like double-wide characters aren't being taken into account when calculating width

  2. added
    Issue-BugIssue has been identified as a bug in the product
    and removed
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Mar 4, 2024
  3. yotsuda commented on Mar 4, 2024

    @yotsuda
    ContributorAuthor

    When displaying multiple progress bars, the screen becomes significantly cluttered. This Copy-Item cmdlet in my provider displays multiple progress bars to represent the sub-progress of the contents being copied in the folder. After the main progress bar completes, all sub-progress bars are also marked as completed. However, they remain visible on the screen without disappearing.
    https://github.com/PowerShell/PowerShell/assets/6428198/25fd13f5-bbf1-4c5d-9608-e1d14bbfd340

  4. yotsuda commented on Mar 5, 2024

    @yotsuda
    ContributorAuthor

    Steve Lee (@SteveL-MSFT) Thank you so much for taking quick action!

  5. yotsuda commented on Apr 30, 2024

    @yotsuda
    ContributorAuthor

    Hello Steve Lee (@SteveL-MSFT) , could you please let me know if this issue has been resolved? Thank you.

  6. yotsuda commented on Oct 28, 2024

    @yotsuda
    ContributorAuthor

    Hello Steve Lee (@SteveL-MSFT) , I am still waiting for the fix. Could you please provide any updates? I truly appreciate your help.

  7. iSazonov commented on Oct 28, 2024

    @iSazonov
    Collaborator

    For reference #23861 (comment)

  8. yotsuda commented on Apr 27, 2025

    @yotsuda
    ContributorAuthor

    Hello Steve Lee (@SteveL-MSFT) Ilya (@iSazonov) ,
    I am still waiting for the fix.
    I understand that it is difficult to completely fix this issue without causing a performance degradation.
    However, I don't think it is necessary to fully fix it (i.e., to calculate the exact string length) for any arbitrary characters such as emojis.
    Since all Japanese hiragana, katakana, and kanji characters are strictly twice as wide as Latin alphabet characters,
    would it be possible to at least handle these characters with reasonable computational cost?
    I have been struggling with this issue for a long time.
    I would greatly appreciate it if you could fix it.
    Thank you very much.

  9. added
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    on Apr 27, 2025
  10. iSazonov commented on Apr 27, 2025

    @iSazonov
    Collaborator

    MSFT team hasn't plans to fix this in near time but it can be community PR.

  11. added 2 commits that reference this issue on Oct 13, 2025
    40387ce
    b837291
  12. yotsuda commented on Oct 13, 2025

    @yotsuda
    ContributorAuthor

    Ilya (@iSazonov) I've submitted a community PR to fix this: #26185

    Comprehensive testing completed with Japanese, Chinese, Korean, emojis, Thai, and Arabic text. All tests passed successfully.

  13. added 2 commits that reference this issue on Oct 15, 2025
    a5227d3
    382d0e4
  14. added 3 commits that reference this issue on Oct 24, 2025
    e26b27c
    1309d67
    463cd77
  15. yotsuda commented on Apr 11, 2026

    @yotsuda
    ContributorAuthor

    Not stale — PR #26185 has been sitting idle for over 5 months waiting for review. All feedback from Ilya (@iSazonov) has been addressed (last review round in late October, final commits on 2025-11-02, commit e0d89df), and no further changes have been requested since.

    Steve Lee (@SteveL-MSFT) Ilya (@iSazonov) could I kindly ask for another look when you have time? I'd really appreciate getting this across the finish line. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-BugIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions