提交 84fc56e3 编写于 作者: I isidor

debug: use uriIdentityService for uri comparison

fixes #107830
上级 9ba6b405
......@@ -15,6 +15,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IEditorContribution } from 'vs/editor/common/editorCommon';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { distinct } from 'vs/base/common/arrays';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
const stickiness = TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges;
......@@ -95,6 +96,7 @@ export class CallStackEditorContribution implements IEditorContribution {
constructor(
private readonly editor: ICodeEditor,
@IDebugService private readonly debugService: IDebugService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
const setDecorations = () => this.decorationIds = this.editor.deltaDecorations(this.decorationIds, this.createCallStackDecorations());
this.toDispose.push(Event.any(this.debugService.getViewModel().onDidFocusStackFrame, this.debugService.getModel().onDidChangeCallStack)(() => {
......@@ -122,7 +124,7 @@ export class CallStackEditorContribution implements IEditorContribution {
}
}
if (candidateStackFrame && candidateStackFrame.source.uri.toString() === this.editor.getModel()?.uri.toString()) {
if (candidateStackFrame && this.uriIdentityService.extUri.isEqual(candidateStackFrame.source.uri, this.editor.getModel()?.uri)) {
decorations.push(...createDecorationsForStackFrame(candidateStackFrame, this.topStackFrameRange, isSessionFocused));
}
}
......
......@@ -40,6 +40,7 @@ import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { flatten } from 'vs/base/common/arrays';
import { getVisibleAndSorted } from 'vs/workbench/contrib/debug/common/debugUtils';
import { DebugConfigurationProviderTriggerKind } from 'vs/workbench/api/common/extHostTypes';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
const jsonRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
jsonRegistry.registerSchema(launchSchemaId, launchSchema);
......@@ -78,6 +79,7 @@ export class ConfigurationManager implements IConfigurationManager {
@IStorageService private readonly storageService: IStorageService,
@IExtensionService private readonly extensionService: IExtensionService,
@IHistoryService private readonly historyService: IHistoryService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IContextKeyService contextKeyService: IContextKeyService
) {
this.configProviders = [];
......@@ -491,7 +493,7 @@ export class ConfigurationManager implements IConfigurationManager {
return undefined;
}
return this.launches.find(l => l.workspace && l.workspace.uri.toString() === workspaceUri.toString());
return this.launches.find(l => l.workspace && this.uriIdentityService.extUri.isEqual(l.workspace.uri, workspaceUri));
}
get selectedConfiguration(): { launch: ILaunch | undefined, name: string | undefined, config: IConfig | undefined, type: string | undefined } {
......
......@@ -19,6 +19,7 @@ import { IViewsService } from 'vs/workbench/common/views';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Action } from 'vs/base/common/actions';
import { getDomNodePagePosition } from 'vs/base/browser/dom';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
export const TOGGLE_BREAKPOINT_ID = 'editor.debug.action.toggleBreakpoint';
class ToggleBreakpointAction extends EditorAction {
......@@ -122,6 +123,7 @@ export class RunToCursorAction extends EditorAction {
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
const debugService = accessor.get(IDebugService);
const uriIdentityService = accessor.get(IUriIdentityService);
const focusedSession = debugService.getViewModel().focusedSession;
if (debugService.state !== State.Stopped || !focusedSession) {
return;
......@@ -145,7 +147,7 @@ export class RunToCursorAction extends EditorAction {
if (!bpExists) {
let column = 0;
const focusedStackFrame = debugService.getViewModel().focusedStackFrame;
if (focusedStackFrame && focusedStackFrame.source.uri.toString() === uri.toString() && focusedStackFrame.range.startLineNumber === position.lineNumber) {
if (focusedStackFrame && uriIdentityService.extUri.isEqual(focusedStackFrame.source.uri, uri) && focusedStackFrame.range.startLineNumber === position.lineNumber) {
// If the cursor is on a line different than the one the debugger is currently paused on, then send the breakpoint at column 0 on the line
// otherwise set it at the precise column #102199
column = position.column;
......@@ -272,10 +274,11 @@ class StepIntoTargetsAction extends EditorAction {
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
const debugService = accessor.get(IDebugService);
const contextMenuService = accessor.get(IContextMenuService);
const uriIdentityService = accessor.get(IUriIdentityService);
const session = debugService.getViewModel().focusedSession;
const frame = debugService.getViewModel().focusedStackFrame;
if (session && frame && editor.hasModel() && editor.getModel().uri.toString() === frame.source.uri.toString()) {
if (session && frame && editor.hasModel() && uriIdentityService.extUri.isEqual(editor.getModel().uri, frame.source.uri)) {
const targets = await session.stepInTargets(frame.frameId);
if (!targets) {
return;
......@@ -305,6 +308,8 @@ class GoToBreakpointAction extends EditorAction {
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<any> {
const debugService = accessor.get(IDebugService);
const editorService = accessor.get(IEditorService);
const uriIdentityService = accessor.get(IUriIdentityService);
if (editor.hasModel()) {
const currentUri = editor.getModel().uri;
const currentLine = editor.getPosition().lineNumber;
......@@ -314,8 +319,8 @@ class GoToBreakpointAction extends EditorAction {
//Try to find breakpoint in current file
let moveBreakpoint =
this.isNext
? allEnabledBreakpoints.filter(bp => bp.uri.toString() === currentUri.toString() && bp.lineNumber > currentLine).shift()
: allEnabledBreakpoints.filter(bp => bp.uri.toString() === currentUri.toString() && bp.lineNumber < currentLine).pop();
? allEnabledBreakpoints.filter(bp => uriIdentityService.extUri.isEqual(bp.uri, currentUri) && bp.lineNumber > currentLine).shift()
: allEnabledBreakpoints.filter(bp => uriIdentityService.extUri.isEqual(bp.uri, currentUri) && bp.lineNumber < currentLine).pop();
//Try to find breakpoints in following files
if (!moveBreakpoint) {
......
......@@ -38,6 +38,7 @@ import { ModesHoverController } from 'vs/editor/contrib/hover/hover';
import { HoverStartMode } from 'vs/editor/contrib/hover/hoverOperation';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { Event } from 'vs/base/common/event';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
const LAUNCH_JSON_REGEX = /\.vscode\/launch\.json$/;
const INLINE_VALUE_DECORATION_KEY = 'inlinevaluedecoration';
......@@ -187,7 +188,8 @@ export class DebugEditorContribution implements IDebugEditorContribution {
@ICodeEditorService private readonly codeEditorService: ICodeEditorService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IHostService private readonly hostService: IHostService
@IHostService private readonly hostService: IHostService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
this.hoverWidget = this.instantiationService.createInstance(DebugHoverWidget, this.editor);
this.toDispose = [];
......@@ -247,7 +249,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
}
private applyHoverConfiguration(model: ITextModel, stackFrame: IStackFrame | undefined): void {
if (stackFrame && model.uri.toString() === stackFrame.source.uri.toString()) {
if (stackFrame && this.uriIdentityService.extUri.isEqual(model.uri, stackFrame.source.uri)) {
if (this.altListener) {
this.altListener.dispose();
}
......@@ -307,7 +309,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
async showHover(range: Range, focus: boolean): Promise<void> {
const sf = this.debugService.getViewModel().focusedStackFrame;
const model = this.editor.getModel();
if (sf && model && sf.source.uri.toString() === model.uri.toString() && !this.altPressed) {
if (sf && model && this.uriIdentityService.extUri.isEqual(sf.source.uri, model.uri) && !this.altPressed) {
return this.hoverWidget.showAt(range, focus);
}
}
......@@ -316,7 +318,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
const model = this.editor.getModel();
if (model) {
this.applyHoverConfiguration(model, sf);
if (sf && sf.source.uri.toString() === model.uri.toString()) {
if (sf && this.uriIdentityService.extUri.isEqual(sf.source.uri, model.uri)) {
await this.toggleExceptionWidget();
} else {
this.hideHoverWidget();
......@@ -421,7 +423,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
return;
}
const sameUri = exceptionSf.source.uri.toString() === model.uri.toString();
const sameUri = this.uriIdentityService.extUri.isEqual(exceptionSf.source.uri, model.uri);
if (this.exceptionWidget && !sameUri) {
this.closeExceptionWidget();
} else if (sameUri) {
......
......@@ -48,6 +48,7 @@ import { DebugTelemetry } from 'vs/workbench/contrib/debug/common/debugTelemetry
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
export class DebugService implements IDebugService {
declare readonly _serviceBrand: undefined;
......@@ -92,7 +93,8 @@ export class DebugService implements IDebugService {
@IExtensionHostDebugService private readonly extensionHostDebugService: IExtensionHostDebugService,
@IActivityService private readonly activityService: IActivityService,
@ICommandService private readonly commandService: ICommandService,
@IQuickInputService private readonly quickInputService: IQuickInputService
@IQuickInputService private readonly quickInputService: IQuickInputService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
this.toDispose = [];
......@@ -295,7 +297,7 @@ export class DebugService implements IDebugService {
const sessions = this.model.getSessions();
const alreadyRunningMessage = nls.localize('configurationAlreadyRunning', "There is already a debug configuration \"{0}\" running.", configOrName);
if (sessions.some(s => s.configuration.name === configOrName && (!launch || !launch.workspace || !s.root || s.root.uri.toString() === launch.workspace.uri.toString()))) {
if (sessions.some(s => s.configuration.name === configOrName && (!launch || !launch.workspace || !s.root || this.uriIdentityService.extUri.isEqual(s.root.uri, launch.workspace.uri)))) {
throw new Error(alreadyRunningMessage);
}
if (compound && compound.configurations && sessions.some(p => compound!.configurations.indexOf(p.configuration.name) !== -1)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册