Skip to content

Commit

Permalink
Data Explorer: Add basic implementation of "not contains" search type (
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm authored Sep 11, 2024
1 parent ce93e82 commit 398cfb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/amalthea/src/comm/data_explorer_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,10 @@ pub enum TextSearchType {
#[strum(to_string = "contains")]
Contains,

#[serde(rename = "not_contains")]
#[strum(to_string = "not_contains")]
NotContains,

#[serde(rename = "starts_with")]
#[strum(to_string = "starts_with")]
StartsWith,
Expand Down
6 changes: 6 additions & 0 deletions crates/ark/src/modules/positron/r_data_explorer.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ col_filter_indices <- function(col, idx = NULL) {
grepl(pattern = escaped_term, col, fixed = FALSE, ignore.case = !params$case_sensitive)
}

# Search for the term not contained in the column's values
else if (identical(params$search_type, "not_contains")) {
escaped_term <- .ps.regex_escape(params$term)
!grepl(pattern = escaped_term, col, fixed = FALSE, ignore.case = !params$case_sensitive)
}

# Search for the term at the beginning of the column's values
else if (identical(params$search_type, "starts_with")) {
escaped_term <- .ps.regex_escape(params$term)
Expand Down

0 comments on commit 398cfb9

Please sign in to comment.