Skip to content

Issue #180 column number fix#185

Open
giantatwork wants to merge 6 commits intoYS-L:mainfrom
giantatwork:current_selected_column
Open

Issue #180 column number fix#185
giantatwork wants to merge 6 commits intoYS-L:mainfrom
giantatwork:current_selected_column

Conversation

@giantatwork
Copy link
Copy Markdown
Contributor

Hello @YS-L,

This PR tries to fix the problem described in #180.
Please let me know if this is the right fix for this problem.

Kind regards,

Previous behavior: the status bar “Col” value always showed the scroll offset (first visible non-frozen column as 1). In column mode this often lagged or restarted on viewport scrolls, and didn’t reflect the selected column. In wrapped/filtered views it stayed offset-based.

New behavior: the status bar shows the actual selected column number when in cell mode (row + column), with line wrap off and no active filter; otherwise it keeps the offset-based display for consistency in row/column-only modes, wrapped views, and filters. This makes column numbers update correctly during navigation while preserving expected wrapped/filter behavior.

Copy link
Copy Markdown

@stsymbaliuk stsymbaliuk left a comment

Choose a reason for hiding this comment

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

Hi @giantatwork,
I've verified current commit on my PC and it partly fixes the issue #180 .
With the commit:

  • in cell selection mode the current column displayed as expected in the issue;
  • in column selection mode behavior stays the same as in the ticket and the current column displays the first visible column on the left and not the real selected column.

col_status_bar_185

And about the commit header "fix issue #180". Please update it to show that this commit fixes the current selected column in the status bar. So it will be easier to see the commit purpose in the git log.

@giantatwork
Copy link
Copy Markdown
Contributor Author

@stsymbaliuk

in column selection mode behavior stays the same as in the ticket and the current column displays the first visible column on the left and not the real selected column

Please check out my latest changes to see if this problem is fixed now.

@stsymbaliuk
Copy link
Copy Markdown

stsymbaliuk commented Jan 4, 2026

Thank you @giantatwork,
With the last changes current column displayed as expected when no rows or columns filters applied.

But I've checked behavior when rows filter (&) or columns filter (*) applied.

"Col" in status bar does not work as expected

After column filter (*city_ascii|state|county) applied "Col" in status bar shows current column number in filtered view. Also the total column number from the original file changed to total columns number if the filtered view.

Steps:

  • Open uscities.csv (simplemaps_uscities_basicv1.92.zip) file;
  • Switch to cell selection mode and select Cell on Row 1 / Col 1;
  • Apply column filter (*) city_ascii|state|county;
  • Current behavior: "[Row 1/31254, Col 1/5] [Filter "(?i)city_ascii|state|county": 5/17 cols]" in status bar;
  • Expected behavior: "[Row 1/31254, Col 2/17] [Filter "(?i)city_ascii|state|county": 1/5 cols]" in status bar;
    col_status_bar_185_2_col

For reference "Row" in status bar has expected behavior

When applied rows filter (&New) "Row" in status bar shows position in original file and not in filtered view. Total number of rows 31254 stays the same even after the rows filter is applied: "[Row 1/31254, Col 1/17] [Filter "New" in city: 1/416]".
col_status_bar_185_2_row

@giantatwork
Copy link
Copy Markdown
Contributor Author

@stsymbaliuk

"Col" in status bar does not work as expected

Please check my latest changes to see if the column numbering issue in filter mode is now fixed.

@stsymbaliuk
Copy link
Copy Markdown

Hi @giantatwork,
Yes, with the latest changes "Col" works as expected in column filtered mode.
Also in column filtered mode status bar shows current filter state ([Filter "(?i)city_ascii|state|county": 1/5 cols]). And it should show the current position in the filtered view and number of columns after filtering. But the current position in the filtered view displayed incorrectly.

Steps:

  • Open uscities.csv (simplemaps_uscities_basicv1.92.zip) file;
  • Switch to cell selection mode and select Cell on Row 1 / Col 1;
  • Apply column filter (*) city_ascii|state|county;
  • Current behavior: "[Row 1/31254, Col 2/17] [Filter "(?i)city_ascii|state|county": 5/17 cols]" in status bar;
  • Expected behavior: "[Row 1/31254, Col 2/17] [Filter "(?i)city_ascii|state|county": 1/5 cols]" in status bar;

@stsymbaliuk
Copy link
Copy Markdown

Thank you @giantatwork,
I can confirm that with last changes (3181ec0):

  • "Col" in status bar works as expected in cell, column, and row selection mode;
  • Current column and row in the filtered view displayed correctly when columns and rows filters are applied.

Copy link
Copy Markdown
Owner

@YS-L YS-L left a comment

Choose a reason for hiding this comment

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

Thanks @giantatwork for the PR!

I think the logic added to ui.rs is getting a bit too complex. Ideally, that module should focus purely on rendering. If more complex data massaging is needed before rendering, it would be better to prepare that information externally and pass it in.

// - Line wrap is off
// - We're in cell or column selection mode
// Otherwise fall back to the scroll offset.
let use_selection_col = !state.enable_line_wrap
Copy link
Copy Markdown
Owner

@YS-L YS-L Jan 7, 2026

Choose a reason for hiding this comment

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

I'm not sure why enabling / disabling line wrap should change the behavior here. Could you clarify?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

After checking "Col" behavior with -S (Toggle line wrapping) or with -W (Toggle line wrapping by words) I can see that "Col" does not show the currently selected column in Cell or Column selection mode. The next quick change fixed the issue for me.

diff --git a/src/ui.rs b/src/ui.rs
index 02e576a..c0e4f8a 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -804,7 +804,8 @@ impl<'a> CsvTable<'a> {
             // - Line wrap is off
             // - We're in cell or column selection mode
             // Otherwise fall back to the scroll offset.
-            let use_selection_col = !state.enable_line_wrap
+            let use_selection_col = true
                 && matches!(
                     state.selection.as_ref().map(|s| s.selection_type()),
                     Some(view::SelectionType::Cell | view::SelectionType::Column)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Upon further review, I believe this condition is redundant and can be removed.

if self.disabled_because_no_match {
line += "no match, showing all columns]";
} else {
line += format!("{}/{} cols]", self.shown, self.total).as_str();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This was actually intended to be simple static information about the number of matches, independent of the selected column.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This was actually intended to be simple static information about the number of matches, independent of the selected column.

In my opinion original implementation for Filter Column status was not consistent with Filter Rows status.
For example when Rows Filter &New and Columns Filter *city_ascii|state|county applied at the same time we can see status for both of them. And Filter Rows status dynamically shows the current selected row and number of row matches. So to be consistent Filter Column status should show selected column and number of column matches as currently implemented in 3181ec0

[Row 575/31254, Col 2/17] [Filter "New" in city_ascii: 11/416] [Filter "city_ascii|state|county": 1/5 cols]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ah that makes sense to me now. Thanks for clarifying!

@giantatwork
Copy link
Copy Markdown
Contributor Author

Thanks @giantatwork for the PR!

I think the logic added to ui.rs is getting a bit too complex. Ideally, that module should focus purely on rendering. If more complex data massaging is needed before rendering, it would be better to prepare that information externally and pass it in.

I agree that this logic should be moved to a file other than ui.rs.
Should I further investigate this, any suggestions?

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.

3 participants