Fix selection going to clipboard

Part of #699
This commit is contained in:
Daniel Imms
2017-06-19 15:45:18 -07:00
parent 75b74ac4ff
commit 8811d96a8b
2 changed files with 23 additions and 3 deletions
+15 -2
View File
@@ -293,10 +293,23 @@ export class SelectionManager extends EventEmitter {
/**
* Queues a refresh, redrawing the selection on the next opportunity.
*/
public refresh(): void {
public refresh(fromMouseEvent?: boolean): void {
// Queue the refresh for the renderer
if (!this._refreshAnimationFrame) {
this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh());
}
// If the refresh comes from a mouse event then emit a newselection event
if (!fromMouseEvent) {
return;
}
// TODO: Only do this when the selection has actually changed
// TODO: Ensure we're not doing more work than absolutely necessary, particularly for large selections
// TODO: Only do this on Linux
const selectionText = this.selectionText;
if (selectionText.length) {
this.emit('newselection', this.selectionText);
}
}
/**
@@ -392,7 +405,7 @@ export class SelectionManager extends EventEmitter {
}
this._addMouseDownListeners();
this.refresh();
this.refresh(true);
}
/**