add config option to limit external command completions (#6076)
* add config option to limit external command completions * fmt * small change * change name in config * change name in config again
This commit is contained in:
parent
e5684bc34c
commit
ae765c71fd
|
@ -43,19 +43,21 @@ impl CommandCompletion {
|
||||||
|
|
||||||
if let Ok(mut contents) = std::fs::read_dir(path) {
|
if let Ok(mut contents) = std::fs::read_dir(path) {
|
||||||
while let Some(Ok(item)) = contents.next() {
|
while let Some(Ok(item)) = contents.next() {
|
||||||
if !executables.contains(
|
if self.engine_state.config.max_external_completion_results
|
||||||
&item
|
> executables.len() as i64
|
||||||
.path()
|
&& !executables.contains(
|
||||||
.file_name()
|
&item
|
||||||
.map(|x| x.to_string_lossy().to_string())
|
.path()
|
||||||
.unwrap_or_default(),
|
.file_name()
|
||||||
) && matches!(
|
.map(|x| x.to_string_lossy().to_string())
|
||||||
item.path()
|
.unwrap_or_default(),
|
||||||
.file_name()
|
)
|
||||||
.map(|x| match_algorithm
|
&& matches!(
|
||||||
|
item.path().file_name().map(|x| match_algorithm
|
||||||
.matches_str(&x.to_string_lossy(), prefix)),
|
.matches_str(&x.to_string_lossy(), prefix)),
|
||||||
Some(true)
|
Some(true)
|
||||||
) && is_executable::is_executable(&item.path())
|
)
|
||||||
|
&& is_executable::is_executable(&item.path())
|
||||||
{
|
{
|
||||||
if let Ok(name) = item.file_name().into_string() {
|
if let Ok(name) = item.file_name().into_string() {
|
||||||
executables.push(name);
|
executables.push(name);
|
||||||
|
|
|
@ -59,6 +59,7 @@ pub struct Config {
|
||||||
pub use_grid_icons: bool,
|
pub use_grid_icons: bool,
|
||||||
pub footer_mode: FooterMode,
|
pub footer_mode: FooterMode,
|
||||||
pub float_precision: i64,
|
pub float_precision: i64,
|
||||||
|
pub max_external_completion_results: i64,
|
||||||
pub filesize_format: String,
|
pub filesize_format: String,
|
||||||
pub use_ansi_coloring: bool,
|
pub use_ansi_coloring: bool,
|
||||||
pub quick_completions: bool,
|
pub quick_completions: bool,
|
||||||
|
@ -92,6 +93,7 @@ impl Default for Config {
|
||||||
use_grid_icons: false,
|
use_grid_icons: false,
|
||||||
footer_mode: FooterMode::RowCount(25),
|
footer_mode: FooterMode::RowCount(25),
|
||||||
float_precision: 4,
|
float_precision: 4,
|
||||||
|
max_external_completion_results: 100,
|
||||||
filesize_format: "auto".into(),
|
filesize_format: "auto".into(),
|
||||||
use_ansi_coloring: true,
|
use_ansi_coloring: true,
|
||||||
quick_completions: true,
|
quick_completions: true,
|
||||||
|
@ -249,6 +251,13 @@ impl Value {
|
||||||
eprintln!("$config.partial_completions is not a bool")
|
eprintln!("$config.partial_completions is not a bool")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"max_external_completion_results" => {
|
||||||
|
if let Ok(i) = value.as_integer() {
|
||||||
|
config.max_external_completion_results = i;
|
||||||
|
} else {
|
||||||
|
eprintln!("$config.max_external_completion_results is not an integer")
|
||||||
|
}
|
||||||
|
}
|
||||||
"completion_algorithm" => {
|
"completion_algorithm" => {
|
||||||
if let Ok(v) = value.as_string() {
|
if let Ok(v) = value.as_string() {
|
||||||
config.completion_algorithm = v.to_lowercase();
|
config.completion_algorithm = v.to_lowercase();
|
||||||
|
|
|
@ -256,6 +256,7 @@ let-env config = {
|
||||||
cd_with_abbreviations: false # set to true to allow you to do things like cd s/o/f and nushell expand it to cd some/other/folder
|
cd_with_abbreviations: false # set to true to allow you to do things like cd s/o/f and nushell expand it to cd some/other/folder
|
||||||
case_sensitive_completions: false # set to true to enable case-sensitive completions
|
case_sensitive_completions: false # set to true to enable case-sensitive completions
|
||||||
enable_external_completion: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up my be very slow
|
enable_external_completion: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up my be very slow
|
||||||
|
max_external_completion_results: 100 # setting it lower can improve completion performance at the cost of omitting some options
|
||||||
|
|
||||||
# A strategy of managing table view in case of limited space.
|
# A strategy of managing table view in case of limited space.
|
||||||
table_trim: {
|
table_trim: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user