Skip to content

Commit 933931a

Browse files
committed
feat(terminal): require Ctrl+click to open file and web links
Prevents accidental link activation when selecting text or clicking in the terminal. Uses Cmd+click on Mac, Ctrl+click on Linux.
1 parent c40a5f6 commit 933931a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/components/TerminalView.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ export function TerminalView(props: TerminalViewProps) {
9191
fitAddon = new FitAddon();
9292
term.loadAddon(fitAddon);
9393
term.loadAddon(
94-
new WebLinksAddon((_event, uri) => {
94+
new WebLinksAddon((event, uri) => {
95+
// Require Cmd+click (Mac) or Ctrl+click (Linux) to open links
96+
if (!(isMac ? event.metaKey : event.ctrlKey)) return;
9597
try {
9698
const parsed = new URL(uri);
9799
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
@@ -140,6 +142,9 @@ export function TerminalView(props: TerminalViewProps) {
140142
},
141143
text: link.text,
142144
activate(event: MouseEvent, _text: string) {
145+
// Require Cmd+click (Mac) or Ctrl+click (Linux) to open links
146+
const modifierHeld = isMac ? event.metaKey : event.ctrlKey;
147+
if (!modifierHeld) return;
143148
// Strip line:col suffix for opening
144149
const filePath = link.text.replace(/:\d+(:\d+)?$/, '');
145150
// Resolve relative paths against the task's working directory

0 commit comments

Comments
 (0)