Skip to content

Read a spaced filter condition as one condition, and clear the box from one x - #21

Merged
ww-mw merged 4 commits into
mainfrom
filter-chip-styling
Sep 17, 2026
Merged

ww-mw merged 4 commits into
mainfrom
filter-chip-styling

Conversation

@ww-mw

@ww-mw ww-mw commented Sep 17, 2026

Copy link
Copy Markdown
Member

Four follow-ups to the filter-chip work in #20, all in the search box.

A condition that contains whitespace is one condition. The tokenizer split on whitespace before it looked for an operator, so a condition written the way a person writes one fragmented:

typed before now
Data Type:double bare word Data AND Type:double one Data Type condition
data type: double Data Type: (empty) AND bare double one Data Type condition
Value > 5 three bare words one Value > 5 condition

One scanner now reads <column> <op> <value> across the seams, and the token's span covers the whole condition, so its chip's x removes every part of it. This engages only once the prefix resolves to a real column of that table, which is what keeps a > b and Name gain ordinary text; a following condition is never swallowed as a value, so Unit= Value>5 still parses as two.

The cost, pinned in a test: Unit= abc now means Unit equals abc rather than "no Unit, and abc somewhere". Asking for empty cells still works -- leave nothing after the operator.

A clear-all x at the right end of the box. Escape already cleared the box, but only for someone who knows that; with a mouse, emptying a search meant removing each chip in turn. One press drops the applied filter and whatever was half-typed, and hands focus back to the input. It is absent while the box is empty, and clearing a pending tail alone proposes nothing -- abandoning a half-typed word stays a local edit, as Escape's first press already worked.

Styling. Smaller chip and bar border radius, tighter bar padding.

There are now two code paths that can read a condition (the scanner, and the per-chunk one that still handles a quoted prefix like "Data Type":double). A test pins the invariant between them: Data Type=double, Data Type = double, Data Type =double and "Data Type"=double all parse to the same column, operator and value.

Testing

  • npm run typecheck clean; npm test 2476 tests / 140 files pass (16 new, in test/rowFilter.test.ts and test/filterBar.test.ts); npm run build and npm run build:web clean.
  • End-to-end against the built dist/webview/table.js in Chromium: each row of the table above verified as chips + filtered rows + <mark> highlighting, plus Data Type: "fixed point", the legacy Value: > 5, and the clear-all button through all four of its states. The x was checked under emulated forced-colors, where it renders in the system text colour.

A space split the label, so `Data Type:double` parsed as the bare word `Data`
ANDed with `Type:double` — a stray condition the user never typed, with a chip
that looked correct. The tokenizer now recognizes a header label containing a
space when an operator follows it, so the prefix can be typed the way the header
spells it. Quoting it still works, and the same words with no operator after them
are still two words to search for.
`data type: double` split on whitespace into `data`, `type:` and `double`,
so the query silently ANDed two words the user never meant to search for
onto a condition that had lost its value. `Value > 5` had the same fault.

Whitespace inside a condition is now insignificant: one scanner reads
<column> <op> <value> across the seams, and a condition's chip spans the
whole thing so its `x` removes every part of it. This only applies once
the prefix resolves to a real column of the table, which is what keeps
`a > b` and `Name gain` ordinary text.

The cost, pinned in a test: `Unit= abc` now means Unit equals abc rather
than "no Unit, and abc somewhere". Asking for empty cells still works --
leave nothing after the operator.
Escape clears the box, but only for someone who knows that; with a mouse,
emptying a search meant removing each chip in turn. A x at the right end
of the bar now drops the applied filter and whatever was half-typed in
one press, and hands focus back to the input so the next search can just
be typed.

It is absent while the box is empty -- a x with nothing to clear sits
exactly where the eye looks for one that does something. Clearing a
pending tail alone proposes nothing, so "abandon what I was typing"
stays a local edit no consumer hears about, the way Escape's first press
already worked.
@ww-mw
ww-mw merged commit f3e98f6 into main Sep 17, 2026
1 check passed
@ww-mw
ww-mw deleted the filter-chip-styling branch September 17, 2026 19:14
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