@@ -12,8 +12,9 @@ struct SourceControlNavigatorToolbarBottom: View {
12
12
@EnvironmentObject var sourceControlManager : SourceControlManager
13
13
14
14
@State private var text = " "
15
- @State private var stashChangesIsPresented : Bool = false
16
- @State private var noChangesToStashIsPresented : Bool = false
15
+ @State private var stashChangesIsPresented = false
16
+ @State private var noChangesToStashIsPresented = false
17
+ @State private var noDiscardChangesIsPresented = false
17
18
18
19
var body : some View {
19
20
HStack ( spacing: 5 ) {
@@ -49,6 +50,11 @@ struct SourceControlNavigatorToolbarBottom: View {
49
50
private var sourceControlMenu : some View {
50
51
Menu {
51
52
Button ( " Discard All Changes... " ) {
53
+ guard let sourceControlManager = workspace. sourceControlManager else { return }
54
+ if sourceControlManager. changedFiles. isEmpty {
55
+ noDiscardChangesIsPresented = true
56
+ return
57
+ }
52
58
if discardChangesDialog ( ) {
53
59
workspace. sourceControlManager? . discardAllChanges ( )
54
60
}
@@ -75,6 +81,11 @@ struct SourceControlNavigatorToolbarBottom: View {
75
81
} message: {
76
82
Text ( " There are no uncommitted changes in the local repository for this project. " )
77
83
}
84
+ . alert ( " Cannot Discard Changes " , isPresented: $noDiscardChangesIsPresented) {
85
+ Button ( " OK " , role: . cancel) { }
86
+ } message: {
87
+ Text ( " There are no uncommitted changes in the local repository for this project. " )
88
+ }
78
89
}
79
90
80
91
/// Renders a Discard Changes Dialog
0 commit comments