Remove Span::unknown (#525)

This commit is contained in:
JT
2021-12-19 18:46:13 +11:00
committed by GitHub
parent b54e9b6bfd
commit 2883d6cd1e
183 changed files with 1291 additions and 1124 deletions

View File

@ -71,7 +71,7 @@ prints out the list properly."#
match input {
PipelineData::Value(Value::List { vals, .. }, ..) => {
// dbg!("value::list");
let data = convert_to_list(vals, &config);
let data = convert_to_list(vals, &config, call.head);
if let Some(items) = data {
Ok(create_grid_output(
items,
@ -88,7 +88,7 @@ prints out the list properly."#
}
PipelineData::Stream(stream, ..) => {
// dbg!("value::stream");
let data = convert_to_list(stream, &config);
let data = convert_to_list(stream, &config, call.head);
if let Some(items) = data {
Ok(create_grid_output(
items,
@ -178,7 +178,7 @@ fn create_grid_output(
if use_grid_icons {
let no_ansi = strip_ansi(&value);
let path = std::path::Path::new(&no_ansi);
let icon = icon_for_file(path)?;
let icon = icon_for_file(path, call.head)?;
let ls_colors_style = ls_colors.style_for_path(path);
// eprintln!("ls_colors_style: {:?}", &ls_colors_style);
@ -236,6 +236,7 @@ fn create_grid_output(
fn convert_to_list(
iter: impl IntoIterator<Item = Value>,
config: &Config,
head: Span,
) -> Option<Vec<(usize, String, String)>> {
let mut iter = iter.into_iter().peekable();
@ -259,7 +260,7 @@ fn convert_to_list(
Value::Record { .. } => {
item.clone().follow_cell_path(&[PathMember::String {
val: header.into(),
span: Span::unknown(),
span: head,
}])
}
_ => Ok(item.clone()),

View File

@ -130,7 +130,7 @@ lazy_static! {
};
}
pub fn icon_for_file(file_path: &Path) -> Result<char, ShellError> {
pub fn icon_for_file(file_path: &Path, span: Span) -> Result<char, ShellError> {
let extensions = Box::new(FileExtensions);
let fp = format!("{}", file_path.display());
@ -143,7 +143,7 @@ pub fn icon_for_file(file_path: &Path) -> Result<char, ShellError> {
ShellError::SpannedLabeledError(
"File name error".into(),
"Unable to get file name".into(),
Span::unknown(),
span,
)
})?
.to_str()
@ -151,7 +151,7 @@ pub fn icon_for_file(file_path: &Path) -> Result<char, ShellError> {
ShellError::SpannedLabeledError(
"Unable to get str error".into(),
"Unable to convert to str file name".into(),
Span::unknown(),
span,
)
})?;
Ok(match str {
@ -167,7 +167,7 @@ pub fn icon_for_file(file_path: &Path) -> Result<char, ShellError> {
ShellError::SpannedLabeledError(
"Unable to get str error".into(),
"Unable to convert to str file name".into(),
Span::unknown(),
span,
)
})?;
Ok(match str {

View File

@ -52,7 +52,7 @@ impl Command for Table {
match input {
PipelineData::Value(Value::List { vals, .. }, ..) => {
let table = convert_to_table(0, vals, ctrlc, &config)?;
let table = convert_to_table(0, vals, ctrlc, &config, call.head)?;
if let Some(table) = table {
let result = nu_table::draw_table(&table, term_width, &color_hm, &config);
@ -220,6 +220,7 @@ fn convert_to_table(
iter: impl IntoIterator<Item = Value>,
ctrlc: Option<Arc<AtomicBool>>,
config: &Config,
head: Span,
) -> Result<Option<nu_table::Table>, ShellError> {
let mut iter = iter.into_iter().peekable();
let color_hm = get_color_config(config);
@ -257,7 +258,7 @@ fn convert_to_table(
Value::Record { .. } => {
item.clone().follow_cell_path(&[PathMember::String {
val: header.into(),
span: Span::unknown(),
span: head,
}])
}
_ => Ok(item.clone()),
@ -399,6 +400,7 @@ impl Iterator for PagingTableCreator {
batch.into_iter(),
self.ctrlc.clone(),
&self.config,
self.head,
);
self.row_offset += idx;