提交 5ac625f8 编写于 作者: I isidor

debug: fix breakpoint line for dirty files

fixes #56398
上级 ae5fff07
......@@ -29,7 +29,6 @@ import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewl
import { attachInputBoxStyler } from 'vs/platform/theme/common/styler';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { ILabelService } from 'vs/platform/label/common/label';
......@@ -296,8 +295,7 @@ class BreakpointsRenderer implements IRenderer<IBreakpoint, IBreakpointTemplateD
constructor(
@IDebugService private debugService: IDebugService,
@ILabelService private labelService: ILabelService,
@ITextFileService private textFileService: ITextFileService
@ILabelService private labelService: ILabelService
) {
// noop
}
......@@ -343,7 +341,7 @@ class BreakpointsRenderer implements IRenderer<IBreakpoint, IBreakpointTemplateD
data.filePath.textContent = this.labelService.getUriLabel(resources.dirname(breakpoint.uri), true);
data.checkbox.checked = breakpoint.enabled;
const { message, className } = getBreakpointMessageAndClassName(this.debugService, this.textFileService, breakpoint);
const { message, className } = getBreakpointMessageAndClassName(this.debugService, breakpoint);
data.icon.className = className + ' icon';
data.breakpoint.title = breakpoint.message || message || '';
......@@ -413,8 +411,7 @@ class ExceptionBreakpointsRenderer implements IRenderer<IExceptionBreakpoint, IB
class FunctionBreakpointsRenderer implements IRenderer<FunctionBreakpoint, IBaseBreakpointWithIconTemplateData> {
constructor(
@IDebugService private debugService: IDebugService,
@ITextFileService private textFileService: ITextFileService
@IDebugService private debugService: IDebugService
) {
// noop
}
......@@ -447,7 +444,7 @@ class FunctionBreakpointsRenderer implements IRenderer<FunctionBreakpoint, IBase
renderElement(functionBreakpoint: FunctionBreakpoint, index: number, data: IBaseBreakpointWithIconTemplateData): void {
data.context = functionBreakpoint;
data.name.textContent = functionBreakpoint.name;
const { className, message } = getBreakpointMessageAndClassName(this.debugService, this.textFileService, functionBreakpoint);
const { className, message } = getBreakpointMessageAndClassName(this.debugService, functionBreakpoint);
data.icon.className = className + ' icon';
data.icon.title = message ? message : '';
data.checkbox.checked = functionBreakpoint.enabled;
......@@ -577,7 +574,7 @@ export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolea
}, sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
}
export function getBreakpointMessageAndClassName(debugService: IDebugService, textFileService: ITextFileService, breakpoint: IBreakpoint | FunctionBreakpoint): { message?: string, className: string } {
export function getBreakpointMessageAndClassName(debugService: IDebugService, breakpoint: IBreakpoint | FunctionBreakpoint): { message?: string, className: string } {
const state = debugService.state;
const debugActive = state === State.Running || state === State.Stopped;
......@@ -612,14 +609,6 @@ export function getBreakpointMessageAndClassName(debugService: IDebugService, te
};
}
if (debugActive && textFileService.isDirty(breakpoint.uri)) {
return {
className: 'debug-breakpoint-unverified',
message: appendMessage(nls.localize('breakpointDirtydHover', "Unverified breakpoint. File is modified, please restart debug session.")),
};
}
if (breakpoint.logMessage || breakpoint.condition || breakpoint.hitCondition) {
const messages = [];
if (breakpoint.logMessage) {
......
......@@ -12,7 +12,6 @@ import { IDebugService, IBreakpoint, State, IBreakpointUpdateData } from 'vs/wor
import { IModelService } from 'vs/editor/common/services/modelService';
import { MarkdownString } from 'vs/base/common/htmlContent';
import { getBreakpointMessageAndClassName } from 'vs/workbench/parts/debug/browser/breakpointsView';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
interface IBreakpointDecoration {
decorationId: string;
......@@ -38,7 +37,6 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
constructor(
@IModelService private modelService: IModelService,
@IDebugService private debugService: IDebugService,
@ITextFileService private textFileService: ITextFileService
) {
this.modelDataMap = new Map<string, IDebugEditorModelData>();
this.toDispose = [];
......@@ -277,7 +275,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
}
private getBreakpointDecorationOptions(breakpoint: IBreakpoint): IModelDecorationOptions {
const { className, message } = getBreakpointMessageAndClassName(this.debugService, this.textFileService, breakpoint);
const { className, message } = getBreakpointMessageAndClassName(this.debugService, breakpoint);
let glyphMarginHoverMessage: MarkdownString;
if (message) {
......
......@@ -24,6 +24,7 @@ import { Source } from 'vs/workbench/parts/debug/common/debugSource';
import { commonSuffixLength } from 'vs/base/common/strings';
import { sep } from 'vs/base/common/paths';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
const MAX_REPL_LENGTH = 10000;
......@@ -622,6 +623,7 @@ export class Breakpoint extends BaseBreakpoint implements IBreakpoint {
hitCondition: string,
logMessage: string,
private _adapterData: any,
private textFileService: ITextFileService,
id = generateUuid()
) {
super(enabled, hitCondition, condition, logMessage, id);
......@@ -629,7 +631,16 @@ export class Breakpoint extends BaseBreakpoint implements IBreakpoint {
public get lineNumber(): number {
const data = this.getSessionData();
return data && typeof data.line === 'number' ? data.line : this._lineNumber;
return this.verified && data && typeof data.line === 'number' ? data.line : this._lineNumber;
}
public get verified(): boolean {
const data = this.getSessionData();
if (data) {
return data.verified && !this.textFileService.isDirty(this.uri);
}
return true;
}
public get column(): number {
......@@ -640,7 +651,14 @@ export class Breakpoint extends BaseBreakpoint implements IBreakpoint {
public get message(): string {
const data = this.getSessionData();
return data ? data.message : undefined;
if (!data) {
return undefined;
}
if (this.textFileService.isDirty(this.uri)) {
return nls.localize('breakpointDirtydHover', "Unverified breakpoint. File is modified, please restart debug session.");
}
return data.message;
}
public get adapterData(): any {
......@@ -695,7 +713,8 @@ export class FunctionBreakpoint extends BaseBreakpoint implements IFunctionBreak
hitCondition: string,
condition: string,
logMessage: string,
id = generateUuid()) {
id = generateUuid()
) {
super(enabled, hitCondition, condition, logMessage, id);
}
......@@ -748,7 +767,8 @@ export class Model implements IModel {
private breakpointsActivated: boolean,
private functionBreakpoints: FunctionBreakpoint[],
private exceptionBreakpoints: ExceptionBreakpoint[],
private watchExpressions: Expression[]
private watchExpressions: Expression[],
private textFileService: ITextFileService
) {
this.sessions = [];
this.replElements = [];
......@@ -886,7 +906,7 @@ export class Model implements IModel {
}
public addBreakpoints(uri: uri, rawData: IBreakpointData[], fireEvent = true): IBreakpoint[] {
const newBreakpoints = rawData.map(rawBp => new Breakpoint(uri, rawBp.lineNumber, rawBp.column, rawBp.enabled, rawBp.condition, rawBp.hitCondition, rawBp.logMessage, undefined, rawBp.id));
const newBreakpoints = rawData.map(rawBp => new Breakpoint(uri, rawBp.lineNumber, rawBp.column, rawBp.enabled, rawBp.condition, rawBp.hitCondition, rawBp.logMessage, undefined, this.textFileService, rawBp.id));
newBreakpoints.forEach(bp => bp.setSessionId(this.breakpointsSessionId));
this.breakpoints = this.breakpoints.concat(newBreakpoints);
this.breakpointsActivated = true;
......
......@@ -114,7 +114,7 @@ export class DebugService implements IDebugService {
this.inDebugMode = CONTEXT_IN_DEBUG_MODE.bindTo(contextKeyService);
this.model = new Model(this.loadBreakpoints(), this.storageService.getBoolean(DEBUG_BREAKPOINTS_ACTIVATED_KEY, StorageScope.WORKSPACE, true), this.loadFunctionBreakpoints(),
this.loadExceptionBreakpoints(), this.loadWatchExpressions());
this.loadExceptionBreakpoints(), this.loadWatchExpressions(), this.textFileService);
this.toDispose.push(this.model);
this.viewModel = new ViewModel(contextKeyService);
......@@ -267,7 +267,7 @@ export class DebugService implements IDebugService {
let result: Breakpoint[];
try {
result = JSON.parse(this.storageService.get(DEBUG_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((breakpoint: any) => {
return new Breakpoint(uri.parse(breakpoint.uri.external || breakpoint.source.uri.external), breakpoint.lineNumber, breakpoint.column, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition, breakpoint.logMessage, breakpoint.adapterData);
return new Breakpoint(uri.parse(breakpoint.uri.external || breakpoint.source.uri.external), breakpoint.lineNumber, breakpoint.column, breakpoint.enabled, breakpoint.condition, breakpoint.hitCondition, breakpoint.logMessage, breakpoint.adapterData, this.textFileService);
});
} catch (e) { }
......
......@@ -17,7 +17,7 @@ suite('Debug - Model', () => {
let rawSession: MockRawSession;
setup(() => {
model = new Model([], true, [], [], []);
model = new Model([], true, [], [], [], <any>{ isDirty: (e: any) => false });
rawSession = new MockRawSession();
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册