Add DeepSource

This commit is contained in:
Ajeet D'Souza 2023-05-07 19:46:46 +05:30
parent 3483ab013a
commit 21211e43d1
3 changed files with 5 additions and 9 deletions

View File

@ -31,17 +31,15 @@ fn import_autojump(db: &mut Database, buffer: &str) -> Result<()> {
if line.is_empty() {
continue;
}
let mut split = line.splitn(2, '\t');
let (rank, path) =
line.split_once('\t').with_context(|| format!("invalid entry: {line}"))?;
let rank = split.next().with_context(|| format!("invalid entry: {line}"))?;
let mut rank = rank.parse::<f64>().with_context(|| format!("invalid rank: {rank}"))?;
// Normalize the rank using a sigmoid function. Don't import actual ranks from
// autojump, since its scoring algorithm is very different and might
// take a while to get normalized.
rank = sigmoid(rank);
let path = split.next().with_context(|| format!("invalid entry: {line}"))?;
db.add_unchecked(path, rank, 0);
}

View File

@ -96,13 +96,11 @@ mod tests {
#[apply(opts)]
fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
let opts = Opts { cmd, hook, echo, resolve_symlinks };
let mut source = String::new();
let mut source = String::default();
// Filter out lines using edit:*, since those functions are only available in
// the interactive editor.
for line in
Elvish(&opts).render().unwrap().split('\n').filter(|line| !line.contains("edit:"))
{
for line in Elvish(&opts).render().unwrap().lines().filter(|line| !line.contains("edit:")) {
source.push_str(line);
source.push('\n');
}

View File

@ -135,7 +135,7 @@ impl FzfChild {
mem::drop(self.0.stdin.take());
let mut stdout = self.0.stdout.take().unwrap();
let mut output = String::new();
let mut output = String::default();
stdout.read_to_string(&mut output).context("failed to read from fzf")?;
let status = self.0.wait().context("wait failed on fzf")?;