From 5e9b9cf4dd80fa66a624374fd04e6545635c1f94 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Wed, 15 Feb 2017 11:01:41 -0500 Subject: [PATCH] fix(Completions): fixes a bug that tried to propogate global args multiple times when generating multiple completion scripts Closes #846 --- src/app/parser.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/parser.rs b/src/app/parser.rs index f2fbbe49cb8..350f5bfd3d3 100644 --- a/src/app/parser.rs +++ b/src/app/parser.rs @@ -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, @@ -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(), @@ -114,11 +116,13 @@ impl<'a, 'b> Parser<'a, 'b> } pub fn gen_completions_to(&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) } @@ -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(),