提交 74fae4d7 编写于 作者: I isidor

repl: multiple trees per session

上级 51cfd808
......@@ -166,6 +166,7 @@ export interface IDebugSession extends ITreeElement {
// session events
readonly onDidEndAdapter: Event<AdapterEndEvent>;
readonly onDidChangeState: Event<void>;
readonly onDidChangeReplElements: Event<void>;
// DA capabilities
readonly capabilities: DebugProtocol.Capabilities;
......@@ -381,7 +382,6 @@ export interface IDebugModel extends ITreeElement {
getFunctionBreakpoints(): ReadonlyArray<IFunctionBreakpoint>;
getExceptionBreakpoints(): ReadonlyArray<IExceptionBreakpoint>;
getWatchExpressions(): ReadonlyArray<IExpression>;
getReplElements(): ReadonlyArray<IReplElement>;
onDidChangeBreakpoints: Event<IBreakpointsChangeEvent>;
onDidChangeCallStack: Event<void>;
......
......@@ -1005,10 +1005,6 @@ export class DebugModel implements IDebugModel {
this._onDidChangeBreakpoints.fire({ removed: removed });
}
public getReplElements(): ReadonlyArray<IReplElement> {
return this.sessions.map(s => s.getReplElements()).reduce((left, right) => left.concat(right), []);
}
public getWatchExpressions(): Expression[] {
return this.watchExpressions;
}
......
......@@ -471,7 +471,7 @@ export class DebugService implements IDebugService {
}
// Show the repl if some error got logged there #5870
if (this.model.getReplElements().length > 0) {
if (session && session.getReplElements().length > 0) {
this.panelService.openPanel(REPL_ID, false);
}
......
......@@ -37,7 +37,7 @@ import { clipboard } from 'electron';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { WorkbenchTree } from 'vs/platform/list/browser/listService';
import { memoize } from 'vs/base/common/decorators';
import { dispose } from 'vs/base/common/lifecycle';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { OpenMode, ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
......@@ -106,10 +106,21 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
}
private registerListeners(): void {
// TODO@Isidor
// this._register(this.debugService.getModel().onDidChangeReplElements(() => {
// this.refreshReplElements(this.debugService.getModel().getReplElements().length === 0);
// }));
let replElementsChangeListener: IDisposable;
this._register(this.debugService.getViewModel().onDidFocusSession(session => {
if (replElementsChangeListener) {
replElementsChangeListener.dispose();
}
if (session) {
replElementsChangeListener = session.onDidChangeReplElements(() => {
this.refreshReplElements(session.getReplElements().length === 0);
});
if (this.tree && this.isVisible()) {
this.tree.setInput(session);
}
}
}));
this._register(this.panelService.onDidPanelOpen(panel => this.refreshReplElements(true)));
}
......@@ -149,8 +160,6 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
accessibilityProvider: new ReplExpressionsAccessibilityProvider(),
controller
}, replTreeOptions);
await this.tree.setInput(this.debugService.getModel());
}
public setVisible(visible: boolean): Promise<void> {
......@@ -159,6 +168,10 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
} else {
this.model = this.modelService.createModel('', null, uri.parse(`${DEBUG_SCHEME}:replinput`), true);
this.replInput.setModel(this.model);
const focusedSession = this.debugService.getViewModel().focusedSession;
if (focusedSession && this.tree.getInput() !== focusedSession) {
this.tree.setInput(focusedSession);
}
}
return super.setVisible(visible);
......
......@@ -15,7 +15,7 @@ import { IMouseEvent } from 'vs/base/browser/mouseEvent';
import { ITree, IAccessibilityProvider, ContextMenuEvent, IDataSource, IRenderer, IActionProvider } from 'vs/base/parts/tree/browser/tree';
import { ICancelableEvent } from 'vs/base/parts/tree/browser/treeDefaults';
import { IExpressionContainer, IExpression, IReplElementSource } from 'vs/workbench/parts/debug/common/debug';
import { DebugModel, RawObjectReplElement, Expression, SimpleReplElement, Variable } from 'vs/workbench/parts/debug/common/debugModel';
import { RawObjectReplElement, Expression, SimpleReplElement, Variable } from 'vs/workbench/parts/debug/common/debugModel';
import { renderVariable, renderExpressionValue, IVariableTemplateData, BaseDebugController } from 'vs/workbench/parts/debug/browser/baseDebugView';
import { ClearReplAction, ReplCollapseAllAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { CopyAction, CopyAllAction } from 'vs/workbench/parts/debug/electron-browser/electronDebugActions';
......@@ -24,6 +24,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { LinkDetector } from 'vs/workbench/parts/debug/browser/linkDetector';
import { handleANSIOutput } from 'vs/workbench/parts/debug/browser/debugANSIHandling';
import { ILabelService } from 'vs/platform/label/common/label';
import { DebugSession } from 'vs/workbench/parts/debug/electron-browser/debugSession';
const $ = dom.$;
......@@ -34,11 +35,11 @@ export class ReplExpressionsDataSource implements IDataSource {
}
public hasChildren(tree: ITree, element: any): boolean {
return element instanceof DebugModel || (<IExpressionContainer>element).hasChildren;
return element instanceof DebugSession || (<IExpressionContainer>element).hasChildren;
}
public getChildren(tree: ITree, element: any): TPromise<any> {
if (element instanceof DebugModel) {
if (element instanceof DebugSession) {
return Promise.resolve(element.getReplElements());
}
if (element instanceof RawObjectReplElement) {
......
......@@ -133,6 +133,9 @@ export class MockSession implements IDebugSession {
}
removeReplExpressions(): void { }
get onDidChangeReplElements(): Event<void> {
return null;
}
addReplExpression(stackFrame: IStackFrame, name: string): TPromise<void> {
return TPromise.as(void 0);
......
......@@ -340,8 +340,8 @@ suite('Debug - Model', () => {
});
test('repl expressions', () => {
assert.equal(model.getReplElements().length, 0);
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
assert.equal(session.getReplElements().length, 0);
model.addSession(session);
session['raw'] = <any>rawSession;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册