Add tests for search option.
This commit is contained in:
parent
d126488891
commit
135ca133ea
@ -10,3 +10,4 @@ rem)]]
|
|||||||
# These become fuzzy
|
# These become fuzzy
|
||||||
[[(foo) ]]
|
[[(foo) ]]
|
||||||
[[ (foo)]]
|
[[ (foo)]]
|
||||||
|
[[(foo)::3]]
|
||||||
|
@ -2,3 +2,5 @@
|
|||||||
|
|
||||||
[[#fo
|
[[#fo
|
||||||
o]]
|
o]]
|
||||||
|
|
||||||
|
[[#foo::3]]
|
||||||
|
@ -2,3 +2,15 @@
|
|||||||
|
|
||||||
[[file:simp
|
[[file:simp
|
||||||
le.org]]
|
le.org]]
|
||||||
|
|
||||||
|
[[file:simple.org::3]]
|
||||||
|
[[file:simple.org::foo]]
|
||||||
|
[[file:simple.org::#foo]]
|
||||||
|
[[file:simple.org::foo bar]]
|
||||||
|
[[file:simple.org::foo
|
||||||
|
bar]]
|
||||||
|
[[file:simple.org::foo
|
||||||
|
bar]]
|
||||||
|
[[file:simple.org::foo
|
||||||
|
bar]]
|
||||||
|
[[file:simple.org::foo::bar]]
|
||||||
|
@ -2,3 +2,5 @@
|
|||||||
|
|
||||||
[[eli
|
[[eli
|
||||||
sp.org]]
|
sp.org]]
|
||||||
|
|
||||||
|
[[elisp.org::3]]
|
||||||
|
@ -2,3 +2,5 @@
|
|||||||
|
|
||||||
[[id:83986bdf-987c-465d
|
[[id:83986bdf-987c-465d
|
||||||
-8851-44cb4c02a86c]]
|
-8851-44cb4c02a86c]]
|
||||||
|
|
||||||
|
[[id:83986bdf-987c-465d-8851-44cb4c02a86c::foo]]
|
||||||
|
@ -2,3 +2,5 @@
|
|||||||
|
|
||||||
[[shell:fo
|
[[shell:fo
|
||||||
o]]
|
o]]
|
||||||
|
|
||||||
|
[[shell:foo::3]]
|
||||||
|
@ -2805,8 +2805,8 @@ fn compare_regular_link<'b, 's>(
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":search-option"),
|
EmacsField::Required(":search-option"),
|
||||||
compare_identity,
|
|r| r.search_option,
|
||||||
compare_property_always_nil
|
compare_property_quoted_string
|
||||||
)
|
)
|
||||||
)? {
|
)? {
|
||||||
this_status = new_status;
|
this_status = new_status;
|
||||||
|
@ -6,7 +6,9 @@ use nom::bytes::complete::take_until;
|
|||||||
use nom::character::complete::anychar;
|
use nom::character::complete::anychar;
|
||||||
use nom::combinator::consumed;
|
use nom::combinator::consumed;
|
||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
|
use nom::combinator::map;
|
||||||
use nom::combinator::map_parser;
|
use nom::combinator::map_parser;
|
||||||
|
use nom::combinator::opt;
|
||||||
use nom::combinator::peek;
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::rest;
|
use nom::combinator::rest;
|
||||||
@ -58,6 +60,7 @@ fn regular_link_without_description<'b, 'g, 'r, 's>(
|
|||||||
link_type: path.link_type,
|
link_type: path.link_type,
|
||||||
path: path.path,
|
path: path.path,
|
||||||
raw_link: path.raw_link,
|
raw_link: path.raw_link,
|
||||||
|
search_option: path.search_option,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -82,6 +85,7 @@ fn regular_link_with_description<'b, 'g, 'r, 's>(
|
|||||||
link_type: path.link_type,
|
link_type: path.link_type,
|
||||||
path: path.path,
|
path: path.path,
|
||||||
raw_link: path.raw_link,
|
raw_link: path.raw_link,
|
||||||
|
search_option: path.search_option,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -90,6 +94,7 @@ struct PathReg<'s> {
|
|||||||
link_type: LinkType<'s>,
|
link_type: LinkType<'s>,
|
||||||
path: &'s str,
|
path: &'s str,
|
||||||
raw_link: &'s str,
|
raw_link: &'s str,
|
||||||
|
search_option: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
@ -123,13 +128,20 @@ fn parse_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn file_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
|
fn file_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
|
||||||
let (remaining, (raw_link, (_, path))) = consumed(tuple((tag("file:"), rest)))(input)?;
|
let (remaining, (raw_link, (_, path, search_option))) = consumed(tuple((
|
||||||
|
tag("file:"),
|
||||||
|
recognize(many_till(anychar, alt((peek(tag("::")), eof)))),
|
||||||
|
opt(map(tuple((tag("::"), rest)), |(_, search_option)| {
|
||||||
|
search_option
|
||||||
|
})),
|
||||||
|
)))(input)?;
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
PathReg {
|
PathReg {
|
||||||
link_type: LinkType::File,
|
link_type: LinkType::File,
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
|
search_option: search_option.map(Into::<&str>::into),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -142,6 +154,7 @@ fn id_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
|
|||||||
link_type: LinkType::Id,
|
link_type: LinkType::Id,
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
|
search_option: None,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -154,6 +167,7 @@ fn custom_id_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s
|
|||||||
link_type: LinkType::CustomId,
|
link_type: LinkType::CustomId,
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
|
search_option: None,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -170,6 +184,7 @@ fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>
|
|||||||
link_type: LinkType::CodeRef,
|
link_type: LinkType::CodeRef,
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
|
search_option: None,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -183,6 +198,7 @@ fn protocol_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>
|
|||||||
link_type: LinkType::Protocol(protocol.into()),
|
link_type: LinkType::Protocol(protocol.into()),
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
raw_link: raw_link.into(),
|
raw_link: raw_link.into(),
|
||||||
|
search_option: None,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -195,6 +211,7 @@ fn fuzzy_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
|
|||||||
link_type: LinkType::Fuzzy,
|
link_type: LinkType::Fuzzy,
|
||||||
path: body.into(),
|
path: body.into(),
|
||||||
raw_link: body.into(),
|
raw_link: body.into(),
|
||||||
|
search_option: None,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ pub struct RegularLink<'s> {
|
|||||||
pub link_type: LinkType<'s>,
|
pub link_type: LinkType<'s>,
|
||||||
pub path: &'s str,
|
pub path: &'s str,
|
||||||
pub raw_link: &'s str,
|
pub raw_link: &'s str,
|
||||||
|
pub search_option: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
Loading…
Reference in New Issue
Block a user