-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add debug API for call stack selection changes (63943) #179132
Add debug API for call stack selection changes (63943) #179132
Conversation
selection (microsoft#63943) Add debug.onDidChangeDebugFocus. May provide ids for session, thread, and stackFrame, as appropriate. Fixes: microsoft#63943 api should provide thread/stack frame id (paraphrasing)
listeners, and create separate contexts for each
This reverts commit c308bc3.
@microsoft-github-policy-service agree company="Coherent Logix" |
export interface IThreadFocusDto { | ||
kind: 'thread'; | ||
threadId: number | undefined; | ||
sessionId: string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can sessionId or threadId actually be undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently, no, but i wanted to allow for it for the future? seemed easier to allow it now, than change to allow it later?
but i barely have any feeling about that, it seemed far-fetched that the 'thread' event should be used when there is no session, so i can make whatever change you suggest. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'd rather just have it reflect whatever is possible now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've changed the sessionId to always be defined.
the threadId may still be undefined, both for thread and stackframe focus events.
@@ -74,6 +75,10 @@ export class ViewModel implements IViewModel { | |||
setFocus(stackFrame: IStackFrame | undefined, thread: IThread | undefined, session: IDebugSession | undefined, explicit: boolean): void { | |||
const shouldEmitForStackFrame = this._focusedStackFrame !== stackFrame; | |||
const shouldEmitForSession = this._focusedSession !== session; | |||
// currently, it does not happen that shouldEmitForThread === true, but shouldEmitForStackFrame === false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't follow this comment. If I select a different thread under the same frame, I think I would expect it to fire for thread but not for stackframe, is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't understand; isn't it flipped, we select stack frames under threads?
there's two things: when you select a thread, the model always then sets the focus to a stack frame; you can't get a 'thread focused' event currently, but i wanted to allow for it. (I didn't want to introduce that yet, because its not required for my use case, and can be added later without changing this API).
Also, during my debugging, the stack frame comparison never was 'they do equal each other' because its using exact comparison, and they were always different objects. Didn't want to change due to risk, and also, the change was not needed to simply allow extensions to know about selection state.
Thanks for the comment - did this make sense? Wanted to make sure i understood your question before changing anything here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't know what I was thinking, I looked at this for too long and got it mixed up in my head.
And re: the object comparison, I can look into it, but I would assume that object comparison should be ok, and we will for example create new stack frame objects on every step, and then it's a different frame and should fire the event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, thanks. i've removed this comment. the comment later about firing only stackframe or thread focus should be enough
@@ -98,16 +103,24 @@ export class ViewModel implements IViewModel { | |||
if (shouldEmitForSession) { | |||
this._onDidFocusSession.fire(session); | |||
} | |||
|
|||
// should not fire this if a stack frame focus is fired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does "this" mean the thread event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes,made the comment more clear, thanks
kind: 'thread'; | ||
|
||
/** | ||
* Id of the debug session (DAP id). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, ooops, fixed comment, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, I think this is enough to get started. Having the multiple internal events, one per type, feels a bit weird, it seems like there should be one event for the focused thing in the callstack view. But that code was already partly there and I can clean it up later if needed.
for #63943
Adds a new API to the debug namespace to add listeners to selection changes to call stack selection changes.
This allows listeners to know when focus has changed, allowing additional custom debug views to show information for the selection context, just as the build-in views do (variables, etc).
This is additive; it does not change any existing APIs, and just taps into the current call stack selection.