@@ -160,7 +160,7 @@ endfunction
160160
161161" Populate the stacktrace window.
162162function ! s: show_stacktrace (res ) abort
163- if ! has_key (a: res , ' result' )
163+ if type ( a: res ) isnot type ({}) || ! has_key (a: res , ' result' ) || empty ( a: res .result )
164164 return
165165 endif
166166
@@ -784,7 +784,9 @@ function! s:update_goroutines() abort
784784 let l: res = s: call_jsonrpc (' RPCServer.State' )
785785 let l: currentGoroutineID = 0
786786 try
787- let l: currentGoroutineID = l: res [" result" ][" State" ][" currentGoroutine" ][" id" ]
787+ if type (l: res ) is type ({}) && has_key (l: res , ' result' ) && ! empty (l: res [' result' ])
788+ let l: currentGoroutineID = l: res [" result" ][" State" ][" currentGoroutine" ][" id" ]
789+ endif
788790 catch
789791 call go#util#EchoWarning (" current goroutine not found..." )
790792 endtry
@@ -811,7 +813,7 @@ function! s:show_goroutines(currentGoroutineID, res) abort
811813
812814 let v = [' # Goroutines' ]
813815
814- if ! has_key (a: res , ' result' )
816+ if type ( a: res ) isnot type ({}) || ! has_key (a: res , ' result' ) || empty ( a: res [ ' result ' ] )
815817 call setline (1 , v )
816818 return
817819 endif
@@ -876,14 +878,21 @@ function! s:update_variables() abort
876878
877879 try
878880 let res = s: call_jsonrpc (' RPCServer.ListLocalVars' , l: cfg )
879- let s: state [' localVars' ] = res .result[' Variables' ]
881+
882+ let s: state [' localVars' ] = {}
883+ if type (l: res ) is type ({}) && has_key (l: res , ' result' ) && ! empty (l: res .result)
884+ let s: state [' localVars' ] = l: res .result[' Variables' ]
885+ endif
880886 catch
881887 call go#util#EchoError (v: exception )
882888 endtry
883889
884890 try
885891 let res = s: call_jsonrpc (' RPCServer.ListFunctionArgs' , l: cfg )
886- let s: state [' functionArgs' ] = res .result[' Args' ]
892+ let s: state [' functionArgs' ] = {}
893+ if type (l: res ) is type ({}) && has_key (l: res , ' result' ) && ! empty (l: res .result)
894+ let s: state [' functionArgs' ] = res .result[' Args' ]
895+ endif
887896 catch
888897 call go#util#EchoError (v: exception )
889898 endtry
@@ -918,7 +927,7 @@ endfunction
918927function ! s: stack_cb (res ) abort
919928 let s: stack_name = ' '
920929
921- if empty (a: res ) || ! has_key (a: res , ' result' )
930+ if type (a: res ) isnot type ({}) || ! has_key (a: res , ' result' ) || empty ( a: res .result )
922931 return
923932 endif
924933
0 commit comments