File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Service/SuggestionCommandHandler
SuggestionWidget/FeatureReducers Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -410,7 +410,8 @@ extension WindowBaseCommandHandler {
410410 let viewStore = Service . shared. guiController. viewStore
411411
412412 _ = await Task { @MainActor in
413- viewStore. send ( . promptToCodeGroup( . createPromptToCode( . init(
413+ // if there is already a prompt to code presenting, we should not present another one
414+ viewStore. send ( . promptToCodeGroup( . activateOrCreatePromptToCode( . init(
414415 code: code,
415416 selectionRange: selection,
416417 language: codeLanguage,
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ public struct PromptToCodeGroup: ReducerProtocol {
6767 }
6868
6969 public enum Action : Equatable {
70+ /// Activate the prompt to code if it exists or create it if it doesn't
71+ case activateOrCreatePromptToCode( PromptToCodeInitialState )
7072 case createPromptToCode( PromptToCodeInitialState )
7173 case updatePromptToCodeRange( id: PromptToCode . State . ID , range: CursorRange )
7274 case discardAcceptedPromptToCodeIfNotContinuous( id: PromptToCode . State . ID )
@@ -80,6 +82,13 @@ public struct PromptToCodeGroup: ReducerProtocol {
8082 public var body : some ReducerProtocol < State , Action > {
8183 Reduce { state, action in
8284 switch action {
85+ case let . activateOrCreatePromptToCode( s) :
86+ guard state. activePromptToCode == nil else {
87+ return . none
88+ }
89+ return . run { send in
90+ await send ( . createPromptToCode( s) )
91+ }
8392 case let . createPromptToCode( s) :
8493 let newPromptToCode = PromptToCode . State (
8594 code: s. code,
You can’t perform that action at this time.
0 commit comments