Fix flow adjacent value with complex key.
This commit is contained in:
parent
7c3e8ed7c4
commit
9281e35bbb
2 changed files with 11 additions and 1 deletions
|
@ -311,6 +311,8 @@ pub struct Scanner<T> {
|
||||||
stream_start_produced: bool,
|
stream_start_produced: bool,
|
||||||
/// Whether we have already emitted the `StreamEnd` token.
|
/// Whether we have already emitted the `StreamEnd` token.
|
||||||
stream_end_produced: bool,
|
stream_end_produced: bool,
|
||||||
|
/// In some flow contexts, the value of a mapping is allowed to be adjacent to the `:`. When it
|
||||||
|
/// is, the index at which the `:` may be must be stored in `adjacent_value_allowed_at`.
|
||||||
adjacent_value_allowed_at: usize,
|
adjacent_value_allowed_at: usize,
|
||||||
/// Whether a simple key could potentially start at the current position.
|
/// Whether a simple key could potentially start at the current position.
|
||||||
///
|
///
|
||||||
|
@ -1395,6 +1397,15 @@ impl<T: Iterator<Item = char>> Scanner<T> {
|
||||||
self.skip();
|
self.skip();
|
||||||
self.skip_ws_to_eol(SkipTabs::Yes)?;
|
self.skip_ws_to_eol(SkipTabs::Yes)?;
|
||||||
|
|
||||||
|
// A flow collection within a flow mapping can be a key. In that case, the value may be
|
||||||
|
// adjacent to the `:`.
|
||||||
|
// ```yaml
|
||||||
|
// - [ {a: b}:value ]
|
||||||
|
// ```
|
||||||
|
if self.flow_level > 0 {
|
||||||
|
self.adjacent_value_allowed_at = self.mark.index;
|
||||||
|
}
|
||||||
|
|
||||||
self.tokens.push_back(Token(start_mark, tok));
|
self.tokens.push_back(Token(start_mark, tok));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,7 +315,6 @@ fn expected_events(expected_tree: &str) -> Vec<String> {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
static EXPECTED_FAILURES: &[&str] = &[
|
static EXPECTED_FAILURES: &[&str] = &[
|
||||||
// Misc
|
// Misc
|
||||||
"9MMW", // Mapping key in implicit mapping in flow sequence(!)
|
|
||||||
"G9HC", // Anchor indent problem(?)
|
"G9HC", // Anchor indent problem(?)
|
||||||
"H7J7", // Anchor indent / linebreak problem?
|
"H7J7", // Anchor indent / linebreak problem?
|
||||||
"3UYS", // Escaped /
|
"3UYS", // Escaped /
|
||||||
|
|
Loading…
Reference in a new issue