Retain labels stays a boolean without -r.
This commit is contained in:
@@ -351,6 +351,7 @@ fn example_switches<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ExampleSwitc
|
||||
let mut retain_labels = RetainLabels::Yes;
|
||||
let mut use_labels = true;
|
||||
let mut label_format = None;
|
||||
let mut saw_r = false;
|
||||
let (remaining, (source, (words, _))) =
|
||||
consumed(tuple((separated_list1(space1, switch_word), space0)))(input)?;
|
||||
|
||||
@@ -366,6 +367,7 @@ fn example_switches<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ExampleSwitc
|
||||
state = SwitchState::ContinuedLineNumber;
|
||||
}
|
||||
(SwitchState::Normal, "-r") => {
|
||||
saw_r = true;
|
||||
use_labels = false;
|
||||
match retain_labels {
|
||||
RetainLabels::Yes => {
|
||||
@@ -378,6 +380,7 @@ fn example_switches<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ExampleSwitc
|
||||
state = SwitchState::LabelFormat;
|
||||
}
|
||||
(SwitchState::Normal, "-k") => {
|
||||
use_labels = false;
|
||||
let text_until_flag = input.get_until(word);
|
||||
let character_offset = Into::<&str>::into(text_until_flag).chars().count();
|
||||
let character_offset = CharOffsetInLine::try_from(character_offset)
|
||||
@@ -426,6 +429,11 @@ fn example_switches<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ExampleSwitc
|
||||
}
|
||||
}
|
||||
|
||||
let retain_labels = match retain_labels {
|
||||
RetainLabels::Keep(_) if !saw_r => RetainLabels::Yes,
|
||||
_ => retain_labels,
|
||||
};
|
||||
|
||||
Ok((
|
||||
remaining,
|
||||
ExampleSwitches {
|
||||
|
||||
Reference in New Issue
Block a user