mirror of
https://github.com/nushell/nushell
synced 2025-01-13 21:55:07 +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)]
|
||||
pub struct NuCompleter {
|
||||
engine_state: EngineState,
|
||||
stack: Stack,
|
||||
config: Option<Value>,
|
||||
}
|
||||
|
||||
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 {
|
||||
engine_state,
|
||||
stack,
|
||||
config,
|
||||
}
|
||||
}
|
||||
|
@ -296,9 +298,8 @@ impl NuCompleter {
|
|||
|
||||
match &flat.1 {
|
||||
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
|
||||
if let Some(conf) = &self.config {
|
||||
stack.vars.insert(CONFIG_VARIABLE_ID, conf.clone());
|
||||
|
|
|
@ -27,13 +27,11 @@ pub fn evaluate_repl(
|
|||
history_path: Option<PathBuf>,
|
||||
is_perf_true: bool,
|
||||
) -> Result<()> {
|
||||
// use crate::logger::{configure, logger};
|
||||
use reedline::{FileBackedHistory, Reedline, Signal};
|
||||
|
||||
let mut entry_num = 0;
|
||||
|
||||
let mut nu_prompt = NushellPrompt::new();
|
||||
// let mut stack = nu_protocol::engine::Stack::new();
|
||||
|
||||
// First, set up env vars as strings only
|
||||
// gather_parent_env_vars(engine_state);
|
||||
|
@ -147,6 +145,7 @@ pub fn evaluate_repl(
|
|||
}))
|
||||
.with_completer(Box::new(NuCompleter::new(
|
||||
engine_state.clone(),
|
||||
stack.clone(),
|
||||
stack.vars.get(&CONFIG_VARIABLE_ID).cloned(),
|
||||
)))
|
||||
.with_quick_completions(config.quick_completions)
|
||||
|
|
Loading…
Reference in a new issue