Skip to content

Commit fce24ad

Browse files
committed
gg.ui.track-recent-workspaces
1 parent 27143f1 commit fce24ad

7 files changed

Lines changed: 26 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Added
6+
- New config option `gg.ui.track-recent-workspaces`, which can be set to false to disable saving recent workspaces to the config file.
7+
58
### Fixed
69
- Another memory leak (failure to deregister RAF callbacks).
710
- Some broken graph rendering (which was relying on the previous leak!).

src-tauri/src/config/gg.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ large-repo-heuristic = 100000
1313
# Stores a list of recently opened directories for shell integration
1414
recent-workspaces = []
1515

16+
# When unset, GG will not update recent-workspaces or system jump lists.
17+
track-recent-workspaces = true
18+
1619
# When set, bookmarks that are local-only or remote-only will be visually indicated.
1720
mark-unpushed-bookmarks = true
1821

src-tauri/src/config/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub trait GGSettings {
1717
fn query_auto_snapshot(&self) -> Option<bool>;
1818
fn ui_theme_override(&self) -> Option<String>;
1919
fn ui_mark_unpushed_bookmarks(&self) -> bool;
20+
fn ui_track_recent_workspaces(&self) -> bool;
2021
#[allow(dead_code)]
2122
fn ui_recent_workspaces(&self) -> Vec<String>;
2223
}
@@ -46,6 +47,11 @@ impl GGSettings for UserSettings {
4647
)
4748
}
4849

50+
fn ui_track_recent_workspaces(&self) -> bool {
51+
self.get_bool("gg.ui.track-recent-workspaces")
52+
.unwrap_or(true)
53+
}
54+
4955
fn ui_recent_workspaces(&self) -> Vec<String> {
5056
self.get_value("gg.ui.recent-workspaces")
5157
.ok()

src-tauri/src/main.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,21 @@ fn try_open_repository(window: &Window, cwd: Option<PathBuf>) -> Result<()> {
568568
Ok(config) => {
569569
log::debug!("load workspace succeeded");
570570
match &config {
571-
messages::RepoConfig::Workspace { absolute_path, .. } => {
571+
messages::RepoConfig::Workspace {
572+
absolute_path,
573+
track_recent_workspaces,
574+
..
575+
} => {
572576
let repo_path = absolute_path.0.clone();
573577
window.set_title((String::from("GG - ") + repo_path.as_str()).as_str())?;
574578

575579
// update config and jump lists - this can be slow
576-
let window = window.clone();
577-
thread::spawn(move || {
578-
handler::nonfatal!(add_recent_workspaces(window, &repo_path));
579-
});
580+
if *track_recent_workspaces {
581+
let window = window.clone();
582+
thread::spawn(move || {
583+
handler::nonfatal!(add_recent_workspaces(window, &repo_path));
584+
});
585+
}
580586
}
581587
_ => {
582588
window.set_title("GG - Gui for JJ")?;

src-tauri/src/messages/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub enum RepoConfig {
8484
status: RepoStatus,
8585
theme_override: Option<String>,
8686
mark_unpushed_branches: bool,
87+
track_recent_workspaces: bool,
8788
},
8889
#[allow(dead_code)] // used by frontend
8990
TimeoutError,

src-tauri/src/worker/gui_util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ impl WorkspaceSession<'_> {
451451
status: self.format_status(),
452452
theme_override: self.data.workspace_settings.ui_theme_override(),
453453
mark_unpushed_branches: self.data.workspace_settings.ui_mark_unpushed_bookmarks(),
454+
track_recent_workspaces: self.data.workspace_settings.ui_track_recent_workspaces(),
454455
})
455456
}
456457

src/messages/RepoConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
import type { DisplayPath } from "./DisplayPath";
33
import type { RepoStatus } from "./RepoStatus";
44

5-
export type RepoConfig = { "type": "Initial" } | { "type": "Workspace", absolute_path: DisplayPath, git_remotes: Array<string>, default_query: string, latest_query: string, status: RepoStatus, theme_override: string | null, mark_unpushed_branches: boolean, } | { "type": "TimeoutError" } | { "type": "LoadError", absolute_path: DisplayPath, message: string, } | { "type": "WorkerError", message: string, };
5+
export type RepoConfig = { "type": "Initial" } | { "type": "Workspace", absolute_path: DisplayPath, git_remotes: Array<string>, default_query: string, latest_query: string, status: RepoStatus, theme_override: string | null, mark_unpushed_branches: boolean, track_recent_workspaces: boolean, } | { "type": "TimeoutError" } | { "type": "LoadError", absolute_path: DisplayPath, message: string, } | { "type": "WorkerError", message: string, };

0 commit comments

Comments
 (0)