mirror of
https://github.com/nushell/nushell.git
synced 2025-01-18 12:22:21 +01:00
Merge pull request #238 from fdncred/allow_esc_q
allow esc and q to get out of completions
This commit is contained in:
commit
11070ffbbe
16
src/main.rs
16
src/main.rs
@ -1,6 +1,10 @@
|
|||||||
use std::{cell::RefCell, io::Write, rc::Rc};
|
use std::{cell::RefCell, io::Write, rc::Rc};
|
||||||
|
|
||||||
use dialoguer::{theme::ColorfulTheme, Select};
|
use dialoguer::{
|
||||||
|
console::{Style, Term},
|
||||||
|
theme::ColorfulTheme,
|
||||||
|
Select,
|
||||||
|
};
|
||||||
use miette::{IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use nu_cli::{report_error, NuCompleter, NuHighlighter, NuValidator, NushellPrompt};
|
use nu_cli::{report_error, NuCompleter, NuHighlighter, NuValidator, NushellPrompt};
|
||||||
use nu_command::create_default_context;
|
use nu_command::create_default_context;
|
||||||
@ -45,13 +49,18 @@ impl CompletionActionHandler for FuzzyCompletion {
|
|||||||
|
|
||||||
let _ = crossterm::terminal::disable_raw_mode();
|
let _ = crossterm::terminal::disable_raw_mode();
|
||||||
println!();
|
println!();
|
||||||
let result = Select::with_theme(&ColorfulTheme::default())
|
let theme = ColorfulTheme {
|
||||||
|
active_item_style: Style::new().for_stderr().on_green().black(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let result = Select::with_theme(&theme)
|
||||||
.default(0)
|
.default(0)
|
||||||
.items(&selections[..])
|
.items(&selections[..])
|
||||||
.interact()
|
.interact_on_opt(&Term::stdout())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let _ = crossterm::terminal::enable_raw_mode();
|
let _ = crossterm::terminal::enable_raw_mode();
|
||||||
|
|
||||||
|
if let Some(result) = result {
|
||||||
let span = completions[result].0;
|
let span = completions[result].0;
|
||||||
|
|
||||||
let mut offset = present_buffer.offset();
|
let mut offset = present_buffer.offset();
|
||||||
@ -63,6 +72,7 @@ impl CompletionActionHandler for FuzzyCompletion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
miette::set_panic_hook();
|
miette::set_panic_hook();
|
||||||
|
Loading…
Reference in New Issue
Block a user