Skip to content

Commit 0b0b0f8

Browse files
authored
Merge pull request microsoft#48747 from Microsoft/isidorn/nonDebugHovers
debug: debug.hideNonDebugHovers
2 parents 72b51f3 + a4dec1a commit 0b0b0f8

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

src/vs/workbench/parts/debug/common/debug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ export interface IDebugConfiguration {
351351
showInStatusBar: 'never' | 'always' | 'onFirstSessionStart';
352352
internalConsoleOptions: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart';
353353
extensionHostDebugAdapter: boolean;
354+
enableAllHovers: boolean;
354355
}
355356

356357
export interface IGlobalConfig {

src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ configurationRegistry.registerConfiguration({
205205
default: 'openOnFirstSessionStart',
206206
description: nls.localize('openDebug', "Controls whether debug view should be open on debugging session start.")
207207
},
208+
'debug.enableAllHovers': {
209+
type: 'boolean',
210+
description: nls.localize({ comment: ['This is the description for a setting'], key: 'enableAllHovers' }, "Controls if the non debug hovers should be enabled while debugging. If true the hover providers will be called to provide a hover. Regular hovers will not be shown even if this setting is true."),
211+
default: false
212+
},
208213
'launch': {
209214
type: 'object',
210215
description: nls.localize({ comment: ['This is the description for a setting'], key: 'launch' }, "Global debug launch configuration. Should be used as an alternative to 'launch.json' that is shared across workspaces"),

src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
4545
import { ContextSubMenu } from 'vs/base/browser/contextmenu';
4646
import { memoize } from 'vs/base/common/decorators';
4747
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
48+
import { getHover } from 'vs/editor/contrib/hover/getHover';
4849

4950
const HOVER_DELAY = 300;
5051
const LAUNCH_JSON_REGEX = /launch\.json$/;
@@ -57,6 +58,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
5758

5859
private toDispose: lifecycle.IDisposable[];
5960
private hoverWidget: DebugHoverWidget;
61+
private nonDebugHoverPosition: Position;
6062
private hoverRange: Range;
6163

6264
private breakpointHintDecoration: string[];
@@ -239,6 +241,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
239241
this.toDispose.push(this.editor.onMouseDown((e: IEditorMouseEvent) => this.onEditorMouseDown(e)));
240242
this.toDispose.push(this.editor.onMouseMove((e: IEditorMouseEvent) => this.onEditorMouseMove(e)));
241243
this.toDispose.push(this.editor.onMouseLeave((e: IEditorMouseEvent) => {
244+
this.provideNonDebugHoverScheduler.cancel();
242245
const hoverDomNode = this.hoverWidget.getDomNode();
243246
if (!hoverDomNode) {
244247
return;
@@ -332,19 +335,36 @@ export class DebugEditorContribution implements IDebugEditorContribution {
332335

333336
@memoize
334337
private get showHoverScheduler(): RunOnceScheduler {
335-
return new RunOnceScheduler(() => this.showHover(this.hoverRange, false), HOVER_DELAY);
338+
const scheduler = new RunOnceScheduler(() => this.showHover(this.hoverRange, false), HOVER_DELAY);
339+
this.toDispose.push(scheduler);
340+
341+
return scheduler;
336342
}
337343

338344
@memoize
339345
private get hideHoverScheduler(): RunOnceScheduler {
340-
return new RunOnceScheduler(() => this.hoverWidget.hide(), HOVER_DELAY);
346+
const scheduler = new RunOnceScheduler(() => this.hoverWidget.hide(), HOVER_DELAY);
347+
this.toDispose.push(scheduler);
348+
349+
return scheduler;
350+
}
351+
352+
@memoize
353+
private get provideNonDebugHoverScheduler(): RunOnceScheduler {
354+
const scheduler = new RunOnceScheduler(() => {
355+
getHover(this.editor.getModel(), this.nonDebugHoverPosition);
356+
}, HOVER_DELAY);
357+
this.toDispose.push(scheduler);
358+
359+
return scheduler;
341360
}
342361

343362
private hideHoverWidget(): void {
344363
if (!this.hideHoverScheduler.isScheduled() && this.hoverWidget.isVisible()) {
345364
this.hideHoverScheduler.schedule();
346365
}
347366
this.showHoverScheduler.cancel();
367+
this.provideNonDebugHoverScheduler.cancel();
348368
}
349369

350370
// hover business
@@ -362,6 +382,10 @@ export class DebugEditorContribution implements IDebugEditorContribution {
362382
return;
363383
}
364384

385+
if (!this.configurationService.getValue<IDebugConfiguration>('debug').enableAllHovers) {
386+
this.nonDebugHoverPosition = mouseEvent.target.position;
387+
this.provideNonDebugHoverScheduler.schedule();
388+
}
365389
const targetType = mouseEvent.target.type;
366390
const stopKey = env.isMacintosh ? 'metaKey' : 'ctrlKey';
367391

0 commit comments

Comments
 (0)