Simplify conditions for entering visual mode

1. You can only enter visual mode from normal mode
2. Must select text to enter visual mode
3. Exit visual mode with escape, etc.

This fixes #2073.
This commit is contained in:
Oliver Blanthorn 2020-01-05 18:33:29 +00:00
parent 4f40438246
commit db61f979a6
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -356,11 +356,9 @@ config.getAsync("leavegithubalone").then(v => {
})
document.addEventListener("selectionchange", () => {
if (contentState.mode == "ignore") return
if (contentState.mode !== "normal") return
const selection = document.getSelection()
if (selection.anchorOffset == selection.focusOffset) {
contentState.mode = "normal"
} else {
if (selection.anchorOffset !== selection.focusOffset) {
contentState.mode = "visual"
}
})