For deck searches, unescape quotes only

For now, revert to the old handling of deck names using text_to_re from
text.rs and have parser.rs only unescape quotes.
This commit is contained in:
RumovZ 2020-11-14 18:32:41 +01:00
parent b186e61e54
commit 3949996728
2 changed files with 3 additions and 2 deletions

View File

@ -69,7 +69,7 @@ pub(super) enum SearchNode<'a> {
AddedInDays(u32),
EditedInDays(u32),
CardTemplate(TemplateKind<'a>),
Deck(String),
Deck(Cow<'a, str>),
DeckID(DeckID),
NoteTypeID(NoteTypeID),
NoteType(OptionalRe<'a>),
@ -280,7 +280,7 @@ fn search_node_for_text_with_argument<'a>(
Ok(match key.to_ascii_lowercase().as_str() {
"added" => SearchNode::AddedInDays(val.parse()?),
"edited" => SearchNode::EditedInDays(val.parse()?),
"deck" => SearchNode::Deck(unescape_to_enforced_re(val)?),
"deck" => SearchNode::Deck(unescape_quotes(val)),
"note" => SearchNode::NoteType(unescape_to_re(val)?),
"tag" => SearchNode::Tag(parse_tag(val)?),
"mid" => SearchNode::NoteTypeID(val.parse()?),

View File

@ -319,6 +319,7 @@ impl SqlWriter<'_> {
};
// convert to a regex that includes child decks
// fixme: use unescape_to_enforced_re from parser.rs?
let re = text_to_re(&native_deck);
self.args.push(format!("(?i)^{}($|\x1f)", re));
let arg_idx = self.args.len();