Skip to content

Commit

Permalink
Hiding branch picker in the toolbar when source control is disabled i…
Browse files Browse the repository at this point in the history
…n Settings by clearing the current branch stored in the source control manager.
  • Loading branch information
austincondiff committed Oct 29, 2024
1 parent 7adc787 commit 5eb0f7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 8 additions & 4 deletions CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ struct ToolbarBranchPicker: View {
isHovering = active
}
.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { (_) in
Task {
await sourceControlManager?.refreshCurrentBranch()
if self.currentBranch != nil {
Task {
await sourceControlManager?.refreshCurrentBranch()
}
}
}
.onReceive(
Expand All @@ -82,8 +84,10 @@ struct ToolbarBranchPicker: View {
self.currentBranch = branch
}
.task {
await self.sourceControlManager?.refreshCurrentBranch()
await self.sourceControlManager?.refreshBranches()
if Settings.shared.preferences.sourceControl.general.enableSourceControl {
await self.sourceControlManager?.refreshCurrentBranch()
await self.sourceControlManager?.refreshBranches()
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions CodeEdit/WorkspaceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ struct WorkspaceView: View {
@AppSettings(\.theme.matchAppearance)
var matchAppearance

@AppSettings(\.sourceControl.general.enableSourceControl)
var enableSourceControl

@EnvironmentObject private var workspace: WorkspaceDocument
@EnvironmentObject private var editorManager: EditorManager
@EnvironmentObject private var utilityAreaViewModel: UtilityAreaViewModel
Expand Down Expand Up @@ -130,6 +133,15 @@ struct WorkspaceView: View {
: themeModel.selectedLightTheme
}
}
.onChange(of: enableSourceControl) { newValue in
if !newValue {
Task {
await sourceControlManager.refreshCurrentBranch()
}
} else {
sourceControlManager.currentBranch = nil
}
}
.onChange(of: focusedEditor) { newValue in
/// Update active tab group only if the new one is not the same with it.
if let newValue, editorManager.activeEditor != newValue {
Expand Down

0 comments on commit 5eb0f7f

Please sign in to comment.