Skip to content

Commit 1958fb2

Browse files
pascalkutheg-re-g
andcommitted
Apply suggestions from code review
Co-authored-by: g-re-g <123515925+g-re-g@users.noreply.github.com>
1 parent a92f9c5 commit 1958fb2

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

helix-term/src/commands.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use movement::Movement;
4545
use crate::{
4646
args,
4747
compositor::{self, Component, Compositor},
48-
filter_entry,
48+
filter_picker_entry,
4949
job::Callback,
5050
keymap::ReverseKeymap,
5151
ui::{self, overlay::overlayed, FilePicker, Picker, Popup, Prompt, PromptEvent},
@@ -1928,7 +1928,9 @@ fn global_search(cx: &mut Context) {
19281928
.git_global(file_picker_config.git_global)
19291929
.git_exclude(file_picker_config.git_exclude)
19301930
.max_depth(file_picker_config.max_depth)
1931-
.filter_entry(move |entry| filter_entry(entry, &absolute_root, dedup_symlinks))
1931+
.filter_entry(move |entry| {
1932+
filter_picker_entry(entry, &absolute_root, dedup_symlinks)
1933+
})
19321934
.build_parallel()
19331935
.run(|| {
19341936
let mut searcher = searcher.clone();

helix-term/src/lib.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@ fn true_color() -> bool {
2727
}
2828

2929
/// Function used for filtering dir entries in the various file pickers.
30-
///
31-
/// We always want to ignore the .git directory, otherwise if
32-
/// `ignore` is turned off, we end up with a lot of noise
33-
/// in our picker.
34-
/// We also ignore symlinks that point inside the current directory
35-
/// if `dedup_links` is enabled.
36-
fn filter_entry(entry: &DirEntry, root: &Path, dedup_links: bool) -> bool {
37-
if entry.file_name() != ".git" {
30+
fn filter_picker_entry(entry: &DirEntry, root: &Path, dedup_links: bool) -> bool {
31+
// We always want to ignore the .git directory, otherwise if
32+
// `ignore` is turned off, we end up with a lot of noise
33+
// in our picker.
34+
if entry.file_name() == ".git" {
3835
return false;
3936
}
4037

38+
// We also ignore symlinks that point inside the current directory
39+
// if `dedup_links` is enabled.
4140
if dedup_links && entry.path_is_symlink() {
4241
return entry
4342
.path()

helix-term/src/ui/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod statusline;
1414
mod text;
1515

1616
use crate::compositor::{Component, Compositor};
17-
use crate::filter_entry;
17+
use crate::filter_picker_entry;
1818
use crate::job::{self, Callback};
1919
pub use completion::Completion;
2020
pub use editor::EditorView;
@@ -163,7 +163,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
163163

164164
let now = Instant::now();
165165

166-
let deadup_symlinks = config.file_picker.deduplicate_links;
166+
let dedup_symlinks = config.file_picker.deduplicate_links;
167167
let absolute_root = root.canonicalize().unwrap_or_else(|_| root.clone());
168168

169169
let mut walk_builder = WalkBuilder::new(&root);
@@ -176,7 +176,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
176176
.git_global(config.file_picker.git_global)
177177
.git_exclude(config.file_picker.git_exclude)
178178
.max_depth(config.file_picker.max_depth)
179-
.filter_entry(move |entry| filter_entry(entry, &absolute_root, deadup_symlinks));
179+
.filter_entry(move |entry| filter_picker_entry(entry, &absolute_root, dedup_symlinks));
180180

181181
// We want to exclude files that the editor can't handle yet
182182
let mut type_builder = TypesBuilder::new();
@@ -196,10 +196,10 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
196196
let files = walk_builder.build().filter_map(|entry| {
197197
let entry = entry.ok()?;
198198
// This is faster than entry.path().is_dir() since it uses cached fs::Metadata fetched by ignore/walkdir
199-
if !entry.file_type()?.is_file() {
200-
return None;
199+
if entry.file_type()?.is_file() {
200+
return Some(entry.into_path());
201201
}
202-
Some(entry.into_path())
202+
None
203203
});
204204

205205
// Cap the number of files if we aren't in a git project, preventing

helix-view/src/editor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub struct FilePickerConfig {
171171
/// Enables following symlinks.
172172
/// Whether to follow symbolic links in file picker and file or directory completions. Defaults to true.
173173
pub follow_symlinks: bool,
174-
/// Hides symlinks that point into the current directory. Default to true
174+
/// Hides symlinks that point into the current directory. Defaults to true.
175175
pub deduplicate_links: bool,
176176
/// Enables reading ignore files from parent directories. Defaults to true.
177177
pub parents: bool,

0 commit comments

Comments
 (0)