Skip to content

Commit

Permalink
fix(Completions): fixes a bug that tried to propogate global args mul…
Browse files Browse the repository at this point in the history
…tiple times when generating multiple completion scripts

Closes #846
  • Loading branch information
kbknapp committed Feb 15, 2017
1 parent 3f71a01 commit 5e9b9cf
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use suggestions;
pub struct Parser<'a, 'b>
where 'a: 'b
{
propogated: bool,
required: Vec<&'a str>,
r_ifs: Vec<(&'a str, &'b str, &'a str)>,
pub short_list: Vec<char>,
Expand Down Expand Up @@ -69,6 +70,7 @@ pub struct Parser<'a, 'b>
impl<'a, 'b> Default for Parser<'a, 'b> {
fn default() -> Self {
Parser {
propogated: false,
flags: vec![],
opts: vec![],
positionals: VecMap::new(),
Expand Down Expand Up @@ -114,11 +116,13 @@ impl<'a, 'b> Parser<'a, 'b>
}

pub fn gen_completions_to<W: Write>(&mut self, for_shell: Shell, buf: &mut W) {

self.propogate_help_version();
self.build_bin_names();
self.propogate_globals();
self.propogate_settings();
if !self.propogated {
self.propogate_help_version();
self.build_bin_names();
self.propogate_globals();
self.propogate_settings();
self.propogated = true;
}

ComplGen::new(self).generate(for_shell, buf)
}
Expand Down Expand Up @@ -2210,6 +2214,7 @@ impl<'a, 'b> Clone for Parser<'a, 'b>
{
fn clone(&self) -> Self {
Parser {
propogated: self.propogated,
required: self.required.clone(),
short_list: self.short_list.clone(),
long_list: self.long_list.clone(),
Expand Down

0 comments on commit 5e9b9cf

Please sign in to comment.