History manager (#26369)
While working on implementing `add_recent_documents` for Windows, I found that the process is significantly more complex compared to macOS. On macOS, simply registering the `add_recent_documents` function is enough, as the system handles everything automatically. On Windows, however, there are two cases to consider: - **Files opened by the app**: These appear in the "Recent" section (as shown in the screenshot, "test.txt") and are managed automatically by Windows (by setting windows registry), similar to macOS.  - **Folders opened by the app**: This is more complicated because Windows does not handle it automatically, requiring the application to track opened folders manually. To address this, this PR introduces a `History Manager` along with `HistoryManagerEvent::Update` and `HistoryManagerEvent::Delete` events to simplify the process of managing recently opened folders. https://github.com/user-attachments/assets/a2581c15-7653-4faf-96b0-7c48ab1dcc8d Release Notes: - N/A --------- Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
5734ffbb18
commit
a5fe6d1e61
14 changed files with 482 additions and 66 deletions
|
@ -24,8 +24,8 @@ use std::{
|
|||
use ui::{KeyBinding, ListItem, ListItemSpacing, Tooltip, prelude::*, tooltip_container};
|
||||
use util::{ResultExt, paths::PathExt};
|
||||
use workspace::{
|
||||
CloseIntent, ModalView, OpenOptions, SerializedWorkspaceLocation, WORKSPACE_DB, Workspace,
|
||||
WorkspaceId,
|
||||
CloseIntent, HistoryManager, ModalView, OpenOptions, SerializedWorkspaceLocation, WORKSPACE_DB,
|
||||
Workspace, WorkspaceId,
|
||||
};
|
||||
use zed_actions::{OpenRecent, OpenRemote};
|
||||
|
||||
|
@ -553,7 +553,13 @@ impl RecentProjectsDelegate {
|
|||
.delegate
|
||||
.set_selected_index(ix.saturating_sub(1), window, cx);
|
||||
picker.delegate.reset_selected_match_index = false;
|
||||
picker.update_matches(picker.query(cx), window, cx)
|
||||
picker.update_matches(picker.query(cx), window, cx);
|
||||
// After deleting a project, we want to update the history manager to reflect the change.
|
||||
// But we do not emit a update event when user opens a project, because it's handled in `workspace::load_workspace`.
|
||||
if let Some(history_manager) = HistoryManager::global(cx) {
|
||||
history_manager
|
||||
.update(cx, |this, cx| this.delete_history(workspace_id, cx));
|
||||
}
|
||||
})
|
||||
})
|
||||
.detach();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue