fix wonky scanning logic

This commit is contained in:
Alex Yatskov 2017-02-26 12:06:37 -08:00
parent ec0aded9bb
commit da124f6c27

View File

@ -22,7 +22,8 @@ class Driver {
this.popup = new Popup(); this.popup = new Popup();
this.popupTimer = null; this.popupTimer = null;
this.lastMousePos = null; this.lastMousePos = null;
this.leftMouseDown = false; this.mouseDownLeft = false;
this.mouseDownMiddle = false;
this.lastTextSource = null; this.lastTextSource = null;
this.pendingLookup = false; this.pendingLookup = false;
this.options = null; this.options = null;
@ -64,16 +65,16 @@ class Driver {
return; return;
} }
if (this.leftMouseDown) { if (this.mouseDownLeft) {
return; return;
} }
if (this.options.scanning.requireShift && !e.shiftKey) { if (this.options.scanning.requireShift && !e.shiftKey && !this.mouseDownMiddle) {
return; return;
} }
const searcher = () => this.searchAt(this.lastMousePos); const searcher = () => this.searchAt(this.lastMousePos);
if (!this.popup.isVisible() || e.shiftKey || e.which === 2 /* mmb */) { if (this.popup.isVisible()) {
searcher(); searcher();
} else { } else {
this.popupTimerSet(searcher); this.popupTimerSet(searcher);
@ -86,13 +87,17 @@ class Driver {
this.searchClear(); this.searchClear();
if (e.which === 1) { if (e.which === 1) {
this.leftMouseDown = true; this.mouseDownLeft = true;
} else if (e.which === 2) {
this.mouseDownMiddle = true;
} }
} }
onMouseUp(e) { onMouseUp(e) {
if (e.which === 1) { if (e.which === 1) {
this.leftMouseDown = false; this.mouseDownLeft = false;
} else if (e.which === 2) {
this.mouseDownMiddle = false;
} }
} }