Skip to content

Commit

Permalink
remove expanded variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Aug 1, 2017
1 parent 4169a74 commit 7b3e64d
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions autoload/go/debug.vim
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,43 @@ function! s:goto_file() abort
silent! normal! zvzz
endfunction

function! s:delete_expands()
let nr = line('.')
while 1
let l = getline(nr+1)
if empty(l) || l =~ '^\S'
return
endif
silent! exe (nr+1) . 'd _'
endwhile
silent! exe 'norm!' nr.'G'
endfunction

function! s:expand_var() abort
let name = matchstr(getline('.'), '^[^:]\+\ze: \.\.\.$')
if name == ''
let name = matchstr(getline('.'), '^[^:]\+\ze: {\.\.\.}$')
if name != ''
setlocal modifiable
let l = line('.')
call s:delete_expands()
call append(l, split(s:eval(name), "\n")[1:])
silent! exe 'norm!' l.'G'
setlocal nomodifiable
return
endif
let m = matchlist(getline('.'), '^\([^:]\+\)\ze: \[\([0-9]\+\)\]$')
if len(m) > 0 && m[1] != ''
setlocal modifiable
let l = line('.')
call s:delete_expands()
let vs = ''
for i in range(0, min([10, m[2]-1]))
let vs .= ' ' . s:eval(m[1] . '[' . i . ']')
endfor
call append(l, split(vs, "\n"))
silent! exe 'norm!' l.'G'
setlocal nomodifiable
return
endif
setlocal modifiable
let l = line('.')
silent! %g/^\s/d _
call append(l, split(s:eval(name), "\n")[1:])
silent! exe 'norm!' l.'G'
setlocal nomodifiable
endfunction

function! s:start_cb(ch, json) abort
Expand Down Expand Up @@ -353,7 +379,9 @@ function! s:eval_tree(var, nest) abort
let v = ''
if !empty(a:var.name)
if len(a:var.children) > 0 && a:var.value == ''
let v .= repeat(' ', nest) . printf("%s: ...\n", a:var.name)
let v .= repeat(' ', nest) . printf("%s: {...}\n", a:var.name)
elseif a:var.len > 0 && a:var.value == ''
let v .= repeat(' ', nest) . printf("%s: [%d]\n", a:var.name, a:var.len)
else
let v .= repeat(' ', nest) . printf("%s: %s\n", a:var.name, a:var.type == 'string' ? json_encode(a:var.value) : a:var.value)
endif
Expand Down

0 comments on commit 7b3e64d

Please sign in to comment.