Skip to content

Commit eee1b9b

Browse files
committed
debug: use history service to get last active root to simplify code
1 parent ce8a083 commit eee1b9b

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/vs/workbench/parts/debug/browser/debugActions.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
77
import { Action } from 'vs/base/common/actions';
88
import * as lifecycle from 'vs/base/common/lifecycle';
99
import { TPromise } from 'vs/base/common/winjs.base';
10-
import { ICodeEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
10+
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1111
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1212
import { ICommandService } from 'vs/platform/commands/common/commands';
1313
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
@@ -24,6 +24,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
2424
import { CollapseAction } from 'vs/workbench/browser/viewlet';
2525
import { ITree } from 'vs/base/parts/tree/browser/tree';
2626
import { first } from 'vs/base/common/arrays';
27+
import { IHistoryService } from 'vs/workbench/services/history/common/history';
2728

2829
export abstract class AbstractDebugAction extends Action {
2930

@@ -118,7 +119,7 @@ export class StartAction extends AbstractDebugAction {
118119
@IDebugService debugService: IDebugService,
119120
@IKeybindingService keybindingService: IKeybindingService,
120121
@IWorkspaceContextService private contextService: IWorkspaceContextService,
121-
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
122+
@IHistoryService private historyService: IHistoryService
122123
) {
123124
super(id, label, 'debug-action start', debugService, keybindingService);
124125

@@ -131,14 +132,10 @@ export class StartAction extends AbstractDebugAction {
131132
const configurationManager = this.debugService.getConfigurationManager();
132133
let launch = configurationManager.selectedConfiguration.launch;
133134
if (!launch) {
134-
const activeEditor = this.editorService.getActiveEditor();
135-
const launches = configurationManager.getLaunches();
136-
if (isCodeEditor(activeEditor)) {
137-
const resource = activeEditor.input.getResource();
138-
const root = this.contextService.getWorkspaceFolder(resource);
139-
launch = configurationManager.getLaunch(root.uri);
140-
}
135+
const rootUri = this.historyService.getLastActiveWorkspaceRoot();
136+
launch = configurationManager.getLaunch(rootUri);
141137
if (!launch) {
138+
const launches = configurationManager.getLaunches();
142139
launch = first(launches, l => !!l.getConfigurationNames().length, launches.length ? launches[0] : undefined);
143140
}
144141

0 commit comments

Comments
 (0)