Skip to content

Commit

Permalink
Correct fix for progressbars. This fixes pallets#470
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Nov 27, 2015
1 parent 226ae62 commit a7f6cc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Click Changelog

This contains all major version changes between Click releases.

Version 6.2
-----------

(bugfix release, released on November 27th 2015)

- Correct fix for hidden progress bars.

Version 6.1
-----------

Expand Down
8 changes: 5 additions & 3 deletions click/_termui_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,11 @@ def format_progress_line(self):

def render_progress(self):
from .termui import get_terminal_size
clear_width = self.width
nl = False

if self.is_hidden:
buf = [self.label]
nl = True
else:
buf = []
# Update width in case the terminal has been resized
Expand All @@ -209,6 +210,7 @@ def render_progress(self):
self.max_width = new_width
self.width = new_width

clear_width = self.width
if self.max_width is not None:
clear_width = self.max_width

Expand All @@ -219,13 +221,13 @@ def render_progress(self):
self.max_width = line_len
buf.append(line)

buf.append(' ' * (clear_width - line_len))
buf.append(' ' * (clear_width - line_len))
line = ''.join(buf)

# Render the line only if it changed.
if line != self._last_line:
self._last_line = line
echo(line, file=self.file, color=self.color, nl='')
echo(line, file=self.file, color=self.color, nl=nl)
self.file.flush()

def make_step(self, n_steps):
Expand Down

0 comments on commit a7f6cc2

Please sign in to comment.