mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 12:29:46 +02:00
Improve enter and fix bugs
This commit is contained in:
@@ -51,7 +51,10 @@ pub fn autoview(
|
||||
let result = table.run(raw.with_input(input), &context.commands).await.unwrap();
|
||||
result.collect::<Vec<_>>().await;
|
||||
} else {
|
||||
println!("TODO!")
|
||||
let table = context.expect_command("table");
|
||||
let result = table.run(raw.with_input(input), &context.commands).await.unwrap();
|
||||
result.collect::<Vec<_>>().await;
|
||||
//println!("TODO!")
|
||||
// TODO
|
||||
// let mut host = context.host.lock().unwrap();
|
||||
// for i in input.iter() {
|
||||
|
@@ -158,13 +158,18 @@ impl InternalCommand {
|
||||
|
||||
let full_path = std::path::PathBuf::from(cwd);
|
||||
|
||||
let (file_extension, contents, contents_tag, _) =
|
||||
let (file_extension, contents, contents_tag, span_source) =
|
||||
crate::commands::open::fetch(
|
||||
&full_path,
|
||||
&location,
|
||||
Span::unknown(),
|
||||
)?;
|
||||
|
||||
if let Some(uuid) = contents_tag.origin {
|
||||
// If we have loaded something, track its source
|
||||
context.add_span_source(uuid, span_source);
|
||||
}
|
||||
|
||||
match contents {
|
||||
Value::Primitive(Primitive::String(string)) => {
|
||||
let value = crate::commands::open::parse_as_value(
|
||||
@@ -178,7 +183,7 @@ impl InternalCommand {
|
||||
}
|
||||
value => context
|
||||
.shell_manager
|
||||
.push(Box::new(ValueShell::new(value.tagged(Tag::unknown())))),
|
||||
.push(Box::new(ValueShell::new(value.tagged(contents_tag)))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -226,6 +226,7 @@ pub fn fetch(
|
||||
}
|
||||
} else {
|
||||
cwd.push(Path::new(location));
|
||||
let cwd = dunce::canonicalize(cwd).unwrap();
|
||||
match std::fs::read(&cwd) {
|
||||
Ok(bytes) => match std::str::from_utf8(&bytes) {
|
||||
Ok(s) => Ok((
|
||||
|
@@ -6,9 +6,17 @@ pub fn shells(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputSt
|
||||
let mut shells_out = VecDeque::new();
|
||||
let span = args.call_info.name_span;
|
||||
|
||||
for shell in args.shell_manager.shells.lock().unwrap().iter() {
|
||||
let shells_len = args.shell_manager.shells.lock().unwrap().len();
|
||||
|
||||
for (index, shell) in args.shell_manager.shells.lock().unwrap().iter().enumerate() {
|
||||
let mut dict = TaggedDictBuilder::new(Tag::unknown_origin(span));
|
||||
dict.insert("name", shell.name());
|
||||
|
||||
if index == (shells_len - 1) {
|
||||
dict.insert(" ", "X".to_string());
|
||||
} else {
|
||||
dict.insert(" ", " ".to_string());
|
||||
}
|
||||
dict.insert("name", shell.name(&args.call_info.source_map));
|
||||
dict.insert("path", shell.path());
|
||||
|
||||
shells_out.push_back(dict.into_tagged_value());
|
||||
|
@@ -15,16 +15,17 @@ pub fn tags(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStre
|
||||
let mut dict = TaggedDictBuilder::new(v.tag());
|
||||
dict.insert("start", Value::int(span.start as i64));
|
||||
dict.insert("end", Value::int(span.end as i64));
|
||||
tags.insert_tagged("span", dict.into_tagged_value());
|
||||
|
||||
match origin.map(|x| source_map.get(&x)).flatten() {
|
||||
Some(SpanSource::File(source)) => {
|
||||
dict.insert("origin", Value::string(source));
|
||||
tags.insert("origin", Value::string(source));
|
||||
}
|
||||
Some(SpanSource::Url(source)) => {
|
||||
dict.insert("origin", Value::string(source));
|
||||
tags.insert("origin", Value::string(source));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
tags.insert_tagged("span", dict.into_tagged_value());
|
||||
}
|
||||
|
||||
tags.into_tagged_value()
|
||||
|
Reference in New Issue
Block a user