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

fix: variable name conflicts with built in function #1448

Merged
merged 5 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/oras/internal/display/status/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const (
MinWidth = 80
// MinHeight is the minimal height of supported console.
MinHeight = 10
// cannot use aec.Save since DEC has better compatilibity than SCO
// Save cannot use aec.Save since DEC has better compatibility than SCO
Save = "\0337"
// cannot use aec.Restore since DEC has better compatilibity than SCO
// Restore cannot use aec.Restore since DEC has better compatibility than SCO
Restore = "\0338"
)

Expand Down Expand Up @@ -87,7 +87,7 @@ func (c *Console) OutputTo(upCnt uint, str string) {

// Restore restores the saved cursor position.
func (c *Console) Restore() {
// cannot use aec.Restore since DEC has better compatilibity than SCO
// cannot use aec.Restore since DEC has better compatibility than SCO
_, _ = c.Write([]byte(Restore))
_, _ = c.Write([]byte(aec.Column(0).
With(aec.EraseLine(aec.EraseModes.All)).
Expand Down
12 changes: 6 additions & 6 deletions cmd/oras/internal/display/status/progress/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@
defer m.statusLock.RUnlock()
// todo: update size in another routine
width, height := m.console.Size()
len := len(m.status) * 2
statusLength := len(m.status) * 2
TerryHowe marked this conversation as resolved.
Show resolved Hide resolved
offset := 0
if len > height {
if statusLength > height {
// skip statuses that cannot be rendered
offset = len - height
offset = statusLength - height

Check warning on line 99 in cmd/oras/internal/display/status/progress/manager.go

View check run for this annotation

Codecov / codecov/patch

cmd/oras/internal/display/status/progress/manager.go#L99

Added line #L99 was not covered by tests
}

for ; offset < len; offset += 2 {
for ; offset < statusLength; offset += 2 {
status, progress := m.status[offset/2].String(width)
m.console.OutputTo(uint(len-offset), status)
m.console.OutputTo(uint(len-offset-1), progress)
m.console.OutputTo(uint(statusLength-offset), status)
m.console.OutputTo(uint(statusLength-offset-1), progress)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/internal/display/status/progress/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func Test_status_String(t *testing.T) {
}
}

func Test_status_String_zeroWitdth(t *testing.T) {
func Test_status_String_zeroWidth(t *testing.T) {
// zero status and progress
s := newStatus()
if status, digest := s.String(console.MinWidth); status != zeroStatus || digest != zeroDigest {
Expand Down
Loading