Skip to content

Commit

Permalink
fix: fixed build error
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinFillon committed Jun 19, 2024
1 parent de2e533 commit f2476cb
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use std::path::{Component, PathBuf};
use std::process::exit;

use nu_ansi_term::{AnsiStrings as ANSIStrings, Style};
use output::OutputType;

use crate::fs::feature::git::GitCache;
use crate::fs::filter::GitIgnore;
Expand Down
2 changes: 1 addition & 1 deletion src/output/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ impl TextCell {
let new_contents = self
.contents
.iter()
.filter(|w| !w.as_str().is_empty() && !w.as_str().trim().is_empty())
.cloned()
.filter(|w| !w.is_empty() && !w.trim().is_empty())
.collect::<Vec<_>>();

TextCell {
Expand Down
4 changes: 2 additions & 2 deletions src/output/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,14 @@ impl<'a> Render<'a> {
None,
);

write!(w, "{{\"files\":[")?;
write!(w, "\"files\":[")?;
for (i, row) in self.iterate(rows).enumerate() {
write!(w, "\"{}\"", row.strings())?;
if (i + 1) < self.files.len() {
write!(w, ", ")?;
}
}
writeln!(w, "]}}")
writeln!(w, "]")
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/output/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ impl<'a> Render<'a> {
// and treat it as just printing *quite* the same as lines
pub fn render_json<W: Write>(mut self, w: &mut W) -> io::Result<()> {
self.filter.sort_files(&mut self.files);
writeln!(w, "{{\"files\":[")?;
write!(w, "\"files\":[")?;
for (i, file) in self.files.iter().enumerate() {
let name_cell = self.file_style.for_file(file, self.theme).paint();
write!(w, "\"{}\"", name_cell.strings())?;
if (i + 1) < self.files.len() {
write!(w, ",")?;
}
}
writeln!(w, "]}}")?;
writeln!(w, "]")?;
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/output/grid_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl<'a> Render<'a> {
// because grid-details has no tree view.

pub fn render_json<W: Write>(self, _w: &mut W) -> io::Result<()> {
todo!("Implement json rendering");
unimplemented!("As it is made to be piped json with grid view, will not be implemented");
}

pub fn render<W: Write>(mut self, w: &mut W) -> io::Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions src/output/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file is a special renderer for json

use std::io::{self, Write};

use super::{details::TableIter, TextCell};
use super::{cell::TextCell, details::TableIter};

#[derive(Debug, Clone)]
struct JsonFile {
Expand Down Expand Up @@ -35,7 +35,7 @@ impl JsonFile {
writeln!(w, "[")?;
}
for (i, cell) in self.cell.contents.iter().enumerate() {
if cell.is_empty() || cell.trim().is_empty() {
if cell.as_str().is_empty() || cell.as_str().trim().is_empty() {
continue;
};
if let Some(ref header) = header {
Expand Down
4 changes: 2 additions & 2 deletions src/output/lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ impl<'a> Render<'a> {

pub fn render_json<W: Write>(mut self, w: &mut W) -> io::Result<()> {
self.filter.sort_files(&mut self.files);
write!(w, "{{\"files\":[")?;
write!(w, "\"files\":[")?;
for (i, file) in self.files.iter().enumerate() {
let name_cell = self.render_file(file);
write!(w, "\"{}\"", ANSIStrings(&name_cell))?;
if (i + 1) < self.files.len() {
write!(w, ",")?;
}
}
writeln!(w, "]}}")?;
writeln!(w, "]")?;

Ok(())
}
Expand Down

0 comments on commit f2476cb

Please sign in to comment.