From 0853cb573f2d5abe4c3f3e38df55d96673921c52 Mon Sep 17 00:00:00 2001 From: CharlesChen0823 Date: Thu, 29 Aug 2024 04:28:09 +0800 Subject: [PATCH] file_finder: Fix crash in new_path_prompt (#16991) Closes #16919 repro step: - add two worktree - modify settings `"use_system_path_prompts" : false` - `ctrl-n` create new file, typing any chars. - `ctrl-s` save file - typing any char, crashed. Release Notes: - Fixed crashed when setting `"use_system_path_prompts": false` or in remote project with two or more worktree. --- crates/file_finder/src/new_path_prompt.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/file_finder/src/new_path_prompt.rs b/crates/file_finder/src/new_path_prompt.rs index 2d5be8dae12ec2e540ea32b08fbd750b8ef6dc0c..e992dd315fa729c6f63adfd10a98aecf5f9e4cca 100644 --- a/crates/file_finder/src/new_path_prompt.rs +++ b/crates/file_finder/src/new_path_prompt.rs @@ -107,8 +107,10 @@ impl Match { if let Some(path_match) = &self.path_match { text.push_str(&path_match.path.to_string_lossy()); + let mut whole_path = PathBuf::from(path_match.path_prefix.to_string()); + whole_path = whole_path.join(path_match.path.clone()); for (range, style) in highlight_ranges( - &path_match.path.to_string_lossy(), + &whole_path.to_string_lossy(), &path_match.positions, gpui::HighlightStyle::color(Color::Accent.color(cx)), ) {