Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8916722c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "floss: return the correct position for autocomplete" am: 716eaa68

parents 8b118932 716eaa68
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -56,23 +56,18 @@ impl Completer for BtHelper {
    ) -> Result<(usize, Vec<String>), ReadlineError> {
        let slice = &line[..pos];
        let candidates = self.get_candidates(slice.to_string().clone());
        let mut completions = candidates
            .iter()
            .map(|c| {
                if candidates.len() == 1 {
                    // If only one candidate, Completer will replace the input by
                    // the returned string. Return the complete string here to avoid
                    // input being replaced by the suggested word.
                    slice.to_string() + &c.suggest_word[c.matched_len..] + " "
                } else {
                    c.suggest_word.clone()
                }
            })
            .collect::<Vec<String>>();
        let mut completions =
            candidates.iter().map(|c| c.suggest_word.clone() + " ").collect::<Vec<String>>();

        completions.sort();

        Ok((0, completions))
        // |start| points to the starting position of the current token
        let start = match slice.rfind(' ') {
            Some(x) => x + 1,
            None => 0,
        };

        Ok((start, completions))
    }
}