Merge from vscode 6e530127a1bb8ffbd1bfb77dc680c321dc0d71f5 (#6844)

This commit is contained in:
Anthony Dresser
2019-08-20 21:07:47 -07:00
committed by GitHub
parent 1f00249646
commit ecb80f14f0
221 changed files with 3140 additions and 1552 deletions

View File

@@ -169,7 +169,7 @@ class SelectionToReplAction extends EditorAction {
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
public async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
const debugService = accessor.get(IDebugService);
const panelService = accessor.get(IPanelService);
const viewModel = debugService.getViewModel();
@@ -179,9 +179,8 @@ class SelectionToReplAction extends EditorAction {
}
const text = editor.getModel().getValueInRange(editor.getSelection());
return session.addReplExpression(viewModel.focusedStackFrame!, text)
.then(() => panelService.openPanel(REPL_ID, true))
.then(_ => undefined);
await session.addReplExpression(viewModel.focusedStackFrame!, text);
await panelService.openPanel(REPL_ID, true);
}
}

View File

@@ -404,7 +404,7 @@ export class DebugService implements IDebugService {
.then(() => false);
}
return launch && launch.openConfigFile(false, true, undefined, this.initCancellationToken ? this.initCancellationToken.token : undefined).then(() => false);
return !!launch && launch.openConfigFile(false, true, undefined, this.initCancellationToken ? this.initCancellationToken.token : undefined).then(() => false);
});
}
@@ -542,6 +542,10 @@ export class DebugService implements IDebugService {
if (this.layoutService.isVisible(Parts.SIDEBAR_PART) && this.configurationService.getValue<IDebugConfiguration>('debug').openExplorerOnEnd) {
this.viewletService.openViewlet(EXPLORER_VIEWLET_ID);
}
// Data breakpoints that can not be persisted should be cleared when a session ends
const dataBreakpoints = this.model.getDataBreakpoints().filter(dbp => !dbp.canPersist);
dataBreakpoints.forEach(dbp => this.model.removeDataBreakpoints(dbp.getId()));
}
}));

View File

