diff --git a/src/vs/workbench/parts/debug/electron-browser/baseDebugView.ts b/src/vs/workbench/parts/debug/electron-browser/baseDebugView.ts index 60a3941b1cb49d8ca92b326c60f31f0506ec0c1b..13a6ce87b8bfe9fdc39e32729425ff2d82af99c3 100644 --- a/src/vs/workbench/parts/debug/electron-browser/baseDebugView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/baseDebugView.ts @@ -13,7 +13,6 @@ import { InputBox, IInputValidationOptions } from 'vs/base/browser/ui/inputbox/i import { attachInputBoxStyler } from 'vs/platform/theme/common/styler'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { once } from 'vs/base/common/functional'; -import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'; import { ClickBehavior, DefaultController } from 'vs/base/parts/tree/browser/treeDefaults'; @@ -199,7 +198,6 @@ export class BaseDebugController extends DefaultController { private actionProvider: IActionProvider, menuId: MenuId, @IDebugService protected debugService: IDebugService, - @IWorkbenchEditorService protected editorService: IWorkbenchEditorService, @IContextMenuService private contextMenuService: IContextMenuService, @IContextKeyService contextKeyService: IContextKeyService, @IMenuService menuService: IMenuService diff --git a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts index 557b1268023c7989818674edc300ca8ae1cd6992..5948091a39d7c662e62a50ea99d27e5ffd8dac26 100644 --- a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts @@ -18,7 +18,6 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { BaseDebugController, twistiePixels, renderViewTree } from 'vs/workbench/parts/debug/electron-browser/baseDebugView'; import { ITree, IActionProvider, IDataSource, IRenderer, IAccessibilityProvider } from 'vs/base/parts/tree/browser/tree'; -import { IMouseEvent } from 'vs/base/browser/mouseEvent'; import { IAction, IActionItem } from 'vs/base/common/actions'; import { RestartAction, StopAction, ContinueAction, StepOverAction, StepIntoAction, StepOutAction, PauseAction, RestartFrameAction } from 'vs/workbench/parts/debug/browser/debugActions'; import { CopyStackTraceAction } from 'vs/workbench/parts/debug/electron-browser/electronDebugActions'; @@ -28,6 +27,8 @@ import { Source } from 'vs/workbench/parts/debug/common/debugSource'; import { basenameOrAuthority } from 'vs/base/common/resources'; import { WorkbenchTree, IListService } from 'vs/platform/list/browser/listService'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; +import FileResultsNavigation from 'vs/workbench/parts/files/browser/fileResultsNavigation'; const $ = dom.$; @@ -48,7 +49,8 @@ export class CallStackView extends TreeViewsViewletPanel { @IKeybindingService keybindingService: IKeybindingService, @IInstantiationService private instantiationService: IInstantiationService, @IThemeService private themeService: IThemeService, - @IListService private listService: IListService + @IListService private listService: IListService, + @IWorkbenchEditorService private editorService: IWorkbenchEditorService, ) { super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService); this.settings = options.viewletSettings; @@ -108,10 +110,28 @@ export class CallStackView extends TreeViewsViewletPanel { keyboardSupport: false }, this.contextKeyService, this.listService, this.themeService); - this.disposables.push(this.tree.onDidChangeSelection(event => { - if (event && event.payload && event.payload.origin === 'keyboard') { - const element = this.tree.getFocus(); - controller.handleSelectionChange(this.tree, element, false, event); + const fileResultsNavigation = new FileResultsNavigation(this.tree); + this.disposables.push(fileResultsNavigation); + this.disposables.push(fileResultsNavigation.openFile(e => { + const element = e.element; + + if (element instanceof StackFrame) { + this.debugService.focusStackFrame(element, element.thread, element.thread.process, true); + element.openInEditor(this.editorService, e.editorOptions.preserveFocus, e.sideBySide).done(undefined, errors.onUnexpectedError); + } + if (element instanceof Thread) { + this.debugService.focusStackFrame(undefined, element, element.process, true); + } + if (element instanceof Process) { + this.debugService.focusStackFrame(undefined, undefined, element, true); + } + if (element instanceof ThreadAndProcessIds) { + const process = this.debugService.getModel().getProcesses().filter(p => p.getId() === element.processId).pop(); + const thread = process && process.getThread(element.threadId); + if (thread) { + (thread).fetchCallStack() + .done(() => this.tree.refresh(), errors.onUnexpectedError); + } } })); @@ -178,14 +198,6 @@ export class CallStackView extends TreeViewsViewletPanel { } class CallStackController extends BaseDebugController { - - protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean { - super.onLeftClick(tree, element, event); - this.handleSelectionChange(tree, element, event.detail !== 2, event); - - return true; - } - protected getContext(element: any): any { if (element instanceof StackFrame) { if (element.source.inMemory) { @@ -198,35 +210,6 @@ class CallStackController extends BaseDebugController { return element.threadId; } } - - // user clicked / pressed on 'Load More Stack Frames', get those stack frames and refresh the tree. - public showMoreStackFrames(tree: ITree, threadAndProcessIds: ThreadAndProcessIds): boolean { - const process = this.debugService.getModel().getProcesses().filter(p => p.getId() === threadAndProcessIds.processId).pop(); - const thread = process && process.getThread(threadAndProcessIds.threadId); - if (thread) { - (thread).fetchCallStack() - .done(() => tree.refresh(), errors.onUnexpectedError); - } - - return true; - } - - public handleSelectionChange(tree: ITree, element: any, preserveFocus: boolean, event: any): void { - if (element instanceof StackFrame) { - this.debugService.focusStackFrame(element, element.thread, element.thread.process, true); - const sideBySide = (event && (event.ctrlKey || event.metaKey)); - element.openInEditor(this.editorService, preserveFocus, sideBySide).done(undefined, errors.onUnexpectedError); - } - if (element instanceof Thread) { - this.debugService.focusStackFrame(undefined, element, element.process, true); - } - if (element instanceof Process) { - this.debugService.focusStackFrame(undefined, undefined, element, true); - } - if (element instanceof ThreadAndProcessIds) { - this.showMoreStackFrames(tree, element); - } - } } diff --git a/src/vs/workbench/parts/files/browser/fileResultsNavigation.ts b/src/vs/workbench/parts/files/browser/fileResultsNavigation.ts index 79f3a7ca198a991318d97020cf4821831e9a2bab..65ecf4b1e6e80a7db6d7c086c56024a839e7e81c 100644 --- a/src/vs/workbench/parts/files/browser/fileResultsNavigation.ts +++ b/src/vs/workbench/parts/files/browser/fileResultsNavigation.ts @@ -15,14 +15,20 @@ export interface IOpenFileOptions { payload: any; } +export interface IFileResultsNavigationOptions { + openOnFocus: boolean; +} + export default class FileResultsNavigation extends Disposable { private _openFile: Emitter = new Emitter(); public readonly openFile: Event = this._openFile.event; - constructor(private tree: ITree) { + constructor(private tree: ITree, options?: IFileResultsNavigationOptions) { super(); - this._register(this.tree.onDidChangeFocus(e => this.onFocus(e))); + if (options && options.openOnFocus) { + this._register(this.tree.onDidChangeFocus(e => this.onFocus(e))); + } this._register(this.tree.onDidChangeSelection(e => this.onSelection(e))); } @@ -66,4 +72,4 @@ export default class FileResultsNavigation extends Disposable { payload }); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/parts/markers/browser/markersPanel.ts b/src/vs/workbench/parts/markers/browser/markersPanel.ts index bc160c94e8e81d7ae0b3a7e3fbe8d726f918aae4..bfe9d25d339c7c300f666473aad796bb3bcd4a38 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanel.ts @@ -231,7 +231,7 @@ export class MarkersPanel extends Panel { Constants.MarkerFocusContextKey.bindTo(this.tree.contextKeyService); - const fileResultsNavigation = this._register(new FileResultsNavigation(this.tree)); + const fileResultsNavigation = this._register(new FileResultsNavigation(this.tree, { openOnFocus: true })); this._register(debounceEvent(fileResultsNavigation.openFile, (last, event) => event, 75, true)(options => { this.openFileAtElement(options.element, options.editorOptions.preserveFocus, options.editorOptions.pinned, options.sideBySide); })); diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index 510ecc9faa6981f1378ae8a2db7eacd66fd0541f..be2c99542207e213e30d50d0bdf93203e54c4aa6 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -514,7 +514,7 @@ export class SearchViewlet extends Viewlet { this.tree.setInput(this.viewModel.searchResult); this.toUnbind.push(renderer); - const fileResultsNavigation = this._register(new FileResultsNavigation(this.tree)); + const fileResultsNavigation = this._register(new FileResultsNavigation(this.tree, { openOnFocus: true })); this._register(debounceEvent(fileResultsNavigation.openFile, (last, event) => event, 75, true)(options => { if (options.element instanceof Match) { let selectedMatch: Match = options.element;