@@ -208,6 +208,23 @@ contains |
| 208 | | 208 | |
| 209 | ! Route keys to symbols panel when visible | 209 | ! Route keys to symbols panel when visible |
| 210 | if (is_symbols_panel_visible(editor%symbols_panel)) then | 210 | 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 |
| 211 | if (symbols_panel_handle_key(editor%symbols_panel, trim(key_str))) then | 228 | if (symbols_panel_handle_key(editor%symbols_panel, trim(key_str))) then |
| 212 | return | 229 | return |
| 213 | end if | 230 | end if |
@@ -5959,16 +5976,6 @@ contains |
| 5959 | result_array = response%result | 5976 | result_array = response%result |
| 5960 | num_symbols = json_array_size(result_array) | 5977 | num_symbols = json_array_size(result_array) |
| 5961 | | 5978 | |
| 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 | - | | |
| 5972 | if (num_symbols == 0) then | 5979 | if (num_symbols == 0) then |
| 5973 | call clear_symbols(editor%symbols_panel) | 5980 | call clear_symbols(editor%symbols_panel) |
| 5974 | call terminal_move_cursor(editor%screen_rows, 1) | 5981 | call terminal_move_cursor(editor%screen_rows, 1) |
@@ -5980,31 +5987,19 @@ contains |
| 5980 | allocate(symbols(num_symbols)) | 5987 | allocate(symbols(num_symbols)) |
| 5981 | | 5988 | |
| 5982 | ! Parse each symbol | 5989 | ! Parse each symbol |
| 5983 | - block | 5990 | + do i = 1, num_symbols |
| 5984 | - integer :: dbg_unit | 5991 | + ! json_get_array_element expects 0-based index |
| 5985 | - open(newunit=dbg_unit, file='/tmp/fac_symbols_debug.log', status='old', position='append', action='write') | 5992 | + symbol_obj = json_get_array_element(result_array, i - 1) |
| 5986 | - | 5993 | + |
| 5987 | - do i = 1, num_symbols | 5994 | + ! Get symbol name (required) |
| 5988 | - ! json_get_array_element expects 0-based index | 5995 | + if (json_has_key(symbol_obj, 'name')) then |
| 5989 | - symbol_obj = json_get_array_element(result_array, i - 1) | 5996 | + name = json_get_string(symbol_obj, 'name', '') |
| 5990 | - | 5997 | + if (len(name) > 0) then |
| 5991 | - write(dbg_unit, '(A,I0,A,I0)') 'Symbol ', i, ': value_type = ', symbol_obj%value_type | 5998 | + if (allocated(symbols(i)%name)) deallocate(symbols(i)%name) |
| 5992 | - write(dbg_unit, '(A,L1)') ' object_value associated = ', associated(symbol_obj%object_value) | 5999 | + allocate(character(len=len(name)) :: symbols(i)%name) |
| 5993 | - if (associated(symbol_obj%object_value)) then | 6000 | + symbols(i)%name = name |
| 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 | | |
| 6007 | end if | 6001 | end if |
| | 6002 | + end if |
| 6008 | | 6003 | |
| 6009 | ! Get detail (optional) | 6004 | ! Get detail (optional) |
| 6010 | if (json_has_key(symbol_obj, 'detail')) then | 6005 | if (json_has_key(symbol_obj, 'detail')) then |
@@ -6083,10 +6078,7 @@ contains |
| 6083 | | 6078 | |
| 6084 | symbols(i)%depth = 0 ! Top level | 6079 | symbols(i)%depth = 0 ! Top level |
| 6085 | symbols(i)%is_expanded = .true. | 6080 | symbols(i)%is_expanded = .true. |
| 6086 | - end do | 6081 | + end do |
| 6087 | - | | |
| 6088 | - close(dbg_unit) | | |
| 6089 | - end block | | |
| 6090 | | 6082 | |
| 6091 | ! Update the symbols panel | 6083 | ! Update the symbols panel |
| 6092 | call set_symbols(editor%symbols_panel, symbols, num_symbols) | 6084 | call set_symbols(editor%symbols_panel, symbols, num_symbols) |