@@ -31,6 +31,8 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ReplModel } from 'vs/workbench/contrib/debug/common/replModel';
import { onUnexpectedError } from 'vs/base/common/errors';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { variableSetEmitter } from 'vs/workbench/contrib/debug/browser/variablesView';
export class DebugSession implements IDebugSession {
@@ -66,7 +68,8 @@ export class DebugSession implements IDebugSession {
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@INotificationService private readonly notificationService: INotificationService,
@IProductService private readonly productService: IProductService,
@IWindowsService private readonly windowsService: IWindowsService
@IWindowsService private readonly windowsService: IWindowsService,
@IOpenerService private readonly openerService: IOpenerService
) {
this.id = generateUuid();
this.repl = new ReplModel(this);
@@ -167,7 +170,7 @@ export class DebugSession implements IDebugSession {
return dbgr.createDebugAdapter(this).then(debugAdapter => {
this.raw = new RawDebugSession(debugAdapter, dbgr, this.telemetryService, customTelemetryService, this.windowsService);
this.raw = new RawDebugSession(debugAdapter, dbgr, this.telemetryService, customTelemetryService, this.windowsService, this.openerService);
return this.raw.start().then(() => {
@@ -552,7 +555,8 @@ export class DebugSession implements IDebugSession {
insertText: item.text || item.label,
kind: completionKindFromString(item.type || 'property'),
filterText: (item.start && item.length) ? text.substr(item.start, item.length).concat(item.label) : undefined,
range: Range.fromPositions(position.delta(0, -(item.length || overwriteBefore)), position)
range: Range.fromPositions(position.delta(0, -(item.length || overwriteBefore)), position),
sortText: item.sortText
});
}
});
@@ -903,12 +907,13 @@ export class DebugSession implements IDebugSession {
this._onDidChangeREPLElements.fire();
}
addReplExpression(stackFrame: IStackFrame | undefined, name: string): Promise<void> {
async addReplExpression(stackFrame: IStackFrame | undefined, name: string): Promise<void> {
const viewModel = this.debugService.getViewModel();
return this.repl.addReplExpression(stackFrame, name)
.then(() => this._onDidChangeREPLElements.fire())
// Evaluate all watch expressions and fetch variables again since repl evaluation might have changed some.
.then(() => this.debugService.focusStackFrame(viewModel.focusedStackFrame, viewModel.focusedThread, viewModel.focusedSession));
await this.repl.addReplExpression(stackFrame, name);
this._onDidChangeREPLElements.fire();
// Evaluate all watch expressions and fetch variables again since repl evaluation might have changed some.
this.debugService.focusStackFrame(viewModel.focusedStackFrame, viewModel.focusedThread, viewModel.focusedSession);
variableSetEmitter.fire();
}
appendToRepl(data: string | IExpression, severity: severity, source?: IReplElementSource): void {

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import strings = require('vs/base/common/strings');
import * as strings from 'vs/base/common/strings';
import { isAbsolute } from 'vs/base/common/path';
import { URI as uri } from 'vs/base/common/uri';
import { isMacintosh } from 'vs/base/common/platform';

View File

@@ -17,6 +17,7 @@ import { IWindowsService } from 'vs/platform/windows/common/windows';
import { URI } from 'vs/base/common/uri';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { env as processEnv } from 'vs/base/common/process';
import { IOpenerService } from 'vs/platform/opener/common/opener';
/**
* This interface represents a single command line argument split into a "prefix" and a "path" half.
@@ -74,7 +75,8 @@ export class RawDebugSession {
dbgr: IDebugger,
private readonly telemetryService: ITelemetryService,
public readonly customTelemetryService: ITelemetryService | undefined,
private readonly windowsService: IWindowsService
private readonly windowsService: IWindowsService,
private readonly openerService: IOpenerService
) {
this.debugAdapter = debugAdapter;
@@ -652,7 +654,7 @@ export class RawDebugSession {
const label = error.urlLabel ? error.urlLabel : nls.localize('moreInfo', "More Info");
return createErrorWithActions(userMessage, {
actions: [new Action('debug.moreInfo', label, undefined, true, () => {
window.open(error.url);
this.openerService.open(URI.parse(error.url));
return Promise.resolve(null);
})]
});

View File

@@ -62,7 +62,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import { FuzzyScore, createMatches } from 'vs/base/common/filters';
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { VariablesRenderer, variableSetEmitter } from 'vs/workbench/contrib/debug/browser/variablesView';
import { VariablesRenderer } from 'vs/workbench/contrib/debug/browser/variablesView';
const $ = dom.$;
@@ -104,6 +104,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
private scopedInstantiationService!: IInstantiationService;
private replElementsChangeListener: IDisposable | undefined;
private styleElement: HTMLStyleElement | undefined;
private completionItemProvider: IDisposable | undefined;
constructor(
@IDebugService private readonly debugService: IDebugService,
@@ -131,7 +132,33 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
this._register(this.debugService.getViewModel().onDidFocusSession(session => {
if (session) {
sessionsToIgnore.delete(session);
if (this.completionItemProvider) {
this.completionItemProvider.dispose();
}
if (session.capabilities.supportsCompletionsRequest) {
this.completionItemProvider = CompletionProviderRegistry.register({ scheme: DEBUG_SCHEME, pattern: '**/replinput', hasAccessToAllModels: true }, {
triggerCharacters: session.capabilities.completionTriggerCharacters || ['.'],
provideCompletionItems: async (_: ITextModel, position: Position, _context: CompletionContext, token: CancellationToken): Promise<CompletionList> => {
// Disable history navigation because up and down are used to navigate through the suggest widget
this.historyNavigationEnablement.set(false);
const model = this.replInput.getModel();
if (model) {
const word = model.getWordAtPosition(position);
const overwriteBefore = word ? word.word.length : 0;
const text = model.getLineContent(position.lineNumber);
const focusedStackFrame = this.debugService.getViewModel().focusedStackFrame;
const frameId = focusedStackFrame ? focusedStackFrame.frameId : undefined;
const suggestions = await session.completions(frameId, text, position, overwriteBefore);
return { suggestions };
}
return Promise.resolve({ suggestions: [] });
}
});
}
}
this.selectSession();
}));
this._register(this.debugService.onWillNewSession(newSession => {
@@ -274,7 +301,6 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
revealLastElement(this.tree);
this.history.add(this.replInput.getValue());
this.replInput.setValue('');
variableSetEmitter.fire();
const shouldRelayout = this.replInputHeight > Repl.REPL_INPUT_INITIAL_HEIGHT;
this.replInputHeight = Repl.REPL_INPUT_INITIAL_HEIGHT;
if (shouldRelayout) {
@@ -418,6 +444,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
private createReplInput(container: HTMLElement): void {
this.replInputContainer = dom.append(container, $('.repl-input-wrapper'));
this.replInputContainer.title = nls.localize('debugConsole', "Debug Console");
const { scopedContextKeyService, historyNavigationEnablement } = createAndBindHistoryNavigationWidgetScopedContextKeyService(this.contextKeyService, { target: this.replInputContainer, historyNavigator: this });
this.historyNavigationEnablement = historyNavigationEnablement;
@@ -430,34 +457,6 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
options.readOnly = true;
this.replInput = this.scopedInstantiationService.createInstance(CodeEditorWidget, this.replInputContainer, options, getSimpleCodeEditorWidgetOptions());
CompletionProviderRegistry.register({ scheme: DEBUG_SCHEME, pattern: '**/replinput', hasAccessToAllModels: true }, {
triggerCharacters: ['.'],
provideCompletionItems: (model: ITextModel, position: Position, _context: CompletionContext, token: CancellationToken): Promise<CompletionList> => {
// Disable history navigation because up and down are used to navigate through the suggest widget
this.historyNavigationEnablement.set(false);
const focusedSession = this.debugService.getViewModel().focusedSession;
if (focusedSession && focusedSession.capabilities.supportsCompletionsRequest) {
const model = this.replInput.getModel();
if (model) {
const word = model.getWordAtPosition(position);
const overwriteBefore = word ? word.word.length : 0;
const text = model.getLineContent(position.lineNumber);
const focusedStackFrame = this.debugService.getViewModel().focusedStackFrame;
const frameId = focusedStackFrame ? focusedStackFrame.frameId : undefined;
return focusedSession.completions(frameId, text, position, overwriteBefore).then(suggestions => {
return { suggestions };
}, err => {
return { suggestions: [] };
});
}
}
return Promise.resolve({ suggestions: [] });
}
});
this._register(this.replInput.onDidScrollChange(e => {
if (!e.scrollHeightChanged) {
return;