Make code mouse more reliable with scroll position

This commit is contained in:
dylan 2023-05-09 08:21:34 -07:00
parent 1211891f53
commit 194209f18f

View File

@ -520,10 +520,12 @@ const update = async () => {
state.doubleClickTimer = 10;
}
const {x, y} = mousePos();
state.setSelection(pixelToIndex(state.code, x, y-8));
state.setSelection(pixelToIndex(state.code, x+state.scrollX, y+state.scrollY-8));
state.scrollToCursor();
} else if (mouseHeld()) {
const {x, y} = mousePos();
state.setFocus(pixelToIndex(state.code, x, y-8));
state.setFocus(pixelToIndex(state.code, x+state.scrollX, y+state.scrollY-8));
state.scrollToCursor();
} else {
state.wordMode = false;
}