-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbacktrace.vim
More file actions
92 lines (79 loc) · 2.48 KB
/
backtrace.vim
File metadata and controls
92 lines (79 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
" vim: noet
let s:backtrace_win = -1
let s:backtrace_buf = -1
" populates the backtrace window according to the array in a:backtrace
function! nodeinspect#backtrace#DisplayBacktraceWindow(backtrace)
let gotoResult = win_gotoid(s:backtrace_win)
if gotoResult == 1
" execute "set modifiable"
execute "%d"
for traceEntry in a:backtrace
" props are name & frameLocation
call append(getline('$'), traceEntry["name"].'['.traceEntry["frameLocation"].']')
endfor
execute 'normal! 1G'
" execute "set nomodifiable"
endif
endfunction
" hide the backtrace window
function! nodeinspect#backtrace#HideBacktraceWindow()
if s:backtrace_win != -1 && win_gotoid(s:backtrace_win) == 1
execute "hide"
endif
endfunction
" kill the backtrace window, if exists.
function! nodeinspect#backtrace#KillBacktraceWindow()
if s:backtrace_win != -1 && win_gotoid(s:backtrace_win) == 1
execute "bd!"
let s:backtrace_buf = -1
endif
endfunction
" empty the backtrace window, adds a 'debugger not stopped' window by default
" or a user message
function! nodeinspect#backtrace#ClearBacktraceWindow(...)
if a:0 == 0
let message = 'Running'
else
let message = a:1
endif
let cur_win = win_getid()
let gotoResult = win_gotoid(s:backtrace_win)
if gotoResult == 1
" execute "set modifiable"
execute "%d"
call setline('.', message)
" execute "set nomodifiable"
call win_gotoid(cur_win)
" execute "set modifiable"
endif
endfunction
" create the backtrace window
function! nodeinspect#backtrace#ShowBacktraceWindow(startWin)
if s:backtrace_buf == -1 || bufwinnr(s:backtrace_buf) == -1
" open split for call stack
if s:backtrace_buf == -1
if g:nodeinspect_window_pos == 'right' || g:nodeinspect_window_pos == 'left'
execute winheight(a:startWin)/3."new | setlocal nobuflisted buftype=nofile statusline=Callstack"
else
execute "rightb ".winwidth(a:startWin)/3."vnew | setlocal nobuflisted buftype=nofile statusline=Callstack"
endif
let s:backtrace_buf = bufnr('%')
set nonu
else
if g:nodeinspect_window_pos == 'right' || g:nodeinspect_window_pos == 'left'
execute winheight(a:startWin)/3."new | buffer ". s:backtrace_buf
else
execute "rightb ".winwidth(a:startWin)/3."vnew | buffer ". s:backtrace_buf
endif
endif
let s:backtrace_win = win_getid()
endif
endfunction
" return 1 if the backtrace window is visible
function nodeinspect#backtrace#IsWindowVisible()
if s:backtrace_buf == -1 || bufwinnr(s:backtrace_buf) == -1
return 0
else
return 1
endif
endfunction