Installed package: @xterm/xterm 6.1.0-beta.292 src/common/services/OptionsService.ts:52 rightClickSelectsWord: isMac, src/browser/CoreBrowserTerminal.ts:391-393 this._register(addDisposableListener(this.element!, 'contextmenu', (event: MouseEvent) => { rightClickHandler(event, this.textarea!, this.screenElement!, this._selectionService!, this.options.rightClickSelectsWord); })); src/browser/Clipboard.ts:86-95 export function rightClickHandler(..., shouldSelectWord: boolean): void { moveTextAreaUnderMouseCursor(ev, textarea, screenElement); if (shouldSelectWord) { selectionService.rightClickSelect(ev); } textarea.value = selectionService.selectionText; textarea.select(); } src/browser/services/SelectionService.ts:820-826 public rightClickSelect(ev: MouseEvent): void { if (!this._isClickInSelection(ev)) { if (this._selectWordAtCursor(ev, false)) { this.refresh(true); } this._fireEventIfSelectionChanged(); } } PR #2479 event order: 1. xterm registers the native listener on the nested .xterm element. 2. PR #2479 registers React onContextMenu on an outer div. 3. A contextmenu event bubbles through the nested listener before it reaches the outer handler. 4. The outer handler calls terminal.getSelection() after xterm can replace the selection. Browser event check with the real installed xterm package: Options: cols=12, rows=5, rightClickSelectsWord=true Buffer: "alpha bravo charlie" Initial selection: "alpha" Context-menu location: the word "charlie", outside the selection Observed JSON: {"before":"alpha","outer":"charlie","after":"charlie","screen":{"width":108,"height":90}} Result: the outer handler read the replacement word. It did not read the original selection.