Repository navigation
Conversation
Pressing & prompts for a substring and hides all data rows that do not contain it (similar to & filtering in less). This makes it easy to narrow down wide tables (e.g. \d+ output) to rows of interest. - new cmd_Filter command bound to & and a Filter rows menu item - filter pattern stored in ScrDesc and preserved across re-layout - window_fill skips non-matching data rows while keeping the header and footer windows intact - cursor navigation (j/k/g/G) jumps between matching rows - an empty pattern clears the filter and restores all rows
Owner
|
I am not against this feature, but I think it needs more thinking about cursor, and first row (on the screen) positioning. Your simple implementation can produce some unwanted visual artefacts. Probably it needs an alternative total_rows, and switching when filter is active. Everything should to work although the cursors can be invisible (deactivated). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'd like to propose a small feature: client-side row filtering.
Motivation
When inspecting wide tables (e.g. \d+ output, CSV, or query results),
it is often useful to temporarily hide every row that does not match a
substring, to focus on the rows of interest. The
lesspager offersexactly this with its
&command.Proposed behavior
&prompts for a substring (same prompt UX as the/search).rows are hidden. The header, footer and corner windows stay intact.
j/k/g/G) moves between matching rows.&then Enter) clears the filter and restoresall rows.
ignore_caseoption.Implementation
I have a working implementation ready. It:
cmd_Filtercommand bound to&plus a "Filter rows" menu item,ScrDesc(so it survives re-layout),window_fillskip non-matching data rows, deriving the rownumber and cursor position from the real line number so rownum/cursor
stay in sync.
Known limitations:
ignore_caseonly (no smart-caseignore_lower_caseheuristic like search)."Pattern not found" notice; clear it with an empty pattern.
A patch is attached / a pull request is available if you are
interested. Would you be open to accepting such a feature?