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
197
         type(json_value_t) :: diagnostics_array, diag_obj, range_obj
197
         type(json_value_t) :: diagnostics_array, diag_obj, range_obj
198
         type(json_value_t) :: start_obj, end_obj
198
         type(json_value_t) :: start_obj, end_obj
199
         character(len=:), allocatable :: uri
199
         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
201
         type(diagnostic_t) :: diag
202
         type(diagnostic_t) :: diag
202
         type(diagnostic_t), allocatable :: old_items(:)
203
         type(diagnostic_t), allocatable :: old_items(:)
203
 
204
 
@@ -210,7 +211,6 @@ contains
210
 
211
 
211
         ! First, remove any existing diagnostics from this server
212
         ! First, remove any existing diagnostics from this server
212
         if (allocated(store%files(file_idx)%items) .and. store%files(file_idx)%count > 0) then
213
         if (allocated(store%files(file_idx)%items) .and. store%files(file_idx)%count > 0) then
213
-            old_count = 0
214
             ! Count diagnostics NOT from this server
214
             ! Count diagnostics NOT from this server
215
             do i = 1, store%files(file_idx)%count
215
             do i = 1, store%files(file_idx)%count
216
                 if (store%files(file_idx)%items(i)%server_index /= server_index) then
216
                 if (store%files(file_idx)%items(i)%server_index /= server_index) then
@@ -230,8 +230,6 @@ contains
230
                 end do
230
                 end do
231
             end if
231
             end if
232
             deallocate(store%files(file_idx)%items)
232
             deallocate(store%files(file_idx)%items)
233
-        else
234
-            old_count = 0
235
         end if
233
         end if
236
 
234
 
237
         ! Parse new diagnostics array
235
         ! Parse new diagnostics array
@@ -249,7 +247,7 @@ contains
249
             store%files(file_idx)%count = new_count
247
             store%files(file_idx)%count = new_count
250
 
248
 
251
             ! Copy old diagnostics first
249
             ! Copy old diagnostics first
252
-            if (old_count > 0) then
250
+            if (old_count > 0 .and. allocated(old_items)) then
253
                 store%files(file_idx)%items(1:old_count) = old_items(1:old_count)
251
                 store%files(file_idx)%items(1:old_count) = old_items(1:old_count)
254
                 deallocate(old_items)
252
                 deallocate(old_items)
255
             end if
253
             end if