fortrangoingonforty/facsimile / b1c2e03

Browse files

fix jump-to for shift-f12 references menu

Authored by espadonne
SHA
b1c2e039fa14cb7c404842c58829393a180ca45c
Parents
098cb2b
Tree
5dc80c9

1 changed file

StatusFile+-
M src/commands/command_handler_module.f90 38 1
src/commands/command_handler_module.f90modified
@@ -201,6 +201,28 @@ contains
201
 
201
 
202
         ! Route keys to references panel when visible
202
         ! Route keys to references panel when visible
203
         if (is_references_panel_visible(editor%references_panel)) then
203
         if (is_references_panel_visible(editor%references_panel)) then
204
+            ! Handle Enter specially - jump to reference location
205
+            if (trim(key_str) == 'enter') then
206
+                block
207
+                    use iso_fortran_env, only: int32
208
+                    character(len=:), allocatable :: uri
209
+                    integer(int32) :: ref_line, ref_col
210
+
211
+                    if (get_selected_reference_location(editor%references_panel, uri, ref_line, ref_col)) then
212
+                        ! Convert URI to file path and navigate
213
+                        if (len(uri) >= 7 .and. uri(1:7) == "file://") then
214
+                            ! Jump to the reference location
215
+                            editor%cursors(editor%active_cursor)%line = ref_line
216
+                            editor%cursors(editor%active_cursor)%column = ref_col
217
+                            ! Center the view on the target line
218
+                            editor%viewport_line = max(1, ref_line - editor%screen_rows / 2)
219
+                            ! Hide the panel after jumping
220
+                            call hide_references_panel(editor%references_panel)
221
+                        end if
222
+                    end if
223
+                end block
224
+                return
225
+            end if
204
             if (references_panel_handle_key(editor%references_panel, trim(key_str))) then
226
             if (references_panel_handle_key(editor%references_panel, trim(key_str))) then
205
                 return
227
                 return
206
             end if
228
             end if
@@ -1335,7 +1357,22 @@ contains
1335
                                         call render_screen(buffer, editor)
1357
                                         call render_screen(buffer, editor)
1336
                                         exit
1358
                                         exit
1337
                                     else if (key_input == 'enter') then
1359
                                     else if (key_input == 'enter') then
1338
-                                        ! TODO: Navigate to selected reference
1360
+                                        ! Navigate to selected reference
1361
+                                        block
1362
+                                            use references_panel_module, only: get_selected_reference_location
1363
+                                            character(len=:), allocatable :: ref_uri
1364
+                                            integer :: ref_line, ref_col
1365
+
1366
+                                            if (get_selected_reference_location(editor%references_panel, ref_uri, ref_line, ref_col)) then
1367
+                                                if (len(ref_uri) >= 7 .and. ref_uri(1:7) == "file://") then
1368
+                                                    ! Jump to the reference location
1369
+                                                    editor%cursors(editor%active_cursor)%line = ref_line
1370
+                                                    editor%cursors(editor%active_cursor)%column = ref_col
1371
+                                                    ! Center the view on the target line
1372
+                                                    editor%viewport_line = max(1, ref_line - editor%screen_rows / 2)
1373
+                                                end if
1374
+                                            end if
1375
+                                        end block
1339
                                         call hide_references_panel(editor%references_panel)
1376
                                         call hide_references_panel(editor%references_panel)
1340
                                         call render_screen(buffer, editor)
1377
                                         call render_screen(buffer, editor)
1341
                                         exit
1378
                                         exit