提交 3118955e 编写于 作者: I isidor

debug: when the alt key is pressed show regular editor hover and hide the debug hover

#84561
上级 3808cb37
......@@ -10,7 +10,7 @@ import { visit } from 'vs/base/common/json';
import { setProperty } from 'vs/base/common/jsonEdit';
import { Constants } from 'vs/base/common/uint';
import { KeyCode } from 'vs/base/common/keyCodes';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { StandardTokenType } from 'vs/editor/common/modes';
import { DEFAULT_WORD_REGEXP } from 'vs/editor/common/model/wordHelper';
import { ICodeEditor, IEditorMouseEvent, MouseTargetType, IPartialEditorMouseEvent } from 'vs/editor/browser/editorBrowser';
......@@ -33,6 +33,7 @@ import { ITextModel } from 'vs/editor/common/model';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { basename } from 'vs/base/common/path';
import { domEvent } from 'vs/base/browser/event';
const HOVER_DELAY = 300;
const LAUNCH_JSON_REGEX = /\.vscode\/launch\.json$/;
......@@ -171,8 +172,9 @@ export class DebugEditorContribution implements IDebugEditorContribution {
private static readonly MEMOIZER = createMemoizer();
private exceptionWidget: ExceptionWidget | undefined;
private configurationWidget: FloatingClickWidget | undefined;
private altListener: IDisposable | undefined;
private altPressed = false;
constructor(
private editor: ICodeEditor,
......@@ -219,7 +221,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
const model = this.editor.getModel();
if (model) {
this._applyHoverConfiguration(model, stackFrame);
this.applyHoverConfiguration(model, stackFrame);
}
this.toggleExceptionWidget();
this.hideHoverWidget();
......@@ -240,14 +242,38 @@ export class DebugEditorContribution implements IDebugEditorContribution {
return getWordToLineNumbersMap(this.editor.getModel());
}
private _applyHoverConfiguration(model: ITextModel, stackFrame: IStackFrame | undefined): void {
private applyHoverConfiguration(model: ITextModel, stackFrame: IStackFrame | undefined): void {
if (stackFrame && model.uri.toString() === stackFrame.source.uri.toString()) {
this.editor.updateOptions({
hover: {
enabled: false
if (this.altListener) {
this.altListener.dispose();
}
// When the alt key is pressed show regular editor hover and hide the debug hover #84561
this.altListener = domEvent(document, 'keydown')(keydownEvent => {
const standardKeyboardEvent = new StandardKeyboardEvent(keydownEvent);
if (standardKeyboardEvent.keyCode === KeyCode.Alt) {
this.altPressed = true;
this.hoverWidget.hide();
this.enableEditorHover();
const listener = domEvent(document, 'keyup')(keyupEvent => {
const standardKeyboardEvent = new StandardKeyboardEvent(keyupEvent);
if (standardKeyboardEvent.keyCode === KeyCode.Alt) {
this.altPressed = false;
this.editor.updateOptions({ hover: { enabled: false } });
listener.dispose();
}
});
}
});
this.editor.updateOptions({ hover: { enabled: false } });
} else {
this.enableEditorHover();
}
}
private enableEditorHover(): void {
if (this.editor.hasModel()) {
const model = this.editor.getModel();
let overrides = {
resource: model.uri,
overrideIdentifier: model.getLanguageIdentifier().language
......@@ -266,7 +292,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()) {
if (sf && model && sf.source.uri.toString() === model.uri.toString() && !this.altPressed) {
return this.hoverWidget.showAt(range, focus);
}
}
......@@ -274,7 +300,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
private async onFocusStackFrame(sf: IStackFrame | undefined): Promise<void> {
const model = this.editor.getModel();
if (model) {
this._applyHoverConfiguration(model, sf);
this.applyHoverConfiguration(model, sf);
if (sf && sf.source.uri.toString() === model.uri.toString()) {
await this.toggleExceptionWidget();
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册