spring-projects / spring-shell

Spring based shell
http://projects.spring.io/spring-shell/
Apache License 2.0
719 stars 395 forks source link

Grid fixed item size goes to bottom right #1010

Closed jvalkeal closed 4 months ago

jvalkeal commented 6 months ago

Using GridView with zero column/row sizes causes item to be placed into bottom-right when user would expect it to go top-left:

Something like when doing tests:

BoxView box1 = new BoxView();
BoxView sbox1 = spy(box1);
GridView grid = new GridView();

grid.setShowBorders(false);
grid.setRowSize(1);
grid.setColumnSize(1);
grid.setShowBorder(false);
grid.addItem(sbox1, 0, 0, 1, 1, 0, 0);

grid.setRect(0, 0, 10, 10);
grid.draw(screen10x10);

verify(sbox1).setRect(0, 0, 1, 1);

For example:

+---------+
|         |
|         |
|        X|
+---------+

When it should be:

+---------+
|X        |
|         |
|         |
+---------+

Logic came from golang tview grid component and it looks like it's "conceptually" broken there as well.

jvalkeal commented 6 months ago

Trouble looks to be here:

https://github.com/spring-projects/spring-shell/blob/19f2570f8e33a683f1be382795e80992e99160d9/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/GridView.java#L533-L540

Need to think if making that configurable makes sense and drive logic through better tests.

jvalkeal commented 4 months ago

There was fix for this in tview where above lines were simply removed to fix the issue. We can probably do same.