mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:12:46 +00:00 
			
		
		
		
	FileManager: Navigate to parent dir when current location is removed
When the location currently displayed in FileManager is removed, find the nearest existing parent path and open it in the window. Without the fix, the FileManager window remained in the deleted directory. Changing the path in 'DirectoryView' object will automatically update other components in the FileManager (breadcrumb bar, directory tree view).
This commit is contained in:
		
							parent
							
								
									f7e6593910
								
							
						
					
					
						commit
						aa466723eb
					
				
					 3 changed files with 15 additions and 0 deletions
				
			
		|  | @ -196,6 +196,19 @@ void DirectoryView::setup_model() | |||
|             on_path_change(model().root_path(), true, can_write_in_path); | ||||
|     }; | ||||
| 
 | ||||
|     m_model->on_root_path_removed = [this] { | ||||
|         // Change model root to the first existing parent directory.
 | ||||
|         LexicalPath model_root(model().root_path()); | ||||
| 
 | ||||
|         while (model_root.string() != "/") { | ||||
|             model_root = model_root.parent(); | ||||
|             if (Core::File::is_directory(model_root.string())) | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|         open(model_root.string()); | ||||
|     }; | ||||
| 
 | ||||
|     m_model->register_client(*this); | ||||
| 
 | ||||
|     m_model->on_thumbnail_progress = [this](int done, int total) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Adam Jakubek
						Adam Jakubek