add sc:... search option

This commit is contained in:
llama 2025-07-01 07:59:11 +08:00
parent 2725dc4ce9
commit 0c9f5b0103
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3
3 changed files with 9 additions and 0 deletions

View file

@ -94,6 +94,7 @@ pub enum SearchNode {
WholeCollection, WholeCollection,
Regex(String), Regex(String),
NoCombining(String), NoCombining(String),
StripClozes(String),
WordBoundary(String), WordBoundary(String),
CustomData(String), CustomData(String),
Preset(String), Preset(String),
@ -358,6 +359,7 @@ fn search_node_for_text_with_argument<'a>(
"cid" => SearchNode::CardIds(check_id_list(val, key)?.into()), "cid" => SearchNode::CardIds(check_id_list(val, key)?.into()),
"re" => SearchNode::Regex(unescape_quotes(val)), "re" => SearchNode::Regex(unescape_quotes(val)),
"nc" => SearchNode::NoCombining(unescape(val)?), "nc" => SearchNode::NoCombining(unescape(val)?),
"sc" => SearchNode::StripClozes(unescape(val)?),
"w" => SearchNode::WordBoundary(unescape(val)?), "w" => SearchNode::WordBoundary(unescape(val)?),
"dupe" => parse_dupe(val)?, "dupe" => parse_dupe(val)?,
"has-cd" => SearchNode::CustomData(unescape(val)?), "has-cd" => SearchNode::CustomData(unescape(val)?),

View file

@ -147,6 +147,11 @@ impl SqlWriter<'_> {
SearchNode::NoCombining(text) => { SearchNode::NoCombining(text) => {
self.write_unqualified(&self.norm_note(text), true, false)? self.write_unqualified(&self.norm_note(text), true, false)?
} }
SearchNode::StripClozes(text) => self.write_unqualified(
&self.norm_note(text),
self.col.get_config_bool(BoolKey::IgnoreAccentsInSearch),
true,
)?,
SearchNode::WordBoundary(text) => self.write_word_boundary(&self.norm_note(text))?, SearchNode::WordBoundary(text) => self.write_word_boundary(&self.norm_note(text))?,
// other // other
@ -1020,6 +1025,7 @@ impl SearchNode {
SearchNode::Duplicates { .. } => RequiredTable::Notes, SearchNode::Duplicates { .. } => RequiredTable::Notes,
SearchNode::Regex(_) => RequiredTable::Notes, SearchNode::Regex(_) => RequiredTable::Notes,
SearchNode::NoCombining(_) => RequiredTable::Notes, SearchNode::NoCombining(_) => RequiredTable::Notes,
SearchNode::StripClozes(_) => RequiredTable::Notes,
SearchNode::WordBoundary(_) => RequiredTable::Notes, SearchNode::WordBoundary(_) => RequiredTable::Notes,
SearchNode::NotetypeId(_) => RequiredTable::Notes, SearchNode::NotetypeId(_) => RequiredTable::Notes,
SearchNode::Notetype(_) => RequiredTable::Notes, SearchNode::Notetype(_) => RequiredTable::Notes,

View file

@ -91,6 +91,7 @@ fn write_search_node(node: &SearchNode) -> String {
WholeCollection => "deck:*".to_string(), WholeCollection => "deck:*".to_string(),
Regex(s) => maybe_quote(&format!("re:{s}")), Regex(s) => maybe_quote(&format!("re:{s}")),
NoCombining(s) => maybe_quote(&format!("nc:{s}")), NoCombining(s) => maybe_quote(&format!("nc:{s}")),
StripClozes(s) => maybe_quote(&format!("sc:{s}")),
WordBoundary(s) => maybe_quote(&format!("w:{s}")), WordBoundary(s) => maybe_quote(&format!("w:{s}")),
CustomData(k) => maybe_quote(&format!("has-cd:{k}")), CustomData(k) => maybe_quote(&format!("has-cd:{k}")),
Preset(s) => maybe_quote(&format!("preset:{s}")), Preset(s) => maybe_quote(&format!("preset:{s}")),