mirror of
https://github.com/nushell/nushell.git
synced 2025-05-28 22:07:40 +02:00
fix(completion): ls_color for ~/xxx
symlinks (#15403)
# Description Get style with expanded real path, so that symlinks get highlighted correctly. # User-Facing Changes Before: <img width="255" alt="image" src="https://github.com/user-attachments/assets/b1a11cb8-e3d3-4287-bb3b-7d0ec36ba51f" /> After: <img width="255" alt="image" src="https://github.com/user-attachments/assets/71476b2c-6a31-4d37-8d25-b187a6b4e4d5" /> # Tests + Formatting # After Submitting
This commit is contained in:
parent
6aed1b42ae
commit
bf1f2d5ebd
@ -199,10 +199,9 @@ pub fn complete_item(
|
||||
let ls_colors = (engine_state.config.completions.use_ls_colors
|
||||
&& engine_state.config.use_ansi_coloring.get(engine_state))
|
||||
.then(|| {
|
||||
let ls_colors_env_str = match stack.get_env_var(engine_state, "LS_COLORS") {
|
||||
Some(v) => env_to_string("LS_COLORS", v, engine_state, stack).ok(),
|
||||
None => None,
|
||||
};
|
||||
let ls_colors_env_str = stack
|
||||
.get_env_var(engine_state, "LS_COLORS")
|
||||
.and_then(|v| env_to_string("LS_COLORS", v, engine_state, stack).ok());
|
||||
get_ls_colors(ls_colors_env_str)
|
||||
});
|
||||
|
||||
@ -264,15 +263,12 @@ pub fn complete_item(
|
||||
}
|
||||
let is_dir = p.isdir;
|
||||
let path = original_cwd.apply(p, path_separator);
|
||||
let real_path = expand_to_real_path(&path);
|
||||
let metadata = std::fs::symlink_metadata(&real_path).ok();
|
||||
let style = ls_colors.as_ref().map(|lsc| {
|
||||
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()
|
||||
lsc.style_for_path_with_metadata(&real_path, metadata.as_ref())
|
||||
.map(lscolors::Style::to_nu_ansi_term_style)
|
||||
.unwrap_or_default()
|
||||
});
|
||||
FileSuggestion {
|
||||
span,
|
||||
|
Loading…
x
Reference in New Issue
Block a user