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

fix: -f work with -T option output empty #1200

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use std::process::exit;
use nu_ansi_term::{AnsiStrings as ANSIStrings, Style};

use crate::fs::feature::git::GitCache;
use crate::fs::filter::{FileFilterFlags::OnlyFiles, GitIgnore};
use crate::fs::filter::GitIgnore;
use crate::fs::{Dir, File};
use crate::options::stdin::FilesInput;
use crate::options::{vars, Options, OptionsResult, Vars};
Expand Down Expand Up @@ -395,18 +395,10 @@ impl<'args> Exa<'args> {
}

/// Prints the list of files using whichever view is selected.
fn print_files(&mut self, dir: Option<&Dir>, mut files: Vec<File<'_>>) -> io::Result<()> {
fn print_files(&mut self, dir: Option<&Dir>, files: Vec<File<'_>>) -> io::Result<()> {
if files.is_empty() {
return Ok(());
}
let recursing = self.options.dir_action.recurse_options().is_some();
let only_files = self.options.filter.flags.contains(&OnlyFiles);
if recursing && only_files {
files = files
.into_iter()
.filter(|f| !f.is_directory())
.collect::<Vec<_>>();
}
let theme = &self.theme;
let View {
ref mode,
Expand Down
38 changes: 20 additions & 18 deletions src/output/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ use crate::fs::dir_action::RecurseOptions;
use crate::fs::feature::git::GitCache;
use crate::fs::feature::xattr::Attribute;
use crate::fs::fields::SecurityContextType;
use crate::fs::filter::FileFilter;
use crate::fs::filter::{FileFilter, FileFilterFlags::OnlyFiles};
use crate::fs::{Dir, File};
use crate::output::cell::TextCell;
use crate::output::color_scale::{ColorScaleInformation, ColorScaleOptions};
Expand Down Expand Up @@ -332,27 +332,29 @@ impl<'a> Render<'a> {
let mut files = Vec::new();
let errors = egg.errors;

if let (Some(ref mut t), Some(row)) = (table.as_mut(), egg.table_row.as_ref()) {
t.add_widths(row);
}
if !(egg.file.path.is_dir() && self.filter.flags.contains(&OnlyFiles)) {
if let (Some(ref mut t), Some(row)) = (table.as_mut(), egg.table_row.as_ref()) {
t.add_widths(row);
}

let file_name = self
.file_style
.for_file(egg.file, self.theme)
.with_link_paths()
.with_mount_details(self.opts.mounts)
.paint()
.promote();
let file_name = self
.file_style
.for_file(egg.file, self.theme)
.with_link_paths()
.with_mount_details(self.opts.mounts)
.paint()
.promote();

debug!("file_name {:?}", file_name);
debug!("file_name {:?}", file_name);

let row = Row {
tree: tree_params,
cells: egg.table_row,
name: file_name,
};
let row = Row {
tree: tree_params,
cells: egg.table_row,
name: file_name,
};

rows.push(row);
rows.push(row);
}

if let Some(ref dir) = egg.dir {
for file_to_add in dir.files(
Expand Down