Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File picker should have an option to display ignored files #280

Closed
valignatev opened this issue Jun 16, 2021 · 18 comments · Fixed by #284 or #988
Closed

File picker should have an option to display ignored files #280

valignatev opened this issue Jun 16, 2021 · 18 comments · Fixed by #284 or #988
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much

Comments

@valignatev
Copy link

valignatev commented Jun 16, 2021

Helix can't open files that are in the home directory and in some other directories.
Can't quite tell the pattern, but in some directories helix just doesn't open any existing files. As in it doesn't show suggestions. It opens the file if I type its name manually with the relative path, but it can't open the file if I type its path like ~/.vimrc, e.g. with leading tilde. It says "NOR" and a path to the file
image

Environment

  • Platform: Arch Linux
  • Helix version: 0.2.0

Log file is empty

@valignatev valignatev added the C-bug Category: This is a bug label Jun 16, 2021
@pickfire
Copy link
Contributor

Seemed to work for me, is your ~/.vimrc empty? I am using arch as well, I tried both v0.2.0 and a364d6c. Did you use the one in AUR? How did you install or test it out?

@valignatev
Copy link
Author

yeah just helix-bin from AUR. My vimrc has content. Again, it opens when I manually type it out like :open .vimrc, and shows the content, but it doesn't open it if I type :open ~/.vimrc.

@sudormrfbin
Copy link
Member

yeah just helix-bin from AUR. My vimrc has content. Again, it opens when I manually type it out like :open .vimrc, and shows the content, but it doesn't open it if I type :open ~/.vimrc.

I can reproduce this on master. Seems like an issue with expanding ~.

@valignatev
Copy link
Author

valignatev commented Jun 28, 2021

I believe this isn't fixed still. While ~ gets expanded to the home directory now, no suggestions for the files are shown.
hx --version is 0.3

This is what space f shows when hx is launched from the home directory
image

@archseer
Copy link
Member

You need to add a trailing slash: ~/ shows results for me.

@valignatev
Copy link
Author

It doesn't for me
image

@archseer
Copy link
Member

Weird, is your home directory a symlink maybe?

@valignatev
Copy link
Author

It's an absolute path

@archseer
Copy link
Member

And ~ is the only path that has these issues?

@archseer
Copy link
Member

The file picker follows .gitignore/ignorefile rules, maybe that's the issue?

pub fn file_picker(root: PathBuf) -> Picker<PathBuf> {
use ignore::Walk;
use std::time;
let files = Walk::new(root.clone()).filter_map(|entry| match entry {
Ok(entry) => {
// filter dirs, but we might need special handling for symlinks!
if !entry.file_type().map_or(false, |entry| entry.is_dir()) {
let time = if let Ok(metadata) = entry.metadata() {
metadata
.accessed()
.or_else(|_| metadata.modified())
.or_else(|_| metadata.created())
.unwrap_or(time::UNIX_EPOCH)
} else {
time::UNIX_EPOCH
};
Some((entry.into_path(), time))
} else {
None
}
}
Err(_err) => None,
});
let mut files: Vec<_> = if root.join(".git").is_dir() {
files.collect()
} else {
const MAX: usize = 8192;
files.take(MAX).collect()
};
files.sort_by_key(|file| std::cmp::Reverse(file.1));
let files = files.into_iter().map(|(path, _)| path).collect();
Picker::new(
files,
move |path: &PathBuf| {
// format_fn
path.strip_prefix(&root)
.unwrap_or(path)
.to_str()
.unwrap()
.into()
},
move |editor: &mut Editor, path: &PathBuf, action| {
let document_id = editor
.open(path.into(), action)
.expect("editor.open failed");
},
)
}

@archseer archseer reopened this Jun 28, 2021
@valignatev
Copy link
Author

Oh yeah that's definitely it, my home directory is a git repo with * in gitignore and forcibly added files that I track:
https://github.com/valignatev/dotfiles/blob/master/.gitignore

I would never have guessed that "git project" is the default behavior for helix and it strictly obeys gitignore like that :)

@pickfire
Copy link
Contributor

pickfire commented Jun 28, 2021

@archseer Yeah, another person like me which use .git for home directory, which is why I say we stop the .git search until the home directory or root directory.

@valignatev One suggestion I can say is used another directory for git. But yeah, that's a temporary solution for just helix. That's also good because it can hide my prompt. Now I just alias home so it is ~/.home rather than ~/.git so stuff don't seemed weird sometimes, and my prompt also does not show the branch for git when at home directory:

alias home 'git --work-tree=/home/ivan --git-dir=/home/ivan/.home'

@valignatev
Copy link
Author

valignatev commented Jun 28, 2021

haha, no thanks, there is no benefit for me to introduce this complexity just to make some text editor work :)

But yeah, probably @pickfire's suggestion to not blindly obey gitignore is a good idea. Generally, even aside from dotfiles case, there are lots of cases when people want to comfortably browse their gitignored files - I browse node_modules, or zig_cache, or rust's cache all the time when I do my development, and those directories are almost always gitignored.

@pickfire
Copy link
Contributor

there are lots of cases when people want to comfortably browse their gitignored files

I almost never do this unless I just press "goto declaration" or sort. We could maybe add a flag in file picker to allow browsing through hidden files.

@archseer
Copy link
Member

Specifically in the case of the home dir, the recommendation is to use something like rcm (https://github.com/thoughtbot/rcm) or homesick. You'll definitely have issues with more than just Helix otherwise. https://askubuntu.com/questions/1316229/is-it-bad-practice-to-git-init-in-the-home-directory-to-keep-track-of-dot-files

But yes, Helix should have an option to run a filepicker without the ignore flags.

@valignatev
Copy link
Author

I'm using this approach to manage my home directory for many years already and this is the first time something ever conflicted with it. I've used rcm and bare git repositories in the past, but all other solutions had some problems I didn't want to deal with, so I switched to this current setup that proved to be the best over the years. I'm definitely not the only one who does the same thing, here's another example: https://drewdevault.com/2019/12/30/dotfiles.html that I can recall off the top of my head.

Regardless, I think that discussions about best practices in managing dotfiles might be slightly offtopic for the issue since it seems to be related not only to the home directory, but generally to the topic of browsing ignored files.

@archseer archseer changed the title Helix doesn't suggest file names in some directories and can't open files if you type them relative to the home directory File picker should have an option to display ignored files Jun 30, 2021
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Aug 19, 2021
@kirawi
Copy link
Member

kirawi commented Aug 19, 2021

I believe someone else recently had this issue on Matrix.

@kirawi
Copy link
Member

kirawi commented Oct 13, 2021

Capture
Having something like this would be nice.

@kirawi kirawi added C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much and removed C-bug Category: This is a bug labels Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants