mirror of
https://github.com/ankitects/anki.git
synced 2025-11-16 17:47:11 -05:00
feat: add support for tag:nc:... searches
This commit is contained in:
parent
3890e12c9e
commit
e506446224
2 changed files with 18 additions and 2 deletions
|
|
@ -392,6 +392,11 @@ fn parse_tag(s: &str) -> ParseResult<'_, SearchNode> {
|
|||
tag: unescape_quotes(re),
|
||||
mode: FieldSearchMode::Regex,
|
||||
}
|
||||
} else if let Some(nc) = s.strip_prefix("nc:") {
|
||||
SearchNode::Tag {
|
||||
tag: unescape(nc)?,
|
||||
mode: FieldSearchMode::NoCombining,
|
||||
}
|
||||
} else {
|
||||
SearchNode::Tag {
|
||||
tag: unescape(s)?,
|
||||
|
|
|
|||
|
|
@ -311,8 +311,19 @@ impl SqlWriter<'_> {
|
|||
}
|
||||
s if s.contains(' ') => write!(self.sql, "false").unwrap(),
|
||||
text => {
|
||||
write!(self.sql, "n.tags regexp ?").unwrap();
|
||||
let re = &to_custom_re(text, r"\S");
|
||||
let text = if mode == FieldSearchMode::Normal {
|
||||
write!(self.sql, "n.tags regexp ?").unwrap();
|
||||
Cow::from(text)
|
||||
} else {
|
||||
write!(
|
||||
self.sql,
|
||||
"coalesce(process_text(n.tags, {}), n.tags) regexp ?",
|
||||
ProcessTextFlags::NoCombining.bits()
|
||||
)
|
||||
.unwrap();
|
||||
without_combining(text)
|
||||
};
|
||||
let re = &to_custom_re(&text, r"\S");
|
||||
self.args.push(format!("(?i).* {re}(::| ).*"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue