diff --git a/src/complete.rs b/src/complete.rs index 526f1c806..7db6b9c1f 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -207,7 +207,7 @@ pub fn rank(&self) -> u32 { /// If this completion replaces the entire token, prepend a prefix. Otherwise do nothing. pub fn prepend_token_prefix(&mut self, prefix: &wstr) { - if self.flags.contains(CompleteFlags::REPLACES_TOKEN) { + if self.replaces_token() { self.completion.insert_utfstr(0, prefix) } } @@ -2093,7 +2093,7 @@ fn escape_opening_brackets(completions: &mut [Completion], argument: &wstr) { return; }; for comp in completions { - if comp.flags.contains(CompleteFlags::REPLACES_TOKEN) { + if comp.replaces_token() { continue; } comp.flags |= CompleteFlags::REPLACES_TOKEN; @@ -2128,7 +2128,7 @@ fn mark_completions_duplicating_arguments( let mut comp_str; for comp in self.completions.get_list_mut() { comp_str = comp.completion.clone(); - if !comp.flags.contains(CompleteFlags::REPLACES_TOKEN) { + if !comp.replaces_token() { comp_str.insert_utfstr(0, prefix); } if arg_strs.binary_search(&comp_str).is_ok() { @@ -3000,7 +3000,7 @@ macro_rules! unique_completion_applies_as { let completions = do_complete(L!("cat te"), CompletionRequestOptions::default()); assert_eq!(completions.len(), 1); assert_eq!(completions[0].completion, L!("stfile")); - assert!(!(completions[0].flags.contains(CompleteFlags::REPLACES_TOKEN))); + assert!(!completions[0].replaces_token()); assert!( !(completions[0] .flags @@ -3017,7 +3017,7 @@ macro_rules! unique_completion_applies_as { let completions = do_complete(L!("cat testfile TE"), CompletionRequestOptions::default()); assert_eq!(completions.len(), 1); assert_eq!(completions[0].completion, L!("testfile")); - assert!(completions[0].flags.contains(CompleteFlags::REPLACES_TOKEN)); + assert!(completions[0].replaces_token()); assert!( completions[0] .flags diff --git a/src/reader/reader.rs b/src/reader/reader.rs index af9ebf4d0..a9a9c37ec 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -6641,7 +6641,7 @@ fn compute_and_apply_completions(&mut self, c: ReadlineCmd) { fn try_insert(&mut self, c: Completion, tok: &wstr, token_range: Range) { // If this is a replacement completion, check that we know how to replace it, e.g. that // the token doesn't contain evil operators like {}. - if !c.flags.contains(CompleteFlags::REPLACES_TOKEN) || reader_can_replace(tok, c.flags) { + if !c.replaces_token() || reader_can_replace(tok, c.flags) { self.completion_insert( &c.completion, token_range.end, @@ -6693,7 +6693,7 @@ fn handle_completions(&mut self, token_range: Range, comp: Vec, comp: Vec