Skip to content

Add config for linkActivationModifier and prevent link following when any other modifiers are down#302647

Open
calad0i wants to merge 3 commits intomicrosoft:mainfrom
calad0i:main
Open

Add config for linkActivationModifier and prevent link following when any other modifiers are down#302647
calad0i wants to merge 3 commits intomicrosoft:mainfrom
calad0i:main

Conversation

@calad0i
Copy link

@calad0i calad0i commented Mar 18, 2026

This PR implements what is requested in #302645, mainly to prevent unwanted link following when extra modifiers are down, and isolates link following modifier in terminal from multiCursorModifier. The new config key is terminal.integrated.linkActivationModifier.

Copilot AI review requested due to automatic review settings March 18, 2026 03:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated terminal setting to control which modifier activates link following, and tightens activation so only the configured modifier (with no additional modifiers) triggers link opening. This addresses unwanted link opens during common key combos (e.g. Ctrl+Shift+C) and decouples terminal link activation from the editor’s multiCursorModifier.

Changes:

  • Introduce terminal.integrated.linkActivationModifier (ctrlCmd/alt/disabled) and wire it into terminal link activation + hover messaging.
  • Enforce “exactly one modifier” semantics via a shared isLinkModifierDown helper.
  • Extend terminal configuration typing and setting registry for the new key.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkManager.ts Reads the new terminal setting for activation checks and hover hint text.
src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkHelpers.ts Adds isLinkModifierDown helper to enforce “no extra modifiers” behavior.
src/vs/workbench/contrib/terminalContrib/links/browser/terminalLink.ts Switches modifier detection to the new terminal setting via the shared helper.
src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts Registers the new terminal.integrated.linkActivationModifier setting and its descriptions/default.
src/vs/workbench/contrib/terminal/common/terminal.ts Extends ITerminalConfiguration with linkActivationModifier.
src/vs/platform/terminal/common/terminal.ts Adds TerminalSettingId.LinkActivationModifier.
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkManager.ts:450

  • clickLabel can remain empty when terminal.integrated.linkActivationModifier is set to 'disabled', but the hover string always appends (${clickLabel}). This will render as empty parentheses like () in the hover. Consider only appending the modifier hint when clickLabel is non-empty (and/or show a dedicated localized hint for the disabled case).
		const modifier = this._configurationService.getValue<ITerminalConfiguration>(TERMINAL_CONFIG_SECTION).linkActivationModifier;

		let clickLabel = '';
		if (modifier === 'alt') {
			if (isMacintosh) {
				clickLabel = nls.localize('terminalLinkHandler.followLinkAlt.mac', "option + click");
			} else {
				clickLabel = nls.localize('terminalLinkHandler.followLinkAlt', "alt + click");
			}
		} else if (modifier === 'ctrlCmd') {
			if (isMacintosh) {
				clickLabel = nls.localize('terminalLinkHandler.followLinkCmd', "cmd + click");
			} else {
				clickLabel = nls.localize('terminalLinkHandler.followLinkCtrl', "ctrl + click");
			}
		}

Comment on lines +261 to +271
export function isLinkModifierDown(event: MouseEvent | KeyboardEvent, modifier: 'ctrlCmd' | 'alt' | 'disabled'): boolean {
if (modifier === 'disabled') {
return false;
}
if (modifier === 'alt') {
return event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey;
}
const primaryKey = isMacintosh ? event.metaKey : event.ctrlKey;
const otherKey = isMacintosh ? event.ctrlKey : event.metaKey;
return primaryKey && !event.shiftKey && !event.altKey && !otherKey;
}
Comment on lines +538 to +539
],
default: 'ctrlCmd'
@calad0i
Copy link
Author

calad0i commented Mar 18, 2026

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants