mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Merge 61664762f3
into 3890e12c9e
This commit is contained in:
commit
0df17257f3
3 changed files with 21 additions and 2 deletions
|
@ -32,6 +32,7 @@ def test_find_cards():
|
||||||
note = col.newNote()
|
note = col.newNote()
|
||||||
note["Front"] = "cat"
|
note["Front"] = "cat"
|
||||||
note["Back"] = "sheep"
|
note["Back"] = "sheep"
|
||||||
|
note.tags.append("conjunção größte")
|
||||||
col.addNote(note)
|
col.addNote(note)
|
||||||
catCard = note.cards()[0]
|
catCard = note.cards()[0]
|
||||||
m = col.models.current()
|
m = col.models.current()
|
||||||
|
@ -68,6 +69,8 @@ def test_find_cards():
|
||||||
col.tags.bulk_remove(col.db.list("select id from notes"), "foo")
|
col.tags.bulk_remove(col.db.list("select id from notes"), "foo")
|
||||||
assert len(col.find_cards("tag:foo")) == 0
|
assert len(col.find_cards("tag:foo")) == 0
|
||||||
assert len(col.find_cards("tag:bar")) == 5
|
assert len(col.find_cards("tag:bar")) == 5
|
||||||
|
assert len(col.find_cards("tag:conjuncao tag:groste")) == 0
|
||||||
|
assert len(col.find_cards("tag:nc:conjuncao tag:nc:groste")) == 1
|
||||||
# text searches
|
# text searches
|
||||||
assert len(col.find_cards("cat")) == 2
|
assert len(col.find_cards("cat")) == 2
|
||||||
assert len(col.find_cards("cat -dog")) == 1
|
assert len(col.find_cards("cat -dog")) == 1
|
||||||
|
|
|
@ -392,6 +392,11 @@ fn parse_tag(s: &str) -> ParseResult<'_, SearchNode> {
|
||||||
tag: unescape_quotes(re),
|
tag: unescape_quotes(re),
|
||||||
mode: FieldSearchMode::Regex,
|
mode: FieldSearchMode::Regex,
|
||||||
}
|
}
|
||||||
|
} else if let Some(nc) = s.strip_prefix("nc:") {
|
||||||
|
SearchNode::Tag {
|
||||||
|
tag: unescape(nc)?,
|
||||||
|
mode: FieldSearchMode::NoCombining,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SearchNode::Tag {
|
SearchNode::Tag {
|
||||||
tag: unescape(s)?,
|
tag: unescape(s)?,
|
||||||
|
|
|
@ -311,8 +311,19 @@ impl SqlWriter<'_> {
|
||||||
}
|
}
|
||||||
s if s.contains(' ') => write!(self.sql, "false").unwrap(),
|
s if s.contains(' ') => write!(self.sql, "false").unwrap(),
|
||||||
text => {
|
text => {
|
||||||
write!(self.sql, "n.tags regexp ?").unwrap();
|
let text = if mode == FieldSearchMode::Normal {
|
||||||
let re = &to_custom_re(text, r"\S");
|
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}(::| ).*"));
|
self.args.push(format!("(?i).* {re}(::| ).*"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue