File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed
Core/Sources/SuggestionWidget/SuggestionPanelContent Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -433,7 +433,7 @@ extension PromptToCodePanelView {
433433 }
434434 }
435435 }
436-
436+
437437 Spacer ( minLength: 56 )
438438 }
439439 }
@@ -575,7 +575,7 @@ extension PromptToCodePanelView {
575575 presentAllContent: !isGenerating
576576 )
577577 } else {
578- ScrollView ( . horizontal ) {
578+ MinScrollView {
579579 CodeBlockInContent (
580580 store: store,
581581 language: language,
@@ -607,6 +607,37 @@ extension PromptToCodePanelView {
607607 }
608608 }
609609
610+ struct MinWidthPreferenceKey : PreferenceKey {
611+ static func reduce( value: inout CGFloat , nextValue: ( ) -> CGFloat ) {
612+ value = nextValue ( )
613+ }
614+
615+ static var defaultValue : CGFloat = 0
616+ }
617+
618+ struct MinScrollView < Content: View > : View {
619+ @ViewBuilder let content : Content
620+ @State var minWidth : CGFloat = 0
621+
622+ var body : some View {
623+ ScrollView ( . horizontal) {
624+ content
625+ . frame ( minWidth: minWidth)
626+ }
627+ . overlay {
628+ GeometryReader { proxy in
629+ Color . clear. preference (
630+ key: MinWidthPreferenceKey . self,
631+ value: proxy. size. width
632+ )
633+ }
634+ }
635+ . onPreferenceChange ( MinWidthPreferenceKey . self) {
636+ minWidth = $0
637+ }
638+ }
639+ }
640+
610641 struct CodeBlockInContent : View {
611642 let store : StoreOf < PromptToCodeSnippetPanel >
612643 let language : CodeLanguage
You can’t perform that action at this time.
0 commit comments