Repository: microsoft/vscode
File: src/vs/editor/contrib/hover/browser/contentHoverController.ts (TypeScript)

Code before:
		if (shouldShowHover(
			this._hoverSettings.enabled,
			this._editor.getOption(EditorOption.multiCursorModifier),
			mouseEvent
		)) {
			const contentWidget: ContentHoverWidgetWrapper = this._getOrCreateContentWidget();
			if (contentWidget.showsOrWillShow(mouseEvent)) {
				return;
			}
		}
		if (_sticky) {
			return;
		}
		this.hideContentHover();
	}

	private _onKeyDown(e: IKeyboardEvent): void {
		if (this._ignoreMouseEvents) {
			return;
		}
		// New behavior: if hover is configured for keyboard modifier and the user presses the triggering modifier
		// we should show the hover immediately for the current (last known) mouse location even without moving the mouse again.
		if (this._hoverSettings.enabled === 'onKeyboardModifier' && this._mouseMoveEvent) {
			const multiCursorModifier = this._editor.getOption(EditorOption.multiCursorModifier); // 'altKey' | 'ctrlKey' | 'metaKey'
			const triggerPressed = isTriggerModifierPressed(multiCursorModifier, e);
			if (triggerPressed) {
				// Avoid re-trigger if already visible
				if (!this._contentWidget?.isVisible) {
					// Get the position/range from the last mouse event and show hover immediately
					const mouseTarget = this._mouseMoveEvent.target;
					if (mouseTarget.position) {
						this.showContentHover(
							Range.fromPositions(mouseTarget.position),
							HoverStartMode.Immediate,
							HoverStartSource.Keyboard,
							false
						);
					}
				}
				// Do not hide hover for this key press
				return;
			}
		}
		if (!this._contentWidget) {
			return;
		}
		const isPotentialKeyboardShortcut = this._isPotentialKeyboardShortcut(e);
		const isModifierKeyPressed = this._isModifierKeyPressed(e);
		if (isPotentialKeyboardShortcut || isModifierKeyPressed) {
			return;
		}

Review comment (suggestion):
Nit, this is simpler:
```suggestion
			const multiCursorModifier = this._editor.getOption(EditorOption.multiCursorModifier);
			if (isTriggerModifierPressed(multiCursorModifier, e)) {
```

Code after:
		if (shouldShowHover(
			this._hoverSettings.enabled,
			this._editor.getOption(EditorOption.multiCursorModifier),
			mouseEvent
		)) {
			const contentWidget: ContentHoverWidgetWrapper = this._getOrCreateContentWidget();
			if (contentWidget.showsOrWillShow(mouseEvent)) {
				return;
			}
		}
		if (_sticky) {
			return;
		}
		this.hideContentHover();
	}

	private _onKeyDown(e: IKeyboardEvent): void {
		if (this._ignoreMouseEvents || !this._contentWidget) {
			return;
		}

		if (this._hoverSettings.enabled === 'onKeyboardModifier'
			&& isTriggerModifierPressed(this._editor.getOption(EditorOption.multiCursorModifier), e)
			&& this._mouseMoveEvent) {
			if (!this._contentWidget.isVisible) {
				this._contentWidget.showsOrWillShow(this._mouseMoveEvent);
			}
			return;
		}

		const isPotentialKeyboardShortcut = this._isPotentialKeyboardShortcut(e);
		const isModifierKeyPressed = isModifierKey(e.keyCode);
		if (isPotentialKeyboardShortcut || isModifierKeyPressed) {
			return;
		}
		if (this._contentWidget.isFocused && e.keyCode === KeyCode.Tab) {
			return;
		}
		this.hideContentHover();
	}

	private _isPotentialKeyboardShortcut(e: IKeyboardEvent): boolean {
		if (!this._editor.hasModel() || !this._contentWidget) {
			return false;
		}
		const resolvedKeyboardEvent = this._keybindingService.softDispatch(e, this._editor.getDomNode());
		const moreChordsAreNeeded = resolvedKeyboardEvent.kind === ResultKind.MoreChordsNeeded;
		const isHoverAction = resolvedKeyboardEvent.kind === ResultKind.KbFound
			&& (resolvedKeyboardEvent.commandId === SHOW_OR_FOCUS_HOVER_ACTION_ID
				|| resolvedKeyboardEvent.commandId === INCREASE_HOVER_VERBOSITY_ACTION_ID
				|| resolvedKeyboardEvent.commandId === DECREASE_HOVER_VERBOSITY_ACTION_ID)