Skip to content

Commit

Permalink
Add negative filter for console (closes #261)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Nov 2, 2024
1 parent 88b7456 commit 37d71a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions docsSite/docs/tab-reference/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ Drag the desired field to the main view to get started. Each row represents an u

![Console view](./img/console-1.png)

The controls are similar to the 🔢 [Table](../tab-reference/table.md) tab. The selected time is synchronized across all tabs. Click a row to select it, or hover over a row to preview it in any visible pop-up windows. Clicking the ↓ button jumps to the selected time (or the time entered in the box). Enter text in the "Filter" input to only display rows which contain the filter text. Press **Ctrl+F** to quickly select the "Filter" input.

:::tip
Click the color palette icon to toggle highlighting for warning and error messages. Messages are highlighted if they contain the text "warning" or "error".
:::

The controls are similar to the 🔢 [Table](../tab-reference/table.md) tab. The selected time is synchronized across all tabs. Click a row to select it, or hover over a row to preview it in any visible pop-up windows. Clicking the ↓ button jumps to the selected time (or the time entered in the box). Enter text in the "Filter" input to only display rows which contain the filter text. Press **Ctrl+F** to quickly select the "Filter" input.

:::info
Adding a "!" at the start of the filter text will _exclude_ matching messages from the main view.
:::
10 changes: 7 additions & 3 deletions src/shared/renderers/ConsoleRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,16 @@ export default class ConsoleRenderer implements TabRenderer {
let timestamps = this.timestamps;
let values = this.values;
const filter = this.FILTER_INPUT.value.toLowerCase();
if (filter.length > 0) {
if (filter.startsWith("!") ? filter.length > 1 : filter.length > 0) {
let filteredTimestamps: number[] = [];
let filteredValues: string[] = [];
for (let i = 0; i < timestamps.length; i++) {
let value = values[i];
if (value.toLowerCase().includes(filter)) {
if (
filter.startsWith("!")
? !value.toLowerCase().includes(filter.slice(1).toLowerCase())
: value.toLowerCase().includes(filter.toLowerCase())
) {
filteredTimestamps.push(timestamps[i]);
filteredValues.push(value);
}
Expand Down Expand Up @@ -239,7 +243,7 @@ export default class ConsoleRenderer implements TabRenderer {
for (let i = 0; i < values.length; i++) {
// Format value
let valueFormatted = "";
if (filter.length > 0) {
if (filter.length > 0 && !filter.startsWith("!")) {
let lastPosition = -1;
let position = -1;
while (
Expand Down

0 comments on commit 37d71a6

Please sign in to comment.