project panel: Update file icon when editing filename (#12078)

d1y and Kirill Bulatov created

Before:


![before](https://github.com/zed-industries/zed/assets/45585937/1590586d-9d42-4d44-85fc-8e79499408b3)

After:


![after](https://github.com/zed-industries/zed/assets/45585937/c0fd1b2a-1ecf-4403-b74a-25c3c700f00d)

Release Notes:

- Update file icons during editing in project panel

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>

Change summary

crates/project_panel/src/project_panel.rs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

Detailed changes

crates/project_panel/src/project_panel.rs 🔗

@@ -1685,7 +1685,13 @@ impl ProjectPanel {
         let filename_text_color =
             entry_git_aware_label_color(details.git_status, details.is_ignored, is_selected);
         let file_name = details.filename.clone();
-        let icon = details.icon.clone();
+        let mut icon = details.icon.clone();
+        if show_editor && details.kind.is_file() {
+            let filename = self.filename_editor.read(cx).text(cx);
+            if filename.len() > 2 {
+                icon = FileIcons::get_icon(Path::new(&filename), cx);
+            }
+        }
         let depth = details.depth;
         div()
             .id(entry_id.to_proto() as usize)