Skip to content

fix: flickering on powershell#220

Merged
schollz merged 1 commit intoschollz:mainfrom
mengshengwu:fix-windows-progressbar-flickering
Oct 7, 2025
Merged

fix: flickering on powershell#220
schollz merged 1 commit intoschollz:mainfrom
mengshengwu:fix-windows-progressbar-flickering

Conversation

@mengshengwu
Copy link
Contributor

Fix Windows progress bar flickering issue

Problem

On Windows platforms, the progress bar exhibits significant flickering during updates due to differences in how Windows console handles carriage return (\r) characters compared to Unix/Linux systems.

Root Cause

The issue is in the clearProgressBar function where multiple \r operations are used:

str := fmt.Sprintf("\r%s\r", strings.Repeat(" ", s.maxLineWidth))

Windows console doesn't handle multiple \r operations as reliably as Unix/Linux terminals, causing visual artifacts.

Solution

  • Added platform-specific handling for Windows
  • Use minimal \r operation on Windows instead of full-line overwrite
  • Maintain backward compatibility for Unix/Linux systems

Changes

  • Added runtime import for platform detection
  • Modified clearProgressBar function to use Windows-specific handling
  • Simplified cursor control on Windows to reduce flickering

Testing

  • ✅ Tested on Windows PowerShell
  • ✅ Tested on Windows Terminal
  • ✅ Verified no regression on Unix/Linux systems

Related Issue

Closes #219

@schollz schollz merged commit 655d41e into schollz:main Oct 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

windows: flickering on powershell due to redundant \r in clearProgressBar

2 participants