Hotkeys for Previous and Next call stack frames in Visual Studio

前端 未结 5 902
温柔的废话
温柔的废话 2021-02-01 20:09

Visual Studio gives many navigation hotkeys: F8 for next item in current panel (search results, errors ...), Control+K, N for bookmar

5条回答
  •  醉酒成梦
    2021-02-01 20:33

    I wrote 2 macros to gain it: PreviousStackFrame and NextStackFrame and assigned shortcuts to

    Function StackFrameIndex(ByRef aFrames As EnvDTE.StackFrames, ByRef aFrame As EnvDTE.StackFrame) As Long
        For StackFrameIndex = 1 To aFrames.Count
            If aFrames.Item(StackFrameIndex) Is aFrame Then Exit Function
        Next
        StackFrameIndex = -1
    End Function
    
    Sub NavigateStack(ByVal aShift As Long)
        If DTE.Debugger.CurrentProgram Is Nothing Then
            DTE.StatusBar.Text = "No program is currently being debugged."
            Exit Sub
        End If
    
        Dim ind As Long = StackFrameIndex(DTE.Debugger.CurrentThread.StackFrames, DTE.Debugger.CurrentStackFrame)
        If ind = -1 Then
            DTE.StatusBar.Text = "Stack navigation failed"
            Exit Sub
        End If
    
        ind = ind + aShift
        If ind <= 0 Or ind > DTE.Debugger.CurrentThread.StackFrames.Count Then
            DTE.StatusBar.Text = "Stack frame index is out of range"
            Exit Sub
        End If
    
        DTE.Debugger.CurrentStackFrame = DTE.Debugger.CurrentThread.StackFrames.Item(ind)
        DTE.StatusBar.Text = "Stack frame index: " & ind & " of " & DTE.Debugger.CurrentThread.StackFrames.Count
    End Sub
    
    Sub PreviousStackFrame()
        NavigateStack(1)
    End Sub
    
    Sub NextStackFrame()
        NavigateStack(-1)
    End Sub
    

提交回复
热议问题