mirror of
https://github.com/nushell/nushell.git
synced 2025-05-30 06:39:33 +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
|
let ls_colors = (engine_state.config.completions.use_ls_colors
|
||||||
&& engine_state.config.use_ansi_coloring.get(engine_state))
|
&& engine_state.config.use_ansi_coloring.get(engine_state))
|
||||||
.then(|| {
|
.then(|| {
|
||||||
let ls_colors_env_str = match stack.get_env_var(engine_state, "LS_COLORS") {
|
let ls_colors_env_str = stack
|
||||||
Some(v) => env_to_string("LS_COLORS", v, engine_state, stack).ok(),
|
.get_env_var(engine_state, "LS_COLORS")
|
||||||
None => None,
|
.and_then(|v| env_to_string("LS_COLORS", v, engine_state, stack).ok());
|
||||||
};
|
|
||||||
get_ls_colors(ls_colors_env_str)
|
get_ls_colors(ls_colors_env_str)
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -264,15 +263,12 @@ pub fn complete_item(
|
|||||||
}
|
}
|
||||||
let is_dir = p.isdir;
|
let is_dir = p.isdir;
|
||||||
let path = original_cwd.apply(p, path_separator);
|
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| {
|
let style = ls_colors.as_ref().map(|lsc| {
|
||||||
lsc.style_for_path_with_metadata(
|
lsc.style_for_path_with_metadata(&real_path, metadata.as_ref())
|
||||||
&path,
|
.map(lscolors::Style::to_nu_ansi_term_style)
|
||||||
std::fs::symlink_metadata(expand_to_real_path(&path))
|
.unwrap_or_default()
|
||||||
.ok()
|
|
||||||
.as_ref(),
|
|
||||||
)
|
|
||||||
.map(lscolors::Style::to_nu_ansi_term_style)
|
|
||||||
.unwrap_or_default()
|
|
||||||
});
|
});
|
||||||
FileSuggestion {
|
FileSuggestion {
|
||||||
span,
|
span,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user