mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 19:07:42 +02:00
Improve enter and fix bugs
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use crate::commands::command::EvaluatedStaticCommandArgs;
|
||||
use crate::context::SourceMap;
|
||||
use crate::object::dir_entry_dict;
|
||||
use crate::prelude::*;
|
||||
use crate::shell::completer::NuCompleter;
|
||||
@ -55,7 +56,7 @@ impl FilesystemShell {
|
||||
}
|
||||
|
||||
impl Shell for FilesystemShell {
|
||||
fn name(&self) -> String {
|
||||
fn name(&self, _source_map: &SourceMap) -> String {
|
||||
"filesystem".to_string()
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
use crate::commands::command::EvaluatedStaticCommandArgs;
|
||||
use crate::context::SourceMap;
|
||||
use crate::errors::ShellError;
|
||||
use crate::stream::OutputStream;
|
||||
|
||||
pub trait Shell {
|
||||
fn name(&self) -> String;
|
||||
fn name(&self, source_map: &SourceMap) -> String;
|
||||
fn ls(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError>;
|
||||
fn cd(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError>;
|
||||
fn path(&self) -> String;
|
||||
|
@ -73,8 +73,8 @@ impl ShellManager {
|
||||
pub fn next(&mut self) {
|
||||
{
|
||||
let mut x = self.shells.lock().unwrap();
|
||||
let shell = x.pop().unwrap();
|
||||
x.insert(0, shell);
|
||||
let shell = x.remove(0);
|
||||
x.push(shell);
|
||||
}
|
||||
self.set_path(self.path());
|
||||
}
|
||||
@ -82,8 +82,8 @@ impl ShellManager {
|
||||
pub fn prev(&mut self) {
|
||||
{
|
||||
let mut x = self.shells.lock().unwrap();
|
||||
let shell = x.remove(0);
|
||||
x.push(shell);
|
||||
let shell = x.pop().unwrap();
|
||||
x.insert(0, shell);
|
||||
}
|
||||
self.set_path(self.path());
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::commands::command::EvaluatedStaticCommandArgs;
|
||||
use crate::context::SourceMap;
|
||||
use crate::prelude::*;
|
||||
use crate::shell::shell::Shell;
|
||||
use std::ffi::OsStr;
|
||||
@ -53,8 +54,15 @@ impl ValueShell {
|
||||
}
|
||||
|
||||
impl Shell for ValueShell {
|
||||
fn name(&self) -> String {
|
||||
"value".to_string()
|
||||
fn name(&self, source_map: &SourceMap) -> String {
|
||||
let origin_name = self.value.origin_name(source_map);
|
||||
format!(
|
||||
"{}",
|
||||
match origin_name {
|
||||
Some(x) => format!("{{{}}}", x),
|
||||
None => format!("<{}>", self.value.item.type_name(),),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn ls(&self, _args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
|
Reference in New Issue
Block a user