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

Dynamic resizing no longer works #730

Closed
ptxmac opened this issue Oct 30, 2019 · 9 comments · Fixed by #738 or #740
Closed

Dynamic resizing no longer works #730

ptxmac opened this issue Oct 30, 2019 · 9 comments · Fixed by #738 or #740
Labels
🐛 bug "Houston, we've had a problem."

Comments

@ptxmac
Copy link

ptxmac commented Oct 30, 2019

What's broken?

Setting columns/rows to empty lists should allow wtfutil to dynamically resize to fit the current terminal according to: #85 and #573

When trying this setup from master it gives the following panic:

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/wtfutil/wtf/utils.CalculateDimensions(0xc00056b5c0, 0xc00056b040, 0x8, 0xc00068f2a8)
	/home/ptx/Projects/github.com/wtfutil/wtf/utils/utils.go:149 +0x400
github.com/wtfutil/wtf/modules/cmdrunner.NewSettingsFromYAML(0xc0003b3564, 0x5, 0xc00056b5c0, 0xc00056b040, 0x0)
	/home/ptx/Projects/github.com/wtfutil/wtf/modules/cmdrunner/settings.go:40 +0x2d1
github.com/wtfutil/wtf/app.MakeWidget(0xc0005a7700, 0xc0003fb260, 0xc0003b3564, 0x5, 0xc00056b040, 0x0, 0xc000369e38)
	/home/ptx/Projects/github.com/wtfutil/wtf/app/widget_maker.go:116 +0x205a
github.com/wtfutil/wtf/app.MakeWidgets(0xc0005a7700, 0xc0003fb260, 0xc00056b040, 0xc00068fd60, 0x1, 0x1)
	/home/ptx/Projects/github.com/wtfutil/wtf/app/widget_maker.go:274 +0x142
github.com/wtfutil/wtf/app.NewWtfApp(0xc0005a7700, 0xc00056b040, 0xc00026ebe0, 0x20, 0x1)
	/home/ptx/Projects/github.com/wtfutil/wtf/app/wtf_app.go:47 +0x2ec
main.main()
	/home/ptx/Projects/github.com/wtfutil/wtf/main.go:70 +0x34c
@senorprogrammer senorprogrammer added the 🐛 bug "Houston, we've had a problem." label Oct 30, 2019
@senorprogrammer
Copy link
Collaborator

This is related to the CalculateDimensions function, which was recently added. Thanks for reporting this.

@ptxmac
Copy link
Author

ptxmac commented Nov 9, 2019

Closed by mistake - this is still an open issue

@senorprogrammer
Copy link
Collaborator

senorprogrammer commented Nov 9, 2019

@ptxmac Did you pull latest master? This config https://github.com/wtfutil/wtf/blob/master/_sample_configs/dynamic_sizing.yml was added that has no color key or grid key. Could you give it a try and see if it works locally?

    go run . --config=_sample_configs/dynamic_sizing.yml

Also, could you post the top part of your config, from wtf: to modules:? Nothing in that section should be sensitive. If there is sensitive data, remove it first.

senorprogrammer added a commit that referenced this issue Nov 9, 2019
@senorprogrammer
Copy link
Collaborator

I'm able to replicate the issue.

@ptxmac
Copy link
Author

ptxmac commented Nov 9, 2019

I just used the default config on a clean install and set the rows / columns fields to empty lists

senorprogrammer added a commit that referenced this issue Nov 9, 2019
@senorprogrammer
Copy link
Collaborator

Give master a try now, should be fixed with the latest commit.

@ptxmac
Copy link
Author

ptxmac commented Nov 9, 2019

Still crashes

$ go run main.go
panic: runtime error: slice bounds out of range [-1:]

goroutine 1 [running]:
github.com/wtfutil/wtf/utils.CalculateDimensions(0xc0006705e0, 0xc000670520, 0x8, 0xc00044d258, 0x1, 0x1)
	/home/ptx/Projects/github.com/wtfutil/wtf/utils/utils.go:154 +0x4b1
github.com/wtfutil/wtf/modules/cmdrunner.NewSettingsFromYAML(0xc00038f400, 0x6, 0xc0006705e0, 0xc000670520, 0x0)
	/home/ptx/Projects/github.com/wtfutil/wtf/modules/cmdrunner/settings.go:39 +0x2d5
github.com/wtfutil/wtf/app.MakeWidget(0xc00062cb00, 0xc00063dd70, 0xc00038f400, 0x6, 0xc000670520, 0x0, 0xc00038f620)
	/home/ptx/Projects/github.com/wtfutil/wtf/app/widget_maker.go:116 +0x205a
github.com/wtfutil/wtf/app.MakeWidgets(0xc00062cb00, 0xc00063dd70, 0xc000670520, 0x8, 0x31ea2d0, 0x0)
	/home/ptx/Projects/github.com/wtfutil/wtf/app/widget_maker.go:274 +0x12a
github.com/wtfutil/wtf/app.NewWtfApp(0xc00062cb00, 0xc000670520, 0xc0002eca80, 0x20, 0x1)
	/home/ptx/Projects/github.com/wtfutil/wtf/app/wtf_app.go:45 +0x260
main.main()
	/home/ptx/Projects/github.com/wtfutil/wtf/main.go:70 +0x360

config

$ head ~/.config/wtf/config.yml 
wtf:
  colors:
    border:
      focusable: darkslateblue
      focused: orange
      normal: gray
  grid:
    columns: []
    rows: []
  refreshInterval: 1

git

$ git log -1
commit b2093314f0b2697d9c1fc8af1322f224a90ba235 (HEAD -> master, origin/master, origin/HEAD)
Author: Chris Cummer <[email protected]>
Date:   Sat Nov 9 14:13:47 2019 -0800

    Fix grid: key issue when key is present
    
    Really do need it to work with and without a grid: key.
    
    Signed-off-by: Chris Cummer <[email protected]>

@ptxmac
Copy link
Author

ptxmac commented Nov 9, 2019

Removing the grid key works - but I was basing my config on examples from previous issues about how to add auto-resizing

@senorprogrammer
Copy link
Collaborator

Yeah, having

  grid:
    columns: []
    rows: []

won't work. That's telling it to have no columns. That will always fail, but it could do so far more gracefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug "Houston, we've had a problem."
2 participants