Skip to content

Commit e6fc23d

Browse files
committed
fix(completer): const $NU_LIB_DIRS for DotNuCompletion
1 parent 03bb144 commit e6fc23d

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

crates/nu-cli/src/completions/dotnu_completions.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ impl Completer for DotNuCompletion {
4141
let mut is_current_folder = false;
4242

4343
// Fetch the lib dirs
44-
let lib_dirs: Vec<String> = if let Some(lib_dirs) = working_set.get_env_var("NU_LIB_DIRS") {
44+
let lib_dirs: Vec<String> = if let Some(lib_dirs) = working_set
45+
.find_variable(b"$NU_LIB_DIRS")
46+
.and_then(|vid| working_set.get_variable(vid).const_val.as_ref())
47+
.or(working_set.get_env_var("NU_LIB_DIRS"))
48+
{
4549
lib_dirs
4650
.as_list()
4751
.into_iter()

crates/nu-cli/src/repl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ fn setup_history(
11591159
/// Setup Reedline keybindingds based on the provided config
11601160
///
11611161
fn setup_keybindings(engine_state: &EngineState, line_editor: Reedline) -> Reedline {
1162-
return match create_keybindings(engine_state.get_config()) {
1162+
match create_keybindings(engine_state.get_config()) {
11631163
Ok(keybindings) => match keybindings {
11641164
KeybindingsMode::Emacs(keybindings) => {
11651165
let edit_mode = Box::new(Emacs::new(keybindings));
@@ -1177,7 +1177,7 @@ fn setup_keybindings(engine_state: &EngineState, line_editor: Reedline) -> Reedl
11771177
report_shell_error(engine_state, &e);
11781178
line_editor
11791179
}
1180-
};
1180+
}
11811181
}
11821182

11831183
///

crates/nu-cli/src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn gather_env_vars(
132132
working_set.error(err);
133133
}
134134

135-
if working_set.parse_errors.first().is_some() {
135+
if !working_set.parse_errors.is_empty() {
136136
report_capture_error(
137137
engine_state,
138138
&String::from_utf8_lossy(contents),
@@ -176,7 +176,7 @@ fn gather_env_vars(
176176
working_set.error(err);
177177
}
178178

179-
if working_set.parse_errors.first().is_some() {
179+
if !working_set.parse_errors.is_empty() {
180180
report_capture_error(
181181
engine_state,
182182
&String::from_utf8_lossy(contents),

crates/nu-lsp/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ fn try_find_id_in_use(
282282
id: Option<&Id>,
283283
) -> Option<(Id, Span)> {
284284
let call_name = working_set.get_span_contents(call.head);
285-
if call_name != b"use" && call_name != b"hide" {
285+
if call_name != b"use" && call_name != b"export use" && call_name != b"hide" {
286286
return None;
287287
}
288288
// TODO: for keyword `hide`, the decl/var is already hidden in working_set,
@@ -318,7 +318,7 @@ fn try_find_id_in_use(
318318
if let Some(pos) = location {
319319
// first argument of `use` should always be module name
320320
// while it is optional in `hide`
321-
if span.contains(*pos) && call_name == b"use" {
321+
if span.contains(*pos) && call_name != b"hide" {
322322
return get_matched_module_id(working_set, span, id);
323323
}
324324
}
@@ -338,7 +338,7 @@ fn try_find_id_in_use(
338338
})
339339
};
340340

341-
let arguments = if call_name == b"use" {
341+
let arguments = if call_name != b"hide" {
342342
call.arguments.get(1..)?
343343
} else {
344344
call.arguments.as_slice()

0 commit comments

Comments
 (0)