@@ -162,6 +162,18 @@ fn project_icon_group_key(path: &Path) -> String {
162162 }
163163}
164164
165+ fn project_icon_root_key ( root : & Path ) -> String {
166+ root. to_string_lossy ( ) . into_owned ( )
167+ }
168+
169+ fn project_icon_candidate_group_key ( root : & Path , path : & Path ) -> String {
170+ format ! (
171+ "{}:{}" ,
172+ project_icon_root_key( root) ,
173+ project_icon_group_key( path)
174+ )
175+ }
176+
165177fn read_project_icon_data_url ( path : & Path ) -> Result < String , String > {
166178 let metadata = fs:: metadata ( path) . map_err ( |e| format ! ( "Failed to inspect icon: {}" , e) ) ?;
167179 if !metadata. is_file ( ) {
@@ -236,7 +248,7 @@ pub fn scan_project_icons(working_dirs: Vec<String>) -> Result<Vec<ProjectIconCa
236248 let relative = path. strip_prefix ( & root) . unwrap_or ( path) ;
237249 let label = relative. to_string_lossy ( ) . into_owned ( ) ;
238250 let score = project_icon_score ( & root, path) ;
239- let group_key = format ! ( "{}:{}" , source_dir , project_icon_group_key ( path) ) ;
251+ let group_key = project_icon_candidate_group_key ( & root , path) ;
240252 candidates. push ( ScoredProjectIconPath {
241253 score,
242254 path : path. to_path_buf ( ) ,
@@ -304,4 +316,17 @@ mod tests {
304316
305317 assert ! ( is_ignored_icon_search_dir( root, & icon) ) ;
306318 }
319+
320+ #[ test]
321+ fn project_icon_group_keys_distinguish_roots_with_same_basename ( ) {
322+ let first_root = Path :: new ( "/work/client" ) ;
323+ let second_root = Path :: new ( "/archive/client" ) ;
324+ let first_icon = first_root. join ( "public/logo.svg" ) ;
325+ let second_icon = second_root. join ( "public/logo.svg" ) ;
326+
327+ assert_ne ! (
328+ project_icon_candidate_group_key( first_root, & first_icon) ,
329+ project_icon_candidate_group_key( second_root, & second_icon)
330+ ) ;
331+ }
307332}
0 commit comments