File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -182,7 +182,8 @@ final class FavoritesSidebarViewModel {
182182 switch item {
183183 case . favorite( let fav) :
184184 if fav. name. localizedCaseInsensitiveContains ( searchText) ||
185- ( fav. keyword? . localizedCaseInsensitiveContains ( searchText) == true ) {
185+ ( fav. keyword? . localizedCaseInsensitiveContains ( searchText) == true ) ||
186+ fav. query. localizedCaseInsensitiveContains ( searchText) {
186187 return item
187188 }
188189 return nil
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ final class AIEditorContextMenu: NSMenu, NSMenuDelegate {
1212 /// Closure provided by the coordinator to check if text is selected
1313 var hasSelection : ( ( ) -> Bool ) ?
1414 var selectedText : ( ( ) -> String ? ) ?
15+ var fullText : ( ( ) -> String ? ) ?
1516 var onExplainWithAI : ( ( String ) -> Void ) ?
1617 var onOptimizeWithAI : ( ( String ) -> Void ) ?
1718 var onSaveAsFavorite : ( ( String ) -> Void ) ?
@@ -55,6 +56,7 @@ final class AIEditorContextMenu: NSMenu, NSMenuDelegate {
5556 )
5657 saveAsFavItem. target = self
5758 saveAsFavItem. image = NSImage ( systemSymbolName: " star " , accessibilityDescription: nil )
59+ saveAsFavItem. isEnabled = ( fullText ? ( ) ? . isEmpty == false )
5860 menu. addItem ( saveAsFavItem)
5961
6062 // AI items — only when text is selected
@@ -96,8 +98,8 @@ final class AIEditorContextMenu: NSMenu, NSMenuDelegate {
9698 @objc private func handleSaveAsFavorite( ) {
9799 if let text = selectedText ? ( ) , !text. isEmpty {
98100 onSaveAsFavorite ? ( text)
99- } else {
100- onSaveAsFavorite ? ( " " )
101+ } else if let text = fullText ? ( ) , !text . isEmpty {
102+ onSaveAsFavorite ? ( text )
101103 }
102104 }
103105}
Original file line number Diff line number Diff line change @@ -165,6 +165,9 @@ final class SQLEditorCoordinator: TextViewCoordinator {
165165 guard range. length > 0 else { return nil }
166166 return ( textView. string as NSString ) . substring ( with: range)
167167 }
168+ menu. fullText = { [ weak controller] in
169+ controller? . textView? . string
170+ }
168171 menu. onExplainWithAI = { [ weak self] text in self ? . onAIExplain ? ( text) }
169172 menu. onOptimizeWithAI = { [ weak self] text in self ? . onAIOptimize ? ( text) }
170173 menu. onSaveAsFavorite = { [ weak self] text in self ? . onSaveAsFavorite ? ( text) }
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ struct FavoriteEditDialog: View {
107107 keyword = fav. keyword ?? " "
108108 isGlobal = forceGlobal || fav. connectionId == nil
109109 } else {
110- isGlobal = true
110+ isGlobal = forceGlobal
111111 if let q = initialQuery {
112112 query = q
113113 }
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ struct SidebarView: View {
8282 . opacity ( sidebarState. selectedSidebarTab == . tables ? 1 : 0 )
8383 . frame ( maxHeight: sidebarState. selectedSidebarTab == . tables ? . infinity : 0 )
8484 . clipped ( )
85+ . allowsHitTesting ( sidebarState. selectedSidebarTab == . tables)
8586
8687 FavoritesTabView (
8788 connectionId: connectionId,
@@ -91,6 +92,7 @@ struct SidebarView: View {
9192 . opacity ( sidebarState. selectedSidebarTab == . favorites ? 1 : 0 )
9293 . frame ( maxHeight: sidebarState. selectedSidebarTab == . favorites ? . infinity : 0 )
9394 . clipped ( )
95+ . allowsHitTesting ( sidebarState. selectedSidebarTab == . favorites)
9496 }
9597 . animation ( . easeInOut( duration: 0.18 ) , value: sidebarState. selectedSidebarTab)
9698 . safeAreaInset ( edge: . top, spacing: 0 ) {
You can’t perform that action at this time.
0 commit comments