Skip to content

Conversation

@DavidWiseman
Copy link
Collaborator

Allow columns to use more space if available.

Allow columns to use more space if available.
Copilot AI review requested due to automatic review settings October 20, 2025 17:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if (visibleColumns.Count == 0) return;

var colCount = visibleColumns.Count;
var capRatio = Math.Max(columnWidthCapRatio ?? DefaultColumnWidthCapRatio, 1f / colCount);
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Math.Max logic is inverted. When there are few columns (e.g., 2 columns = 0.5), this caps each column at 50% instead of the intended 15%. It should use Math.Min to ensure the cap doesn't exceed the default ratio: Math.Min(columnWidthCapRatio ?? DefaultColumnWidthCapRatio, 1f / colCount).

Suggested change
var capRatio = Math.Max(columnWidthCapRatio ?? DefaultColumnWidthCapRatio, 1f / colCount);
var capRatio = Math.Min(columnWidthCapRatio ?? DefaultColumnWidthCapRatio, 1f / colCount);

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what is intended. If there are only 2 columns, no need to cap at 15%. If there are 100 columns, we want the cap to be 15% instead of 1% to ensure the columns are reasonably sized (though we might need to scroll).

Comment on lines +97 to +100
foreach (var col in cappedColumns)
{
// Only grow up to the original auto-sized width
var newWidth = Math.Min(col.Width + extraPerColumn, columnWidths[col]);
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integer division discards the remainder, potentially leaving unused space. For example, with 100px unused space and 3 capped columns, this allocates only 33px per column, leaving 1px unused. Convert to int after the division or accumulate the remainder: var extraPerColumn = Convert.ToInt32((double)unusedSpace / cappedColumns.Count);

Suggested change
foreach (var col in cappedColumns)
{
// Only grow up to the original auto-sized width
var newWidth = Math.Min(col.Width + extraPerColumn, columnWidths[col]);
var remainder = unusedSpace % cappedColumns.Count;
for (int i = 0; i < cappedColumns.Count; i++)
{
var col = cappedColumns[i];
// Distribute remainder pixels to the first 'remainder' columns
var addPixel = i < remainder ? 1 : 0;
var newWidth = Math.Min(col.Width + extraPerColumn + addPixel, columnWidths[col]);

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably overkill.

@DavidWiseman DavidWiseman merged commit 0a4231c into trimble-oss:main Oct 20, 2025
@DavidWiseman DavidWiseman deleted the ColumnAutoResizeFix branch October 20, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant