chore: improve code comments clarity (#1158)
Signed-off-by: stringscut <stringscut@outlook.jp>
This commit is contained in:
parent
324b0d35e7
commit
52a716fed6
|
|
@ -37,7 +37,7 @@ fn import_autojump(db: &mut Database, buffer: &str) -> Result<()> {
|
||||||
let mut rank = rank.parse::<f64>().with_context(|| format!("invalid rank: {rank}"))?;
|
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
|
// Normalize the rank using a sigmoid function. Don't import actual ranks from
|
||||||
// autojump, since its scoring algorithm is very different and might
|
// autojump, since its scoring algorithm is very different and might
|
||||||
// take a while to get normalized.
|
// take a while to normalize.
|
||||||
rank = sigmoid(rank);
|
rank = sigmoid(rank);
|
||||||
|
|
||||||
db.add_unchecked(path, rank, 0);
|
db.add_unchecked(path, rank, 0);
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ impl Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new directory. This will create a duplicate entry if this
|
/// Creates a new directory. This will create a duplicate entry if this
|
||||||
/// directory is always in the database, it is expected that the user either
|
/// directory is already in the database, it is expected that the user either
|
||||||
/// does a check before calling this, or calls `dedup()` afterward.
|
/// does a check before calling this, or calls `dedup()` afterward.
|
||||||
pub fn add_unchecked(&mut self, path: impl AsRef<str> + Into<String>, rank: Rank, now: Epoch) {
|
pub fn add_unchecked(&mut self, path: impl AsRef<str> + Into<String>, rank: Rank, now: Epoch) {
|
||||||
self.with_dirs_mut(|dirs| {
|
self.with_dirs_mut(|dirs| {
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ impl<'a> Stream<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The logic here is reversed - if we resolve symlinks when adding entries to
|
// The logic here is reversed - if we resolve symlinks when adding entries to
|
||||||
// the database, we should not return symlinks when querying back from
|
// the database, we should not return symlinks when querying from
|
||||||
// the database.
|
// the database.
|
||||||
let resolver =
|
let resolver =
|
||||||
if self.options.resolve_symlinks { fs::symlink_metadata } else { fs::metadata };
|
if self.options.resolve_symlinks { fs::symlink_metadata } else { fs::metadata };
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ mod tests {
|
||||||
let mut source = String::new();
|
let mut source = String::new();
|
||||||
|
|
||||||
// Filter out lines using edit:*, since those functions are only available in
|
// Filter out lines using edit:*, since those functions are only available in
|
||||||
// the interactive editor.
|
// interactive editor mode.
|
||||||
for line in Elvish(&opts).render().unwrap().lines().filter(|line| !line.contains("edit:")) {
|
for line in Elvish(&opts).render().unwrap().lines().filter(|line| !line.contains("edit:")) {
|
||||||
source.push_str(line);
|
source.push_str(line);
|
||||||
source.push('\n');
|
source.push('\n');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue