Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #378 from jtpio/notebook-switch
Browse files Browse the repository at this point in the history
Handle switching between two active debug sessions
  • Loading branch information
afshin authored Mar 5, 2020
2 parents 8fb22d6 + 8176e8b commit c7f7525
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
21 changes: 19 additions & 2 deletions src/callstack/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export class CallstackModel {
*/
set frames(newFrames: CallstackModel.IFrame[]) {
this._state = newFrames;
// default to the new frame is the previous one can't be found
if (!this.frame || !newFrames.find(frame => frame.id === this.frame.id)) {
const frame = newFrames.find(
frame => Private.getFrameId(frame) === Private.getFrameId(this.frame)
);
// Default to the first frame if the previous one can't be found.
// Otherwise keep the current frame selected.
if (!frame) {
this.frame = newFrames[0];
}
this._framesChanged.emit(newFrames);
Expand Down Expand Up @@ -72,3 +76,16 @@ export namespace CallstackModel {
*/
export interface IFrame extends DebugProtocol.StackFrame {}
}

/**
* A namespace for private data.
*/
namespace Private {
/**
* Construct an id for the given frame.
* @param frame The frame.
*/
export function getFrameId(frame: CallstackModel.IFrame) {
return `${frame?.source?.path}-${frame?.id}`;
}
}
7 changes: 2 additions & 5 deletions src/variables/tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,9 @@ const VariablesComponent = ({
<>
<ul>
{variables.map(variable => {
const key = `${variable.evaluateName}-${variable.type}-${variable.value}`;
return (
<VariableComponent
key={variable.evaluateName}
data={variable}
service={service}
/>
<VariableComponent key={key} data={variable} service={service} />
);
})}
</ul>
Expand Down

0 comments on commit c7f7525

Please sign in to comment.