Add mapping for Focus, and make focusing a stack frame focus the thread

This commit is contained in:
Ben Jackson 2020-11-21 20:37:35 +00:00
commit a9d0ebde0b
3 changed files with 45 additions and 11 deletions

View file

@ -751,6 +751,9 @@ Scopes and variables are represented by the buffer `vimspector.Variables`.
## Watches
The watch window is used to inspect variables and expressions. Expressions are
evaluated in the selected stack frame which is "focussed"
The watches window is a prompt buffer, where that's available. Enter insert mode
to add a new watch expression.
@ -767,7 +770,7 @@ The watches are represented by the buffer `vimspector.StackTrace`.
### Watch autocompletion
The watch prompt buffer has its `omnifunc` set to a function that will
The watch prompt buffer has its `omnifunc` set to a function that will
calcualte completion for the current expression. This is trivailly used with
`<Ctrl-x><Ctrl-o>` (see `:help ins-completion`), or integrated with your
favourite completion system. The filetype in the buffer is set to
@ -783,8 +786,28 @@ let g:ycm_semantic_triggers = {
## Stack Traces
* In the threads window, use `<CR>`, or double-click with left mouse to expand/collapse.
The stack trace window shows the state of each progream thread. Threads which
are stopped can be expanded to show the strack trace of that thread.
Often, but not always, all threads are stopped when a breakpoint is hit. The
status of a thread is show in parentheses after the thread's name. Where
supported by the underlying debugger, threads can be paused and continued
individually from within the Stack Trace window.
A particular thread, highlighted with the `CursorLine` highlight group is the
"focussed" thread. This is the thread that receives commands like "Stop In",
"Stop Out", "Continue" and "Pause" in the code window. The focussed thread can
be changed manually to "switch to" that thread.
* Use `<CR>`, or double-click with left mouse to expand/collapse a thread stack
trace, or use the WinBar button.
* Use `<CR>`, or double-click with left mouse on a stack frame to jump to it.
* Use the WinBar or `vimspector#PauseContinueThread()` to individually pause or
continue the selected thread.
* Use the "Focus" WinBar button, `<leader><CR>` or `vimspector#SetCurrentThread()`
to set the "focussed" thread to the currently selected one. If the selected
line is a stack frame, set the focussed thread to the thread of that frame and
jump to that frame in the code window.
![stack trace](https://puremourning.github.io/vimspector-web/img/vimspector-callstack-window.png)

View file

@ -110,6 +110,8 @@ class StackTraceView( object ):
with utils.LetCurrentWindow( win ):
vim.command( 'nnoremap <silent> <buffer> <CR> '
':<C-U>call vimspector#GoToFrame()<CR>' )
vim.command( 'nnoremap <silent> <buffer> <leader><CR> '
':<C-U>call vimspector#SetCurrentThread()<CR>' )
vim.command( 'nnoremap <silent> <buffer> <2-LeftMouse> '
':<C-U>call vimspector#GoToFrame()<CR>' )
@ -320,16 +322,22 @@ class StackTraceView( object ):
thread = self._GetSelectedThread()
return thread.id if thread else thread
def _SetCurrentThread( self, thread: Thread ):
self._current_thread = thread.id
self._DrawThreads()
def SetCurrentThread( self ):
thread = self._GetSelectedThread()
if not thread:
utils.UserMessage( "No thread selected" )
if thread:
self._SetCurrentThread( thread )
elif vim.current.buffer != self._buf:
return
elif vim.current.window.cursor[ 0 ] in self._line_to_frame:
thread, frame = self._line_to_frame[ vim.current.window.cursor[ 0 ] ]
self._SetCurrentThread( thread )
self._JumpToFrame( frame )
else:
self._current_thread = thread.id
self._DrawThreads()
utils.UserMessage( "No thread selected" )
def ExpandFrameOrThread( self ):
thread = self._GetSelectedThread()
@ -345,12 +353,15 @@ class StackTraceView( object ):
elif vim.current.buffer != self._buf:
return
elif vim.current.window.cursor[ 0 ] in self._line_to_frame:
self._JumpToFrame( self._line_to_frame[ vim.current.window.cursor[ 0 ] ] )
thread, frame = self._line_to_frame[ vim.current.window.cursor[ 0 ] ]
self._JumpToFrame( frame )
def _JumpToFrame( self, frame, reason = '' ):
def do_jump():
if 'line' in frame and frame[ 'line' ] > 0:
# Should this set the current _Thread_ too ? If i jump to a frame in
# Thread 2, should that become the focussed thread ?
self._current_frame = frame
return self._session.SetCurrentFrame( self._current_frame, reason )
return False
@ -469,7 +480,7 @@ class StackTraceView( object ):
source[ 'name' ],
frame[ 'line' ] ) )
self._line_to_frame[ line ] = frame
self._line_to_frame[ line ] = ( thread, frame )
def _ResolveSource( self, source, and_then ):
source_reference = int( source[ 'sourceReference' ] )

View file

@ -3,7 +3,7 @@ var msg = 'Hello, world!'
var obj = {
test: 'testing',
toast: function() {
return 'toasty' . this.test;
return 'toasty' + this.test;
}
}