fortrangoingonforty/facsimile / 7f29919

Browse files

fix document symbols not appearing

Authored by espadonne
SHA
7f299199e1573112900ec6bbb0647c13fd84d310
Parents
2096aef
Tree
d59bc4a

2 changed files

StatusFile+-
M src/commands/command_handler_module.f90 38 11
M src/ui/symbols_panel_module.f90 11 3
src/commands/command_handler_module.f90modified
@@ -5959,6 +5959,16 @@ contains
5959
         result_array = response%result
5959
         result_array = response%result
5960
         num_symbols = json_array_size(result_array)
5960
         num_symbols = json_array_size(result_array)
5961
 
5961
 
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
+
5962
         if (num_symbols == 0) then
5972
         if (num_symbols == 0) then
5963
             call clear_symbols(editor%symbols_panel)
5973
             call clear_symbols(editor%symbols_panel)
5964
             call terminal_move_cursor(editor%screen_rows, 1)
5974
             call terminal_move_cursor(editor%screen_rows, 1)
@@ -5970,17 +5980,31 @@ contains
5970
         allocate(symbols(num_symbols))
5980
         allocate(symbols(num_symbols))
5971
 
5981
 
5972
         ! Parse each symbol
5982
         ! Parse each symbol
5973
-        do i = 1, num_symbols
5983
+        block
5974
-            ! json_get_array_element expects 0-based index
5984
+            integer :: dbg_unit
5975
-            symbol_obj = json_get_array_element(result_array, i - 1)
5985
+            open(newunit=dbg_unit, file='/tmp/fac_symbols_debug.log', status='old', position='append', action='write')
5976
 
5986
 
5977
-            ! Get symbol name (required)
5987
+            do i = 1, num_symbols
5978
-            if (json_has_key(symbol_obj, 'name')) then
5988
+                ! json_get_array_element expects 0-based index
5979
-                name = json_get_string(symbol_obj, 'name', '')
5989
+                symbol_obj = json_get_array_element(result_array, i - 1)
5980
-                if (allocated(symbols(i)%name)) deallocate(symbols(i)%name)
5990
+
5981
-                allocate(character(len=len(name)) :: symbols(i)%name)
5991
+                write(dbg_unit, '(A,I0,A,I0)') 'Symbol ', i, ': value_type = ', symbol_obj%value_type
5982
-                symbols(i)%name = name
5992
+                write(dbg_unit, '(A,L1)') '  object_value associated = ', associated(symbol_obj%object_value)
5983
-            end if
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
6007
+                end if
5984
 
6008
 
5985
             ! Get detail (optional)
6009
             ! Get detail (optional)
5986
             if (json_has_key(symbol_obj, 'detail')) then
6010
             if (json_has_key(symbol_obj, 'detail')) then
@@ -6059,7 +6083,10 @@ contains
6059
 
6083
 
6060
             symbols(i)%depth = 0  ! Top level
6084
             symbols(i)%depth = 0  ! Top level
6061
             symbols(i)%is_expanded = .true.
6085
             symbols(i)%is_expanded = .true.
6062
-        end do
6086
+            end do
6087
+
6088
+            close(dbg_unit)
6089
+        end block
6063
 
6090
 
6064
         ! Update the symbols panel
6091
         ! Update the symbols panel
6065
         call set_symbols(editor%symbols_panel, symbols, num_symbols)
6092
         call set_symbols(editor%symbols_panel, symbols, num_symbols)
src/ui/symbols_panel_module.f90modified
@@ -155,8 +155,12 @@ contains
155
             allocate(panel%flat_symbols(flat_count))
155
             allocate(panel%flat_symbols(flat_count))
156
             panel%num_flat_symbols = flat_count
156
             panel%num_flat_symbols = flat_count
157
 
157
 
158
-            ! Flatten for navigation
158
+            ! Flatten for navigation (start at index 1)
159
-            call flatten_symbols(panel%symbols, num_symbols, panel%flat_symbols, flat_count)
159
+            block
160
+                integer :: start_idx
161
+                start_idx = 1
162
+                call flatten_symbols(panel%symbols, num_symbols, panel%flat_symbols, start_idx)
163
+            end block
160
         end if
164
         end if
161
 
165
 
162
         panel%selected_index = 1
166
         panel%selected_index = 1
@@ -326,7 +330,11 @@ contains
326
                 end if
330
                 end if
327
 
331
 
328
                 ! Add icon and name
332
                 ! Add icon and name
329
-                line = trim(line) // icon // " " // trim(panel%flat_symbols(i)%name)
333
+                if (allocated(panel%flat_symbols(i)%name)) then
334
+                    line = trim(line) // icon // " " // trim(panel%flat_symbols(i)%name)
335
+                else
336
+                    line = trim(line) // icon // " (unnamed)"
337
+                end if
330
 
338
 
331
                 ! Add location if room
339
                 ! Add location if room
332
                 if (panel%show_details .or. i == panel%selected_index) then
340
                 if (panel%show_details .or. i == panel%selected_index) then