Add config for linkActivationModifier and prevent link following when any other modifiers are down#302647
Open
calad0i wants to merge 3 commits intomicrosoft:mainfrom
Open
Add config for linkActivationModifier and prevent link following when any other modifiers are down#302647calad0i wants to merge 3 commits intomicrosoft:mainfrom
calad0i wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
isLinkModifierDownhelper. - 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
clickLabelcan remain empty whenterminal.integrated.linkActivationModifieris 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 whenclickLabelis 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' |
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 isterminal.integrated.linkActivationModifier.