mirror of
https://github.com/nushell/nushell
synced 2025-01-14 14:14:13 +00:00
Use real stack during custom completion (#5010)
This commit is contained in:
parent
1aef3a730a
commit
0afa18ac4a
2 changed files with 5 additions and 5 deletions
|
@ -28,13 +28,15 @@ impl Default for CompletionOptions {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct NuCompleter {
|
pub struct NuCompleter {
|
||||||
engine_state: EngineState,
|
engine_state: EngineState,
|
||||||
|
stack: Stack,
|
||||||
config: Option<Value>,
|
config: Option<Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NuCompleter {
|
impl NuCompleter {
|
||||||
pub fn new(engine_state: EngineState, config: Option<Value>) -> Self {
|
pub fn new(engine_state: EngineState, stack: Stack, config: Option<Value>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
engine_state,
|
engine_state,
|
||||||
|
stack,
|
||||||
config,
|
config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,9 +298,8 @@ impl NuCompleter {
|
||||||
|
|
||||||
match &flat.1 {
|
match &flat.1 {
|
||||||
FlatShape::Custom(decl_id) => {
|
FlatShape::Custom(decl_id) => {
|
||||||
//let prefix = working_set.get_span_contents(flat.0).to_vec();
|
let mut stack = self.stack.clone();
|
||||||
|
|
||||||
let mut stack = Stack::new();
|
|
||||||
// Set up our initial config to start from
|
// Set up our initial config to start from
|
||||||
if let Some(conf) = &self.config {
|
if let Some(conf) = &self.config {
|
||||||
stack.vars.insert(CONFIG_VARIABLE_ID, conf.clone());
|
stack.vars.insert(CONFIG_VARIABLE_ID, conf.clone());
|
||||||
|
|
|
@ -27,13 +27,11 @@ pub fn evaluate_repl(
|
||||||
history_path: Option<PathBuf>,
|
history_path: Option<PathBuf>,
|
||||||
is_perf_true: bool,
|
is_perf_true: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// use crate::logger::{configure, logger};
|
|
||||||
use reedline::{FileBackedHistory, Reedline, Signal};
|
use reedline::{FileBackedHistory, Reedline, Signal};
|
||||||
|
|
||||||
let mut entry_num = 0;
|
let mut entry_num = 0;
|
||||||
|
|
||||||
let mut nu_prompt = NushellPrompt::new();
|
let mut nu_prompt = NushellPrompt::new();
|
||||||
// let mut stack = nu_protocol::engine::Stack::new();
|
|
||||||
|
|
||||||
// First, set up env vars as strings only
|
// First, set up env vars as strings only
|
||||||
// gather_parent_env_vars(engine_state);
|
// gather_parent_env_vars(engine_state);
|
||||||
|
@ -147,6 +145,7 @@ pub fn evaluate_repl(
|
||||||
}))
|
}))
|
||||||
.with_completer(Box::new(NuCompleter::new(
|
.with_completer(Box::new(NuCompleter::new(
|
||||||
engine_state.clone(),
|
engine_state.clone(),
|
||||||
|
stack.clone(),
|
||||||
stack.vars.get(&CONFIG_VARIABLE_ID).cloned(),
|
stack.vars.get(&CONFIG_VARIABLE_ID).cloned(),
|
||||||
)))
|
)))
|
||||||
.with_quick_completions(config.quick_completions)
|
.with_quick_completions(config.quick_completions)
|
||||||
|
|
Loading…
Reference in a new issue