Relates to: #2244
This works fine when a double-click highlights a word selection > 1 character. But if the selection only highlights a single character, getSelection() returns an empty string. Is this by design?
Online example: https://play.ddgame.us
I can't repro?

Did you double-click the M? It works if you click&hold and select a single character.
Perhaps this missing info is crucial here... my getSelection() occurs within the onSelectionChange() event, i.e.,
term.onSelectionChange(() => {
if (carrier) {
let word = term.getSelection()
if (word.length > 0 && word.length < 64) {
socket.send(word + '\x0D')
term.clearSelection()
}
}
})

@theflyingape I do see double clicking not sending sometimes, maybe the event isn't firing or something?
I took a shot at looking into this and seems like it's related to onMouseUp in the SelectionService... https://github.com/xtermjs/xterm.js/blob/afc39106c3707532136c0818e9d3aa1dbcf176ac/src/browser/services/SelectionService.ts#L665
https://github.com/xtermjs/xterm.js/blob/afc39106c3707532136c0818e9d3aa1dbcf176ac/src/browser/services/SelectionService.ts#L670
https://github.com/xtermjs/xterm.js/blob/afc39106c3707532136c0818e9d3aa1dbcf176ac/src/browser/services/SelectionService.ts#L671
The problem is that if the length of selectionText is <= 1, but event.altKey doesn't return true, the selection gets thrown away and this._onSelectionChange.fire() doesn't get called. Is there a reason that we can't just always call this._onSelectionChange.fire(), even if event.altKey is true?
Thoughts? @Tyriar @theflyingape
@daniel-j-davis good find! Moving this event.altKey up one line would probably fix it, do you want to do a PR?
To verify, make sure alt+click still works by moving the cursor horizontally in a prompt with input
@Tyriar Yeah, that works too and I've verified that alt+click still works as expected.
4.7.0 works great, thanks!
Most helpful comment
4.7.0 works great, thanks!