@@ -22,16 +22,15 @@ class EditorContextMenu {
2222 func buildContextMenu( hasSelection: Bool ) -> UIMenu {
2323 var menuItems : [ UIMenuElement ] = [ ]
2424
25+ let commandSection = buildCommandSection ( )
26+ menuItems. append ( commandSection)
27+
2528 // AI Features Section (if has selection)
2629 if hasSelection {
2730 let aiSection = buildAISection ( )
2831 menuItems. append ( aiSection)
2932 }
3033
31- // Basic Editing Section
32- let editingSection = buildEditingSection ( hasSelection: hasSelection)
33- menuItems. append ( editingSection)
34-
3534 // Code Actions Section
3635 if hasSelection {
3736 let codeActionsSection = buildCodeActionsSection ( )
@@ -93,62 +92,38 @@ class EditorContextMenu {
9392 )
9493 }
9594
96- private func buildEditingSection( hasSelection: Bool ) -> UIMenu {
97- var actions : [ UIAction ] = [ ]
98-
99- if hasSelection {
100- let cutAction = UIAction (
101- title: NSLocalizedString ( " Cut " , comment: " " ) ,
102- image: UIImage ( systemName: " scissors " )
103- ) { [ weak self] _ in
104- Task {
105- await self ? . editorImplementation? . cutSelection ( )
106- }
107- }
108- actions. append ( cutAction)
109-
110- let copyAction = UIAction (
111- title: NSLocalizedString ( " Copy " , comment: " " ) ,
112- image: UIImage ( systemName: " doc.on.doc " )
113- ) { [ weak self] _ in
114- Task {
115- if let text = await self ? . editorImplementation? . copySelection ( ) {
116- UIPasteboard . general. string = text
117- }
118- }
95+ private func buildCommandSection( ) -> UIMenu {
96+ let commandPaletteAction = UIAction (
97+ title: NSLocalizedString ( " Command Palette... " , comment: " " ) ,
98+ image: UIImage ( systemName: " command " )
99+ ) { [ weak self] _ in
100+ Task {
101+ await self ? . editorImplementation? . _toggleCommandPalatte ( )
119102 }
120- actions. append ( copyAction)
121103 }
122104
123- let pasteAction = UIAction (
124- title: NSLocalizedString ( " Paste " , comment: " " ) ,
125- image: UIImage ( systemName: " doc.on.clipboard " )
105+ let goToLineAction = UIAction (
106+ title: NSLocalizedString ( " Go to Line... " , comment: " " ) ,
107+ image: UIImage ( systemName: " number " )
126108 ) { [ weak self] _ in
127- if let text = UIPasteboard . general. string {
128- Task {
129- await self ? . editorImplementation? . pasteText ( text: text)
130- }
109+ Task {
110+ await self ? . editorImplementation? . _toggleGoToLineWidget ( )
131111 }
132112 }
133- actions. append ( pasteAction)
134113
135- if hasSelection {
136- let deleteAction = UIAction (
137- title: NSLocalizedString ( " Delete " , comment: " " ) ,
138- image: UIImage ( systemName: " trash " ) ,
139- attributes: . destructive
140- ) { [ weak self] _ in
141- Task {
142- await self ? . editorImplementation? . deleteSelection ( )
143- }
114+ let formatDocumentAction = UIAction (
115+ title: NSLocalizedString ( " Format Document " , comment: " " ) ,
116+ image: UIImage ( systemName: " doc.text " )
117+ ) { [ weak self] _ in
118+ Task {
119+ await self ? . editorImplementation? . formatDocument ( )
144120 }
145- actions. append ( deleteAction)
146121 }
147122
148123 return UIMenu (
149124 title: " " ,
150125 options: . displayInline,
151- children: actions
126+ children: [ commandPaletteAction , goToLineAction , formatDocumentAction ]
152127 )
153128 }
154129
@@ -194,26 +169,6 @@ class EditorContextMenu {
194169 }
195170 actions. append ( renameAction)
196171
197- let formatDocumentAction = UIAction (
198- title: NSLocalizedString ( " Format Document " , comment: " " ) ,
199- image: UIImage ( systemName: " doc.text " )
200- ) { [ weak self] _ in
201- Task {
202- await self ? . editorImplementation? . formatDocument ( )
203- }
204- }
205- actions. append ( formatDocumentAction)
206-
207- let commandPaletteAction = UIAction (
208- title: NSLocalizedString ( " Command Palette... " , comment: " " ) ,
209- image: UIImage ( systemName: " command " )
210- ) { [ weak self] _ in
211- Task {
212- await self ? . editorImplementation? . _toggleCommandPalatte ( )
213- }
214- }
215- actions. append ( commandPaletteAction)
216-
217172 return UIMenu (
218173 title: " " ,
219174 options: . displayInline,
0 commit comments