@@ -31,6 +31,7 @@ extension PromptToCodePanel {
3131 let store : StoreOf < PromptToCode >
3232
3333 struct AttachButtonState : Equatable {
34+ var attachedToFilename : String
3435 var isAttachedToSelectionRange : Bool
3536 var selectionRange : CursorRange ?
3637 }
@@ -45,6 +46,7 @@ extension PromptToCodePanel {
4546 WithViewStore (
4647 store,
4748 observe: { AttachButtonState (
49+ attachedToFilename: $0. filename,
4850 isAttachedToSelectionRange: $0. isAttachedToSelectionRange,
4951 selectionRange: $0. selectionRange
5052 ) }
@@ -53,7 +55,7 @@ extension PromptToCodePanel {
5355 let color : Color = isAttached ? . indigo : . secondary. opacity ( 0.6 )
5456 HStack ( spacing: 4 ) {
5557 Image (
56- systemName: isAttached ? " bandage " : " character.cursor.ibeam "
58+ systemName: isAttached ? " link " : " character.cursor.ibeam "
5759 )
5860 . resizable ( )
5961 . aspectRatio ( contentMode: . fit)
@@ -68,13 +70,16 @@ extension PromptToCodePanel {
6870 )
6971 )
7072
71- let text : String = {
72- if isAttached, let range = viewStore. state. selectionRange {
73- return range. description
74- }
75- return " text cursor "
76- } ( )
77- Text ( text) . foregroundColor ( . primary)
73+ if isAttached {
74+ HStack ( spacing: 4 ) {
75+ Text ( viewStore. state. attachedToFilename)
76+ if let range = viewStore. state. selectionRange {
77+ Text ( range. description)
78+ }
79+ } . foregroundColor ( . primary)
80+ } else {
81+ Text ( " text selection " ) . foregroundColor ( . secondary)
82+ }
7883 }
7984 . padding ( 2 )
8085 . padding ( . trailing, 4 )
@@ -422,8 +427,8 @@ struct PromptToCodePanel_Preview: PreviewProvider {
422427 language: . builtIn( . swift) ,
423428 indentSize: 4 ,
424429 usesTabsForIndentation: false ,
425- projectRootURL: URL ( fileURLWithPath: " " ) ,
426- documentURL: URL ( fileURLWithPath: " " ) ,
430+ projectRootURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
431+ documentURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
427432 allCode: " " ,
428433 commandName: " Generate Code " ,
429434 description: " Hello world " ,
@@ -452,8 +457,8 @@ struct PromptToCodePanel_Error_Detached_Preview: PreviewProvider {
452457 language: . builtIn( . swift) ,
453458 indentSize: 4 ,
454459 usesTabsForIndentation: false ,
455- projectRootURL: URL ( fileURLWithPath: " " ) ,
456- documentURL: URL ( fileURLWithPath: " " ) ,
460+ projectRootURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
461+ documentURL: URL ( fileURLWithPath: " path/to/file.txt " ) ,
457462 allCode: " " ,
458463 commandName: " Generate Code " ,
459464 description: " Hello world " ,
0 commit comments