Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18179,8 +18179,20 @@ <h3 data-i18n="kb.title">⌨️ Keyboard Shortcuts</h3>
// browser restoring focus after an alt-tab — leaves the pane visually active but
// deaf. A click on it is an unambiguous "I am typing here"; don't steal focus back
// when the user is dragging out a selection.
//
// Copy-on-select rides the same mouseup. xterm has no built-in option for it
// (that was an xterm v4 option, removed upstream), and a right-click can't
// fall back to the browser's native "Copy" because xterm clears the selection
// on the right mousedown before the context menu opens. It is NOT wired to
// `term.onSelectionChange`: that fires from the selection service's refresh on
// every animation frame while the mouse is still dragging, which is a
// clipboard write per frame — and over plain http `copyText()` falls back to a
// focused off-screen textarea, so it would also steal focus mid-drag.
host.addEventListener('mouseup', () => {
if (term.hasSelection && term.hasSelection()) return;
if (term.hasSelection && term.hasSelection()) {
copyText(term.getSelection()).catch(() => {});
return;
}
try { term.focus(); } catch {}
});
_connectTerminalWs(sessionId);
Expand Down
9 changes: 7 additions & 2 deletions test/composer-terminal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,13 @@ check('a reconnect refocuses the pane',
/ws\.onopen = \(\) => \{[\s\S]{0,700}?requestAnimationFrame\(\(\) => \{ try \{ term\.focus\(\); \} catch \{\} \}\);/.test(TB), true);
check('clicking the pane refocuses it',
/host\.addEventListener\('mouseup'[\s\S]{0,260}?term\.focus\(\)/.test(TB), true);
check('but not while a selection is being dragged out',
/host\.addEventListener\('mouseup'[\s\S]{0,160}?if \(term\.hasSelection && term\.hasSelection\(\)\) return;/.test(TB), true);
check('but not while a selection is being dragged out — that mouseup copies the selection instead',
/host\.addEventListener\('mouseup'[\s\S]{0,160}?if \(term\.hasSelection && term\.hasSelection\(\)\) \{\s*copyText\(term\.getSelection\(\)\)[^\n]*\n\s*return;/.test(TB), true);
// xterm fires onSelectionChange from the selection service's refresh on every
// animation frame while the mouse is still dragging — a clipboard write per frame,
// and over plain http copyText()'s textarea fallback steals focus mid-drag.
check('copy-on-select is not wired to term.onSelectionChange',
/term\.onSelectionChange\(/.test(TB), false);

console.log('\n— i18n: the three new keys exist in all five locales —');

Expand Down