Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Breakpoint Decoration Rendering #12249

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions packages/debug/src/browser/editor/debug-editor-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import URI from '@theia/core/lib/common/uri';
import { Disposable, DisposableCollection, MenuPath, isOSX } from '@theia/core';
import { ContextMenuRenderer } from '@theia/core/lib/browser';
import { MonacoConfigurationService } from '@theia/monaco/lib/browser/monaco-frontend-module';
import { BreakpointManager } from '../breakpoint/breakpoint-manager';
import { BreakpointManager, SourceBreakpointsChangeEvent } from '../breakpoint/breakpoint-manager';
import { DebugSourceBreakpoint } from '../model/debug-source-breakpoint';
import { DebugSessionManager } from '../debug-session-manager';
import { SourceBreakpoint } from '../breakpoint/breakpoint-marker';
Expand Down Expand Up @@ -97,6 +97,9 @@ export class DebugEditorModel implements Disposable {
@inject(MonacoConfigurationService)
readonly configurationService: IConfigurationService;

@inject(DebugSessionManager)
protected readonly sessionManager: DebugSessionManager;

@postConstruct()
protected init(): void {
this.uri = new URI(this.editor.getControl().getModel()!.uri.toString());
Expand All @@ -112,7 +115,13 @@ export class DebugEditorModel implements Disposable {
this.editor.getControl().getModel()!.onDidChangeDecorations(() => this.updateBreakpoints()),
this.editor.onDidResize(e => this.breakpointWidget.inputSize = e),
this.sessions.onDidChange(() => this.update()),
this.toDisposeOnUpdate
this.toDisposeOnUpdate,
this.sessionManager.onDidChangeBreakpoints(({ session, uri }) => {
if ((!session || session === this.sessionManager.currentSession) && uri.isEqual(this.uri)) {
this.render();
}
}),
this.breakpoints.onDidChangeBreakpoints(event => this.closeBreakpointIfAffected(event)),
]);
this.update();
this.render();
Expand Down Expand Up @@ -444,6 +453,22 @@ export class DebugEditorModel implements Disposable {
return [];
}

protected closeBreakpointIfAffected({ uri, removed }: SourceBreakpointsChangeEvent): void {
if (!uri.isEqual(this.uri)) {
return;
}
const position = this.breakpointWidget.position;
if (!position) {
return;
}
for (const breakpoint of removed) {
if (breakpoint.raw.line === position.lineNumber) {
this.breakpointWidget.hide();
break;
}
}
}

protected showHover(mouseEvent: monaco.editor.IEditorMouseEvent): void {
const targetType = mouseEvent.target.type;
const stopKey = isOSX ? 'metaKey' : 'ctrlKey';
Expand Down Expand Up @@ -472,7 +497,7 @@ export class DebugEditorModel implements Disposable {
protected deltaDecorations(oldDecorations: string[], newDecorations: monaco.editor.IModelDeltaDecoration[]): string[] {
this.updatingDecorations = true;
try {
return this.editor.getControl().getModel()!.deltaDecorations(oldDecorations, newDecorations);
return this.editor.getControl().deltaDecorations(oldDecorations, newDecorations);
} finally {
this.updatingDecorations = false;
}
Expand Down
14 changes: 0 additions & 14 deletions packages/debug/src/browser/editor/debug-editor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
import * as monaco from '@theia/monaco-editor-core';
import URI from '@theia/core/lib/common/uri';
import { EditorManager, EditorWidget } from '@theia/editor/lib/browser';
import { ContextMenuRenderer } from '@theia/core/lib/browser';
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
Expand Down Expand Up @@ -50,12 +49,6 @@ export class DebugEditorService {
protected init(): void {
this.editors.all.forEach(widget => this.push(widget));
this.editors.onCreated(widget => this.push(widget));
this.sessionManager.onDidChangeBreakpoints(({ session, uri }) => {
if (!session || session === this.sessionManager.currentSession) {
this.render(uri);
}
});
this.breakpoints.onDidChangeBreakpoints(event => this.closeBreakpointIfAffected(event));
}

protected push(widget: EditorWidget): void {
Expand All @@ -72,13 +65,6 @@ export class DebugEditorService {
});
}

protected render(uri: URI): void {
const model = this.models.get(uri.toString());
if (model) {
model.render();
}
}

get model(): DebugEditorModel | undefined {
const { currentEditor } = this.editors;
const uri = currentEditor && currentEditor.getResourceUri();
Expand Down