fortrangoingonforty/facsimile / fb634e0

Browse files

cleanup

Authored by espadonne
SHA
fb634e00b59f76f69a214039a18943dc2c774d07
Parents
d12ed9f
Tree
2ef0f74

1 changed file

StatusFile+-
M src/lsp/diagnostics_module.f90 3 5
src/lsp/diagnostics_module.f90modified
@@ -197,7 +197,8 @@ contains
197197
         type(json_value_t) :: diagnostics_array, diag_obj, range_obj
198198
         type(json_value_t) :: start_obj, end_obj
199199
         character(len=:), allocatable :: uri
200
-        integer :: i, n_diagnostics, file_idx, old_count, new_count, j
200
+        integer :: i, n_diagnostics, file_idx, new_count, j
201
+        integer :: old_count = 0
201202
         type(diagnostic_t) :: diag
202203
         type(diagnostic_t), allocatable :: old_items(:)
203204
 
@@ -210,7 +211,6 @@ contains
210211
 
211212
         ! First, remove any existing diagnostics from this server
212213
         if (allocated(store%files(file_idx)%items) .and. store%files(file_idx)%count > 0) then
213
-            old_count = 0
214214
             ! Count diagnostics NOT from this server
215215
             do i = 1, store%files(file_idx)%count
216216
                 if (store%files(file_idx)%items(i)%server_index /= server_index) then
@@ -230,8 +230,6 @@ contains
230230
                 end do
231231
             end if
232232
             deallocate(store%files(file_idx)%items)
233
-        else
234
-            old_count = 0
235233
         end if
236234
 
237235
         ! Parse new diagnostics array
@@ -249,7 +247,7 @@ contains
249247
             store%files(file_idx)%count = new_count
250248
 
251249
             ! Copy old diagnostics first
252
-            if (old_count > 0) then
250
+            if (old_count > 0 .and. allocated(old_items)) then
253251
                 store%files(file_idx)%items(1:old_count) = old_items(1:old_count)
254252
                 deallocate(old_items)
255253
             end if