mirror of
https://github.com/nushell/nushell.git
synced 2025-03-26 23:36:20 +01:00
Fix the colors when completing using a relative path (#12898)
# Description Fixes a bug where the autocompletion menu has the wrong colors due to 'std::fs::symlink_metadata' not being able to handle relative paths. Attached below are screenshots before and after applying the commit, in which the colors are wrong when autocompleting on a path prefixed by a tilde, whereas the same directory is highlighted correctly when prefixed by a dot. BEFORE:   AFTER:  
This commit is contained in:
parent
d6a9fb0e40
commit
cfe13397ed
@ -1,7 +1,7 @@
|
||||
use crate::completions::{matches, CompletionOptions};
|
||||
use nu_ansi_term::Style;
|
||||
use nu_engine::env_to_string;
|
||||
use nu_path::home_dir;
|
||||
use nu_path::{expand_to_real_path, home_dir};
|
||||
use nu_protocol::{
|
||||
engine::{EngineState, Stack, StateWorkingSet},
|
||||
Span,
|
||||
@ -185,9 +185,14 @@ pub fn complete_item(
|
||||
.map(|p| {
|
||||
let path = original_cwd.apply(p);
|
||||
let style = ls_colors.as_ref().map(|lsc| {
|
||||
lsc.style_for_path_with_metadata(&path, std::fs::symlink_metadata(&path).ok().as_ref())
|
||||
.map(lscolors::Style::to_nu_ansi_term_style)
|
||||
.unwrap_or_default()
|
||||
lsc.style_for_path_with_metadata(
|
||||
&path,
|
||||
std::fs::symlink_metadata(expand_to_real_path(&path))
|
||||
.ok()
|
||||
.as_ref(),
|
||||
)
|
||||
.map(lscolors::Style::to_nu_ansi_term_style)
|
||||
.unwrap_or_default()
|
||||
});
|
||||
(span, escape_path(path, want_directory), style)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user