fix: fixed build error

This commit is contained in:
MartinFillon 2024-05-31 17:17:17 +02:00
parent de2e5337a0
commit f2476cbd24
No known key found for this signature in database
GPG key ID: 16DC898F53F94853
7 changed files with 11 additions and 10 deletions

View file

@ -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;

View file

@ -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 {

View file

@ -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, "]")
}
}

View file

@ -63,7 +63,7 @@ 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())?;
@ -71,7 +71,7 @@ impl<'a> Render<'a> {
write!(w, ",")?;
}
}
writeln!(w, "]}}")?;
writeln!(w, "]")?;
Ok(())
}
}

View file

@ -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<()> {

View file

@ -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 {
@ -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 {

View file

@ -37,7 +37,7 @@ 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))?;
@ -45,7 +45,7 @@ impl<'a> Render<'a> {
write!(w, ",")?;
}
}
writeln!(w, "]}}")?;
writeln!(w, "]")?;
Ok(())
}