janisdd / vscode-edit-csv

vs code extension to edit csv files with an excel like table ui
MIT License
229 stars 35 forks source link

Hidden long comments inflate first column-width #107

Closed lurch closed 1 year ago

lurch commented 1 year ago

What OS?

Description

I have a CSV file with some very long comment-lines. which causes the first column in the CSV-editor to become ridiculously wide. If I select the option to hide comments (great feature!) the first column is still ridiculously wide.

Expected behavior

I'd expect the first column's width to shrink to the width of the longest cell in non-comment lines. Even if I double-click the column-separator between the first and second columns to auto-resize the column, it still adjusts the first column to the width of the longest (now-hidden) comment, rather than the the width of the longest (still visible) cell.

Steps to reproduce

See above.

janisdd commented 1 year ago

I'll look into that in a few week when another project is completed. Currently there is no special treatment of hidden comment rows (only height 0). Somehow the logic for cell size has to take comment cells into account.

janisdd commented 1 year ago

I'll need some more time (~3 weeks) until I can look into this (maybe sooner)...

janisdd commented 1 year ago

Found some time... there will be a new option autoColumnWithsIgnoreComments (defaults to true) that will ignore any comment cell from participating in the auto column size process.

The option enableWrapping might be also interesting to you, as the long comments will be wrap by default.

I just need to do some manual testing before releasing (should be in the next couple of days).

lurch commented 1 year ago

autoColumnWithsIgnoreComments should probably be autoColumnWidthsIgnoreComments? Same typo appears multiple times in the linked commit too.

janisdd commented 1 year ago

Ah, thanks for pointing that out, I would have missed it!

After some testing, I found that ignoring comment cells when option hide comments (or via button) is on might also be a good idea. So only one option has to be set: hide comments or autoColumnWidthsIgnoreComments to ignore the widths of comment cells.

lurch commented 1 year ago

Perfect, thank you! :clap:

The only thing that would make it better, is if when you clicked the "Hide comments" button the first column automatically shrank to the new max-width, instead of retaining the old max-width (i.e. when comments were still being shown).

janisdd commented 1 year ago

To me this seems a bit counter intuitive... why should the size of the column remain the same when the comments are hidden? After manually changing the column size, it will keep its size.

lurch commented 1 year ago

Sorry, perhaps I should clarify that I've not manually set the column size.

  1. I open a file with some really long comment lines, and the first column auto-resizes to accommodate this (which makes the first column width really huge)
  2. I click on the "Hide comments" button
  3. The first column width remains really huge, even though none of the visible (non-comment) cells are now this wide

In step 2. it would be nice if the column widths auto-resized again, to ignore the now-hidden comment lines. Does that make sense, or am I still explaining this badly?

janisdd commented 1 year ago

Completely misunderstood your comment, sorry. What you just described is exactly the new behavior (maybe you need to manually update to version 0.7.3, not sure when vs code checks for extension updates).