fortrangoingonforty/facsimile / 8c77d81

Browse files

fix jump-to from symbols panel

Authored by espadonne
SHA
8c77d814e997c2f769ee8f1c336002f4372c6abb
Parents
7f29919
Tree
07f33e9

2 changed files

StatusFile+-
M src/commands/command_handler_module.f90 30 38
M src/ui/symbols_panel_module.f90 4 2
src/commands/command_handler_module.f90modified
@@ -208,6 +208,23 @@ contains
208208
 
209209
         ! Route keys to symbols panel when visible
210210
         if (is_symbols_panel_visible(editor%symbols_panel)) then
211
+            ! Handle Enter specially - jump to symbol location
212
+            if (trim(key_str) == 'enter') then
213
+                block
214
+                    use iso_fortran_env, only: int32
215
+                    integer(int32) :: sym_line, sym_col
216
+                    if (get_selected_symbol_location(editor%symbols_panel, sym_line, sym_col)) then
217
+                        ! Jump to the symbol location
218
+                        editor%cursors(editor%active_cursor)%line = sym_line
219
+                        editor%cursors(editor%active_cursor)%column = sym_col
220
+                        ! Center the view on the target line
221
+                        editor%viewport_line = max(1, sym_line - editor%screen_rows / 2)
222
+                        ! Hide the panel after jumping
223
+                        call hide_symbols_panel(editor%symbols_panel)
224
+                    end if
225
+                end block
226
+                return
227
+            end if
211228
             if (symbols_panel_handle_key(editor%symbols_panel, trim(key_str))) then
212229
                 return
213230
             end if
@@ -5959,16 +5976,6 @@ contains
59595976
         result_array = response%result
59605977
         num_symbols = json_array_size(result_array)
59615978
 
5962
-        ! Debug: log to file
5963
-        block
5964
-            integer :: dbg_unit
5965
-            open(newunit=dbg_unit, file='/tmp/fac_symbols_debug.log', status='replace', action='write')
5966
-            write(dbg_unit, '(A,I0)') 'result_array%value_type = ', result_array%value_type
5967
-            write(dbg_unit, '(A,L1)') 'result_array%array_value associated = ', associated(result_array%array_value)
5968
-            write(dbg_unit, '(A,I0)') 'num_symbols = ', num_symbols
5969
-            close(dbg_unit)
5970
-        end block
5971
-
59725979
         if (num_symbols == 0) then
59735980
             call clear_symbols(editor%symbols_panel)
59745981
             call terminal_move_cursor(editor%screen_rows, 1)
@@ -5980,31 +5987,19 @@ contains
59805987
         allocate(symbols(num_symbols))
59815988
 
59825989
         ! Parse each symbol
5983
-        block
5984
-            integer :: dbg_unit
5985
-            open(newunit=dbg_unit, file='/tmp/fac_symbols_debug.log', status='old', position='append', action='write')
5986
-
5987
-            do i = 1, num_symbols
5988
-                ! json_get_array_element expects 0-based index
5989
-                symbol_obj = json_get_array_element(result_array, i - 1)
5990
-
5991
-                write(dbg_unit, '(A,I0,A,I0)') 'Symbol ', i, ': value_type = ', symbol_obj%value_type
5992
-                write(dbg_unit, '(A,L1)') '  object_value associated = ', associated(symbol_obj%object_value)
5993
-                if (associated(symbol_obj%object_value)) then
5994
-                    write(dbg_unit, '(A,I0)') '  object pair count = ', symbol_obj%object_value%count
5995
-                end if
5996
-                write(dbg_unit, '(A,L1)') '  has_key(name) = ', json_has_key(symbol_obj, 'name')
5997
-
5998
-                ! Get symbol name (required)
5999
-                if (json_has_key(symbol_obj, 'name')) then
6000
-                    name = json_get_string(symbol_obj, 'name', '')
6001
-                    write(dbg_unit, '(A,I0,A,A,A)') '  name len=', len(name), ' value="', trim(name), '"'
6002
-                    if (len(name) > 0) then
6003
-                        if (allocated(symbols(i)%name)) deallocate(symbols(i)%name)
6004
-                        allocate(character(len=len(name)) :: symbols(i)%name)
6005
-                        symbols(i)%name = name
6006
-                    end if
5990
+        do i = 1, num_symbols
5991
+            ! json_get_array_element expects 0-based index
5992
+            symbol_obj = json_get_array_element(result_array, i - 1)
5993
+
5994
+            ! Get symbol name (required)
5995
+            if (json_has_key(symbol_obj, 'name')) then
5996
+                name = json_get_string(symbol_obj, 'name', '')
5997
+                if (len(name) > 0) then
5998
+                    if (allocated(symbols(i)%name)) deallocate(symbols(i)%name)
5999
+                    allocate(character(len=len(name)) :: symbols(i)%name)
6000
+                    symbols(i)%name = name
60076001
                 end if
6002
+            end if
60086003
 
60096004
             ! Get detail (optional)
60106005
             if (json_has_key(symbol_obj, 'detail')) then
@@ -6083,10 +6078,7 @@ contains
60836078
 
60846079
             symbols(i)%depth = 0  ! Top level
60856080
             symbols(i)%is_expanded = .true.
6086
-            end do
6087
-
6088
-            close(dbg_unit)
6089
-        end block
6081
+        end do
60906082
 
60916083
         ! Update the symbols panel
60926084
         call set_symbols(editor%symbols_panel, symbols, num_symbols)
src/ui/symbols_panel_module.f90modified
@@ -455,23 +455,25 @@ contains
455455
 
456456
         select case(trim(key))
457457
         case('j', 'down')
458
+            ! Always handle to clamp at boundary
459
+            handled = .true.
458460
             if (panel%selected_index < panel%num_flat_symbols) then
459461
                 panel%selected_index = panel%selected_index + 1
460462
                 ! Adjust scroll if needed
461463
                 if (panel%selected_index > panel%scroll_offset + panel%max_visible) then
462464
                     panel%scroll_offset = panel%selected_index - panel%max_visible
463465
                 end if
464
-                handled = .true.
465466
             end if
466467
 
467468
         case('k', 'up')
469
+            ! Always handle to clamp at boundary
470
+            handled = .true.
468471
             if (panel%selected_index > 1) then
469472
                 panel%selected_index = panel%selected_index - 1
470473
                 ! Adjust scroll if needed
471474
                 if (panel%selected_index <= panel%scroll_offset) then
472475
                     panel%scroll_offset = max(0, panel%selected_index - 1)
473476
                 end if
474
-                handled = .true.
475477
             end if
476478
 
477479
         case('g')