Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add * as allowed variant characters
  • Loading branch information
RobinMalfait committed Dec 8, 2023
commit 5de784e60adab45ab06bfe49c5ff1fef85de9eaa
13 changes: 11 additions & 2 deletions oxide/crates/core/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl<'a> Extractor<'a> {
}

// Allowed first characters.
b'@' | b'!' | b'-' | b'<' | b'>' | b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' => {
b'@' | b'!' | b'-' | b'<' | b'>' | b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' | b'*' => {
// TODO: A bunch of characters that we currently support but maybe we only want it behind
// a flag. E.g.: '<sm'
// | '$' | '^' | '_'
Expand Down Expand Up @@ -473,7 +473,7 @@ impl<'a> Extractor<'a> {
b'%' => return ParseAction::Skip,

// < and > can only be part of a variant and only be the first or last character
b'<' | b'>' => {
b'<' | b'>' | b'*' => {
// Can only be the first or last character
// E.g.:
// - <sm:underline
Expand Down Expand Up @@ -797,6 +797,15 @@ mod test {
assert_eq!(candidates, vec!["hover:underline"]);
}

#[test]
fn it_can_parse_start_variants() {
let candidates = run("*:underline", false);
assert_eq!(candidates, vec!["*:underline"]);

let candidates = run("hover:*:underline", false);
assert_eq!(candidates, vec!["hover:*:underline"]);
}

#[test]
fn it_can_parse_simple_candidates_with_stacked_variants() {
let candidates = run("focus:hover:underline", false);
Expand Down