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

-width is inaccurate #31

Open
Orum opened this issue Sep 27, 2020 · 2 comments · May be fixed by #147
Open

-width is inaccurate #31

Orum opened this issue Sep 27, 2020 · 2 comments · May be fixed by #147
Labels
bug Something isn't working

Comments

@Orum
Copy link

Orum commented Sep 27, 2020

If I use autodetection (the default), or specify my -width to the actual terminal width, duf will wrap before it uses the full width of the terminal. However, if I specify a width much larger than the terminal, the output is fine and still (in this case) fits within the terminal.

In other words, the width seems to be internally scaled to a smaller value than the terminal actually is.

@muesli muesli added the bug Something isn't working label Sep 27, 2020
@eciancio
Copy link

eciancio commented Sep 30, 2020

The first column's max width is explicitly set to be .4 * tableWidth. So It might wrap around before the table uses the full width of the terminal because the column has used its full WidthMax.

duf/table.go

Lines 58 to 61 in dac0c7d

twidth := tableWidth(cols, tab.Style().Options.SeparateColumns)
tab.SetColumnConfigs([]table.ColumnConfig{
{Number: 1, Hidden: !inColumns(cols, 1), WidthMax: int(float64(twidth) * 0.4)},

twidth is calculated using *width so when you specify -width to be larger, twidth gets larger so does the column's WithMax

duf/table.go

Lines 225 to 238 in dac0c7d

func tableWidth(cols []int, separators bool) int {
var sw int
if separators {
sw = 1
}
twidth := int(*width)
for i := 0; i < len(columns); i++ {
if inColumns(cols, i+1) {
twidth -= 2 + sw + columns[i].Width
}
}
return twidth

@yermulnik
Copy link

Observing the same behavior. Forcing duf to go beyond terminal width makes output smoother:
изображение

@mrngm mrngm linked a pull request Oct 31, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants