When I have a Calc spreadsheet with multiple filled columns (3 columns) without adjustment, if I select one column (column B) and double click between columns header (A and B or C and D) to auto fit column width to content, the column not fit properly.
Steps to Reproduce:
1. Create a Calc spreadsheet with 3 filled columns without adjustment to their content;
2. Select one column (column B) and double click between columns header (A and B or C and D) to auto fit column width to content.
The column don't auto fit to it content, only selected column fit properly.
The column auto fit to it content.
User Profile Reset: No
Version: 18.104.22.168 (x86)
Build ID: c01aa64b6c3d89ebe5fe69c28c7adb24eb85249c
Threads da CPU: 8; SO: Windows 10.0 Build 19041; Realizador da interface: Skia/Vulkan; VCL: win
Locale: pt-BR (pt_BR); Interface: pt-BR
*** Bug 139482 has been marked as a duplicate of this bug. ***
NEW per duplicate
Possibly this is the consequence of the *intended* behavior, that selection defines the width. The idea is, that you can select (selection is not equal to focusing!) a cell or a cell range, and the auto-fit feature will consider the cells in the selection, ignoring cells outside. Note that when you select column B, and try to auto-fit column A, there is no cells in A that in the selection -> no cells must be taken into account, hence the width resets to a default.
Note also, that the discussed feature is broken since 4.1 (bug 148008).
Regardless of the bug 148008, I don't know if the behavior discussed here is bad, or is it actually reasonable and logical in the frame of the feature. IMO, it looks logical: a selection is present, and has no cells to consider for this column -> use a default. OTOH, in the same case, "-> use the widest cell" would be also a viable option...
Note that, no matter how this should resolve, the other case, when an *empty* cell in A is selected, A should continue to reset to a default.
*IIF* this is decided to be changed, here's a code pointer:
ScColumn::GetOptimalColWidth in sc/source/core/data/column2.cxx
When an existing selection doesn't cover the column in question, aMarkedSpans stays empty. The change could be to generalize the '"Select" the entire column if no selection exists' code to all cases when aMarkedSpans is empty after the previous check.