Skip to content

Commit 3118955

Browse files
committed
debug: when the alt key is pressed show regular editor hover and hide the debug hover
microsoft#84561
1 parent 3808cb3 commit 3118955

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { visit } from 'vs/base/common/json';
1010
import { setProperty } from 'vs/base/common/jsonEdit';
1111
import { Constants } from 'vs/base/common/uint';
1212
import { KeyCode } from 'vs/base/common/keyCodes';
13-
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
13+
import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
1414
import { StandardTokenType } from 'vs/editor/common/modes';
1515
import { DEFAULT_WORD_REGEXP } from 'vs/editor/common/model/wordHelper';
1616
import { ICodeEditor, IEditorMouseEvent, MouseTargetType, IPartialEditorMouseEvent } from 'vs/editor/browser/editorBrowser';
@@ -33,6 +33,7 @@ import { ITextModel } from 'vs/editor/common/model';
3333
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
3434
import { EditOperation } from 'vs/editor/common/core/editOperation';
3535
import { basename } from 'vs/base/common/path';
36+
import { domEvent } from 'vs/base/browser/event';
3637

3738
const HOVER_DELAY = 300;
3839
const LAUNCH_JSON_REGEX = /\.vscode\/launch\.json$/;
@@ -171,8 +172,9 @@ export class DebugEditorContribution implements IDebugEditorContribution {
171172
private static readonly MEMOIZER = createMemoizer();
172173

173174
private exceptionWidget: ExceptionWidget | undefined;
174-
175175
private configurationWidget: FloatingClickWidget | undefined;
176+
private altListener: IDisposable | undefined;
177+
private altPressed = false;
176178

177179
constructor(
178180
private editor: ICodeEditor,
@@ -219,7 +221,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
219221
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
220222
const model = this.editor.getModel();
221223
if (model) {
222-
this._applyHoverConfiguration(model, stackFrame);
224+
this.applyHoverConfiguration(model, stackFrame);
223225
}
224226
this.toggleExceptionWidget();
225227
this.hideHoverWidget();
@@ -240,14 +242,38 @@ export class DebugEditorContribution implements IDebugEditorContribution {
240242
return getWordToLineNumbersMap(this.editor.getModel());
241243
}
242244

243-
private _applyHoverConfiguration(model: ITextModel, stackFrame: IStackFrame | undefined): void {
245+
private applyHoverConfiguration(model: ITextModel, stackFrame: IStackFrame | undefined): void {
244246
if (stackFrame && model.uri.toString() === stackFrame.source.uri.toString()) {
245-
this.editor.updateOptions({
246-
hover: {
247-
enabled: false
247+
if (this.altListener) {
248+
this.altListener.dispose();
249+
}
250+
// When the alt key is pressed show regular editor hover and hide the debug hover #84561
251+
this.altListener = domEvent(document, 'keydown')(keydownEvent => {
252+
const standardKeyboardEvent = new StandardKeyboardEvent(keydownEvent);
253+
if (standardKeyboardEvent.keyCode === KeyCode.Alt) {
254+
this.altPressed = true;
255+
this.hoverWidget.hide();
256+
this.enableEditorHover();
257+
const listener = domEvent(document, 'keyup')(keyupEvent => {
258+
const standardKeyboardEvent = new StandardKeyboardEvent(keyupEvent);
259+
if (standardKeyboardEvent.keyCode === KeyCode.Alt) {
260+
this.altPressed = false;
261+
this.editor.updateOptions({ hover: { enabled: false } });
262+
listener.dispose();
263+
}
264+
});
248265
}
249266
});
267+
268+
this.editor.updateOptions({ hover: { enabled: false } });
250269
} else {
270+
this.enableEditorHover();
271+
}
272+
}
273+
274+
private enableEditorHover(): void {
275+
if (this.editor.hasModel()) {
276+
const model = this.editor.getModel();
251277
let overrides = {
252278
resource: model.uri,
253279
overrideIdentifier: model.getLanguageIdentifier().language
@@ -266,15 +292,15 @@ export class DebugEditorContribution implements IDebugEditorContribution {
266292
async showHover(range: Range, focus: boolean): Promise<void> {
267293
const sf = this.debugService.getViewModel().focusedStackFrame;
268294
const model = this.editor.getModel();
269-
if (sf && model && sf.source.uri.toString() === model.uri.toString()) {
295+
if (sf && model && sf.source.uri.toString() === model.uri.toString() && !this.altPressed) {
270296
return this.hoverWidget.showAt(range, focus);
271297
}
272298
}
273299

274300
private async onFocusStackFrame(sf: IStackFrame | undefined): Promise<void> {
275301
const model = this.editor.getModel();
276302
if (model) {
277-
this._applyHoverConfiguration(model, sf);
303+
this.applyHoverConfiguration(model, sf);
278304
if (sf && sf.source.uri.toString() === model.uri.toString()) {
279305
await this.toggleExceptionWidget();
280306
} else {

0 commit comments

Comments
 (0)